mtasa-blue
mtasa-blue copied to clipboard
Fix #539 Changing player position when he/she has a jetpack will remove the jetpack and bug when skin is changed
Fixed #539
Jetpack is removed because the GTA function that is called CPed::Teleport aborts all tasks (including jetpack).
Then when changing the skin, the jetpack is set based on the m_bHasJetPack variable, which is true because its state is not changed when the position is changed, therefore the new skin gets the jetpack that was removed by GTA, but the MTA still knows that the player has the jetpack because he doesn't know that GTA removed it.
https://github.com/multitheftauto/mtasa-blue/blob/97920d83de400e0378f73ea93e87b27cf59dd758/Client/mods/deathmatch/logic/CClientPed.cpp#L5232
Therefore, we first check whether the player has a jetpack before changing position, and then set it after changing position depending on whether he had it before.
Good stuff
The code looks fine, but I don't think we want to introduce desync (new client sees jetpack, older clients do not) right now
The code looks fine, but I don't think we want to introduce desync (new client sees jetpack, older clients do not) right now
Will simply taking a jetpack when changing positions solve the problem?
I would keep the jetpack on the player.
@botder I think I solved the desync problem by sending a GIVE_PED_JETPACK packet. So now it is no longer bakcwards-incompatible
"Changing player position when he/she has a jetpack will remove the jetpack and bug when skin is changed"
If you set the warp param to false in setElementPosition it will preserve the jetpack animation and won't take away the player's jetpack. If the scripter uses this option when teleporting players with jetpack, then he/she won't have to worry about skin changes.
Video: https://youtu.be/BLVGxOA0NIY
"Changing player position when he/she has a jetpack will remove the jetpack and bug when skin is changed"
If you set the
warpparam to false insetElementPositionit will preserve the jetpack animation and won't take away the player's jetpack. If the scripter uses this option when teleporting players with jetpack, then he/she won't have to worry about skin changes.Video: https://youtu.be/BLVGxOA0NIY
Yeah, this happens because if the warp argument is set to false, only the position vector in the matrix/transform of the given entity is changed. However, when warp is true, a GTA function is called, specifically CPed::Teleport. This function aborts all tasks, including the jetpack. In the case of teleportation, the ped is literally recreated: it’s removed from the world, its position is changed, and it’s added back to the world.
https://github.com/gta-reversed/gta-reversed/blob/6e2e236c9f46a049d30c3b5097c275c8b15eeae4/source/game_sa/Entity/Ped/Ped.cpp#L3390-L3406