-
-
Notifications
You must be signed in to change notification settings - Fork 412
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 #501 Setting player model resets their current weapon slot #3510
Conversation
// Set it to 0 (Fix #501)
SetCurrentWeaponSlot(eWeaponSlot::WEAPONSLOT_TYPE_UNARMED);
if (bRestoreState)
{
// Jax: restore all the things we saved
SetHealth(fHealth);
SetArmor(fArmor);
SetCurrentWeaponSlot(weaponSlot);
SetCurrentRotation(fCurrentRotation);
m_pPlayerPed->SetTargetRotation(fTargetRotation);
SetMoveSpeed(vecMoveSpeed);
SetHasJetPack(m_bHasJetPack);
SetInterior(ucInterior);
} what about this condition after it set the weapon slot should not |
I do not understand what you mean. After changing the skin, the slot changes to 0 anyway, but the MTA does not recognize it, so setting the slot to 0 from the MTA level solves the problem. |
you can notice a condtion after your fix
so setting bRestoreState to true should fix the issue if I am not wrong |
You're wrong. I described what the problem is.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job!
mainly the issue comes from if (weaponSlot != GetCurrentWeaponSlot())
returning false, I was confused at the start
Fixed #501
In the case of non-player peds weapon the slot is set correctly, but in the case of player peds the slot is not set.
This is due to the fact that the slot for the player is taken directly from the GTA memory
mtasa-blue/Client/mods/deathmatch/logic/CClientPed.cpp
Lines 2209 to 2211 in 97920d8
and when the skin respawns, the slot in the game memory is still the one we had before changing the skin. This causes the condition result is false.
mtasa-blue/Client/mods/deathmatch/logic/CClientPed.cpp
Lines 2148 to 2152 in 97920d8
As a result, the weapon slot is not set at all. Therefore, we first set the weapon slot to 0 to make this condition true.