SA-MP Forums Archive
Detecting ammo at 0 for all guns - 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: Detecting ammo at 0 for all guns (/showthread.php?tid=307722)



Detecting ammo at 0 for all guns - cloudysky - 31.12.2011

Hi,

I'm trying to detect when a players ammo reaches 0 so I can send them a little message (using SendClientMessage)
but I don't want to do it for one gun, so not just the MP5 for example every gun. How can i go about doing this and if it isn't too much to ask an example would be a lot more helpful.


Re: Detecting ammo at 0 for all guns - Dark_Kostas - 31.12.2011

pawn Код:
new PlayerWeapons[MAX_PLAYERS][13][2];

OnPlayerUpdate(playerid)
{
       new TempWeapons[13][2];
       for (new i = 0; i < 13; i++)
       {
              GetPlayerWeaponData(playerid, i, TempWeapons[i][0], TempWeapons[i][1]);
              if (TempWeapons[i][1] == 0 && PlayerWeapons[playerid][i][1] > 0) SendClientMessage(playerid, 0xFF000000, "You run out of ammo");
       }

       for (new i = 0; i < 13; i++)
       {
              GetPlayerWeaponData(playerid, i, PlayerWeapons[playerid][i][0], PlayerWeapons[playerid][i][1]);
       }

       return 1;
}
I think something like that will work. Make sure you reset PlayerWeapons variable when a player connect(or disconnect it depends on you) back to 0.