weapon system help!! - 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: weapon system help!! (
/showthread.php?tid=420339)
weapon system help!! -
PaulDinam - 04.03.2013
I made a perm weapon system.
The player can hold only 2 weapons, primary and secondary.
My question is: How can I make an update to check if the player has ammo in the weapon and if not.
so the weapon variable will update. or I can use it on OnPlayerUpdate
I made the stocks which checks if the player has ammo so it will return the weapon id otherwise it will return 0 as no gun in the slot.
Where can I use it to update?
pawn Код:
stock GetPrimaryWeapon(playerid)
{
if(GetWeaponAmmo(playerid, PlayerInfo[playerid][pWep1]) > 0)
return PlayerInfo[playerid][pWep1];
else
return 0;
}
stock GetSecondaryWeapon(playerid)
{
if(GetWeaponAmmo(playerid, PlayerInfo[playerid][pWep2]) > 0)
return PlayerInfo[playerid][pWep2];
else
return 0;
}
Re: weapon system help!! -
PaulDinam - 04.03.2013
Nevermind found a way without a timer
pawn Код:
if(RELEASED(KEY_FIRE))
{
if(GetWeaponAmmo(playerid, PlayerInfo[playerid][pWep1]) == 0) PlayerInfo[playerid][pWep1] = 0;
if(GetWeaponAmmo(playerid, PlayerInfo[playerid][pWep2]) == 0) PlayerInfo[playerid][pWep2] = 0;
}