03.05.2015, 15:56
Hi.
I use OnPlayerChangeWeapon in OnPlayerUpdate for check if player switch weapon.
The "basic" code:
However I want to use as a parameter in the callback OnPlayerChangeWeapon the id of my custom weapons.
I did that:
However when I callback weapon switch OnPlayerChangeWeapon is not called .
I found that in my for loop I use Weapons [ playerid ] [ ActiveWeapon [ playerid ]] [Model ] to make the comparison ( This variable stores the id of the custom weapon the player has in hand) , it remains unchanged thereafter, but I do not want to change right away, only OnPlayerChangeWeapon .
Thank you .
I use OnPlayerChangeWeapon in OnPlayerUpdate for check if player switch weapon.
The "basic" code:
pawn Код:
if(GetPlayerWeapon(playerid) != Lastgun[playerid])
{
OnPlayerChangeWeapon(playerid, Lastgun[playerid], GetPlayerWeapon(playerid));
}
Lastgun[playerid] = GetPlayerWeapon(playerid);
I did that:
pawn Код:
new id_array = -1;
for(new w; w < sizeof(wep_Data); w++)
{
if(wep_Data[w][wep_CustomWeapon] != -1 && wep_Data[w][wep_CustomWeapon] == Armes[playerid][ActiveWeapon[playerid]][Model]) // Arme actu
{
id_array = w;
}
}
if(id_array != -1)
{
if(wep_Data[id_array][wep_CustomWeapon] != AncienneArme[playerid])
{
OnPlayerChangeWeapon(playerid, AncienneArme[playerid], wep_Data[id_array][wep_CustomWeapon]);
}
AncienneArme[playerid] = wep_Data[id_array][wep_CustomWeapon];
}
I found that in my for loop I use Weapons [ playerid ] [ ActiveWeapon [ playerid ]] [Model ] to make the comparison ( This variable stores the id of the custom weapon the player has in hand) , it remains unchanged thereafter, but I do not want to change right away, only OnPlayerChangeWeapon .
Thank you .