weapon automatically removed with 0 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: weapon automatically removed with 0 ammo (
/showthread.php?tid=570942)
weapon automatically removed with 0 ammo -
J4Rr3x - 14.04.2015
Hi all,
Today I have a problem with weapons and ammo.
Gta sa automatically remove all weapons with 0 ammo, but I need to hook this. So, when the player have 0 ammo in his weapon him must to stay with weapon in hand.
I've tried OnPlayerWeaponShot with this code:
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(hittype >= BULLET_HIT_TYPE_NONE)
{
if(GetPlayerAmmo(playerid) < 1)
GivePlayerGun(playerid, weaponid, 1);
}
return 1;
}
But, it's not work..
Thanks in advance.
Re: weapon automatically removed with 0 ammo -
ReD_HunTeR - 14.04.2015
try this:
PHP код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(GetPlayerAmmo(playerid) == 1)
{
GivePlayerGun(playerid, weaponid, 1);
}
return 1;
}
Re: weapon automatically removed with 0 ammo -
J4Rr3x - 14.04.2015
Quote:
Originally Posted by ReD_HunTeR
try this:
PHP код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(GetPlayerAmmo(playerid) == 1)
{
GivePlayerGun(playerid, weaponid, 1);
}
return 1;
}
|
Thanks, you have illuminated me!
I had a bug in OnPlayerUpdate and i've used "< 2" instead of "== 1". Because if player shooting with a M4 (it have rapid fire) the player receive the weapon after some ms.
Re: weapon automatically removed with 0 ammo -
Kar - 15.04.2015
Why not give them infinite ammo?
GivePlayerGun(playerid, weaponid, -1);
or GivePlayerGun(playerid, weaponid, 9999);
Re: weapon automatically removed with 0 ammo -
J4Rr3x - 15.04.2015
Quote:
Originally Posted by Kar
Why not give them infinite ammo?
GivePlayerGun(playerid, weaponid, -1);
or GivePlayerGun(playerid, weaponid, 9999);
|
I don't understand this method, sorry..