Reset a variabile when player don't have any ammo
#1

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;

Reply
#2

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

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;
}
Reply
#4

https://sampwiki.blast.hk/wiki/GetPlayerWeaponState
Reply
#5

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)