SA-MP Forums Archive
Trying this under OnPlayerWeaponShot - Doesn't seem to work. - 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: Trying this under OnPlayerWeaponShot - Doesn't seem to work. (/showthread.php?tid=560301)



Trying this under OnPlayerWeaponShot - Doesn't seem to work. - Dokins - 28.01.2015

pawn Код:
new ammo = GetPlayerAmmo(playerid);
    if(ammo == 0)
    {
            ProxDetector(30.0, playerid, "* CLINK *", COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
            SendClientMessage(playerid, COLOUR_GREY, "You are out of ammo for this weapon. You need to load more into it, before you can use it again.");
    }
It doesn't 'CLINK' when the AMMO is 0, could someone tell me why?


Re: Trying this under OnPlayerWeaponShot - Doesn't seem to work. - semara123 - 28.01.2015

try to put in onplayerupdate


Re: Trying this under OnPlayerWeaponShot - Doesn't seem to work. - Schneider - 28.01.2015

Do you by chance have Lag-compensation turned off?


Re: Trying this under OnPlayerWeaponShot - Doesn't seem to work. - Abagail - 28.01.2015

If the ammo is 0, then the weapon gets "trashed". The player looses the weapon when they run out of ammo, so therefore it wouldn't be called.

The exception would be weapons such as MP5, where you can fire multiple shots, and it'd be shooting a few extra(due to lag?) after the initial shot(s) were actually fired.

Note, you should return 0 if you don't want bullets to go through and sync to the server(and give damage, etc.).

A work-around for this would to be monitoring players with low weapon ammo, and freezing the weapon usage upon having 1 ammo round left.


Re: Trying this under OnPlayerWeaponShot - Doesn't seem to work. - DRIFT_HUNTER - 28.01.2015

Im pretty sure that the bullets are decreased on server only after these (and maybe few more) callback(s).

Try if(ammo-1 == 0) (I dont think that it will work but still there is a change and it doesnt cost you to test...)


Re: Trying this under OnPlayerWeaponShot - Doesn't seem to work. - Dokins - 28.01.2015

Sorry for the delay.

Thank you for all your responses. I have lag compensation on. I thought it was something to do with the fact that the weapon gets trashed.

I save weapons with unique ID's. So they don't really get 'trashed' I'll come up with an alternative. Thank you all very kindly.


Re: Trying this under OnPlayerWeaponShot - Doesn't seem to work. - Vince - 28.01.2015

Try GetPlayerWeaponState with WEAPONSTATE_LAST_BULLET.