Closed FileEX closed 13 hours ago
// 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 bRestoreState
become true so it loop through the list
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.
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 at line 5226 it alredy set the weapon slot SetCurrentWeaponSlot(weaponSlot);
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);
}
so setting bRestoreState to true should fix the issue if I am not wrong
You're wrong. I described what the problem is. bRestoreState
is true, but still the weapon slot is not set correctly without my fix.
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
https://github.com/multitheftauto/mtasa-blue/blob/97920d83de400e0378f73ea93e87b27cf59dd758/Client/mods/deathmatch/logic/CClientPed.cpp#L2209-L2211
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.
https://github.com/multitheftauto/mtasa-blue/blob/97920d83de400e0378f73ea93e87b27cf59dd758/Client/mods/deathmatch/logic/CClientPed.cpp#L2148-L2152
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.