weapon automatically removed with 0 ammo
#1

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.
Reply
#2

try this:

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
   if(
GetPlayerAmmo(playerid) == 1)
   {
      
GivePlayerGun(playeridweaponid1);
   }
   return 
1;

Reply
#3

Quote:
Originally Posted by ReD_HunTeR
Посмотреть сообщение
try this:

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
   if(
GetPlayerAmmo(playerid) == 1)
   {
      
GivePlayerGun(playeridweaponid1);
   }
   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.
Reply
#4

Why not give them infinite ammo?

GivePlayerGun(playerid, weaponid, -1);

or GivePlayerGun(playerid, weaponid, 9999);
Reply
#5

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..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)