Disabling fire when the ammo == 1
#1

Hi!

I need a script,which disables firing if the ammo of the weapon is == 1.
Thanks
Reply
#2

Not really possible. Weapon firing is handled client-side.
Reply
#3

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE)
    {
        if(GetPlayerAmmo(playerid) == 1) SetPlayerArmedWeapon(playerid, 0);
    }
    return 1;
}
Reply
#4

Will this work?If there is only 1 bullet in the weapon,the player is going to switch to hand?
Reply
#5

Not really, if they're lagging (even by like 5 MS) they will shoot the bullet before the server has a chance to detect it.
Reply
#6

Well I tested it with desert eagle. I had one bullet and it switched to hand. It's not really accurate, like if I'll do c-bug I can shot that ammo out.

However I think you can put that under a timer. So it will switch automatically if you'll hold a weapon with 1 bullet.
Reply
#7

No.On my server the players can hold the weapon with 1 bullet,because it's equal to a weapon without bullets(in the real life).So players can scare others players,even if there is no bullet in the weapon.(Roleplay Server)
If this isn't possible,how can I do that player can hold weapon with no ammo?
Reply
#8

Another thing that is yet impossible. Once a weapon reaches 0 ammo, it is automatically removed. There are some objects that you can attach using SetPlayerAttachedObject, like weapons, just search for them on the internet, and you can attach weapons once the weapon runs out of ammo.
Reply
#9

That's why I would like to do it with the 1 bullet system.But yes,if the player is lagging it isn't working
Reply
#10

What about GetPlayerWeaponState? WEAPONSTATE_LAST_BULLET
That might be pretty accurate if used with OnPlayerUpdate.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)