SA-MP Forums Archive
Prevent player from shooting - 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: Prevent player from shooting (/showthread.php?tid=649473)



Prevent player from shooting - Eibison - 09.02.2018

I'm writing a code on which when it detects player haves 1 ammo on any weapon, it prevents him from shooting his gun. Nevertheless, I've been trying to stop the player being able to shoot and its been impossible for me.

What can I do?


Re: Prevent player from shooting - PepsiCola23 - 09.02.2018

use
PHP код:
GetPlayerAmmo(playerid); 
,get his ammo here
PHP код:
OnPlayerWeaponShot 
if the ammo is 1,return 0; so the bullet won`t cause dmg and reset his weapon by giving it back with 1 ammo.

thats the only method i know


Re: Prevent player from shooting - Eibison - 09.02.2018

That's interesting. But for esthetics sake, there's a way which the player can't shoot the weapon at all?


Re: Prevent player from shooting - wallen - 09.02.2018

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange


Re: Prevent player from shooting - Mugala - 09.02.2018

just clear the player's animation when he tries to aim (u can detect aiming with key or GetAnimationIndex & Name)


Re: Prevent player from shooting - Eibison - 10.02.2018

This didn't work. I've tried clearing anims when player aims but that doesn't seem to work to stop the aiming.


Re: Prevent player from shooting - PepsiCola23 - 10.02.2018

check my method,i think its gonna work


Re: Prevent player from shooting - Mugala - 10.02.2018

Quote:
Originally Posted by Eibison
Посмотреть сообщение
This didn't work. I've tried clearing anims when player aims but that doesn't seem to work to stop the aiming.
u can simply use SetPlayerArmedWeapon too or SetPlayerPos (same pos where he's standing, for clearing an animation)


Re: Prevent player from shooting - Astralis - 11.02.2018

SetPlayerArmedWeapon(playerid,0); if ammo is 1.


Re: Prevent player from shooting - Eibison - 11.02.2018

Quote:
Originally Posted by Astralis
Посмотреть сообщение
SetPlayerArmedWeapon(playerid,0); if ammo is 1.
F***ing love you. Thanks, this is exactly what I wanted