SA-MP Forums Archive
Reset a variabile when player don't have any ammo - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Reset a variabile when player don't have any ammo (/showthread.php?tid=397118)



Reset a variabile when player don't have any ammo - Night Dreamer - 03.12.2012

I have an "globale variabile" I want to reset the "globale variabile" on player when he is use the last bullet of weapon or don't have bullet.
Example of an ideea:
PHP код:
public OnPlayerUpdate(playerid)
{
    new 
wpnammo
    
GetPlayerWeaponData(playerid5wpnammo)
    
g_variabile[playerid][amunition] = ammo
    
    
return 1;




Re: Reset a variabile when player don't have any ammo - Feastahashi - 03.12.2012

Код:
public OnPlayerUpdate(playerid) 
{ 
new wpn, ammo;  
    GetPlayerWeaponData(playerid, 5, wpn, ammo) 
if(ammo = 0 && IsPlayerConnected(playerid))
{
    g_variabile[playerid][amunition] = 0
}
return 1;
}



Re: Reset a variabile when player don't have any ammo - Randy More - 03.12.2012

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(GetPlayerWeapon(playerid) == 30 || GetPlayerWeapon(playerid) == 31)
    {
        if(GetPlayerAmmo(playerid) == 0) g_variabile[playerid][amunition] = 0; // A note: This will be done several times until the weapon is actually removed, like if if you made a message for DEBUGGING, it will be sent like 3-4 hours, as the player keeps updating and it will stop once the gun is out of his hands. This shouldn't be a problem with this case, it just sets the value to 0 several times.
    }
    return 1;
}



Re: Reset a variabile when player don't have any ammo - Vince - 03.12.2012

https://sampwiki.blast.hk/wiki/GetPlayerWeaponState


Re: Reset a variabile when player don't have any ammo - Konstantinos - 03.12.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
I didn't know about this function. Thanks!


Re: Reset a variabile when player don't have any ammo - Night Dreamer - 03.12.2012

Probleme is I don't wana to use in OnPlayerUpdate or timer... and idee I has to use on
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys == && GetPlayerWeaponState(playerid) == WEAPONSTATE_NO_BULLETS)
    {
        
//personal code below
    
}

PS: I hope it will work