Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #539 Changing player position when he/she has a jetpack will remove the jetpack and bug when skin is changed #3511

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

FileEX
Copy link
Contributor

@FileEX FileEX commented Jun 25, 2024

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.

SetHasJetPack(m_bHasJetPack);

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.

@Fernando-A-Rocha
Copy link
Contributor

Good stuff

@botder botder added the backwards-incompatible Should be merged after the release of 1.6.1 label Jun 26, 2024
@botder
Copy link
Member

botder commented Jun 26, 2024

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

@FileEX
Copy link
Contributor Author

FileEX commented Jun 26, 2024

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?

@botder
Copy link
Member

botder commented Jun 26, 2024

I would keep the jetpack on the player.

@tederis tederis added the bugfix Solution to a bug of any kind label Jun 27, 2024
@FileEX
Copy link
Contributor Author

FileEX commented Jul 16, 2024

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

@derxgbb
Copy link

derxgbb commented Oct 29, 2024

"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

@FileEX
Copy link
Contributor Author

FileEX commented Oct 29, 2024

"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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards-incompatible Should be merged after the release of 1.6.1 bugfix Solution to a bug of any kind
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changing player position when he/she has a jetpack will remove the jetpack and bug when skin is changed
9 participants