mtasa-blue icon indicating copy to clipboard operation
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

Open FileEX opened this issue 1 year ago • 5 comments

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.

FileEX avatar Jun 25 '24 11:06 FileEX

Good stuff

Fernando-A-Rocha avatar Jun 25 '24 11:06 Fernando-A-Rocha

The code looks fine, but I don't think we want to introduce desync (new client sees jetpack, older clients do not) right now

botder avatar Jun 26 '24 12:06 botder

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?

FileEX avatar Jun 26 '24 14:06 FileEX

I would keep the jetpack on the player.

botder avatar Jun 26 '24 15:06 botder

@botder I think I solved the desync problem by sending a GIVE_PED_JETPACK packet. So now it is no longer bakcwards-incompatible

FileEX avatar Jul 16 '24 11:07 FileEX

"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

ghost avatar Oct 29 '24 22:10 ghost

"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

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

FileEX avatar Oct 29 '24 23:10 FileEX