Prevent player from shooting
#1

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

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
Reply
#3

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

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#5

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

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

check my method,i think its gonna work
Reply
#8

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)
Reply
#9

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)