Jump to content

is it possible to cancel 'onClientPlayerWeaponFire' ?


Fist

Recommended Posts

as title says, is it possible to cancel event onClientPlayerWeaponFire or onPlayerWeaponFire ? Tried both of them to cancel with cancelEvent but didn't work.

p.s: toggleControl is not solution for me, i want to play tick sound when player has 1 ammo. ( that 1 ammo would be fake bullet that ) and if i just toggle off fire control then i can't play that sound 'cause there would be no way to know when player wants to fire. Atleast i think that way.

here is code what i tried with.

addEventHandler("onClientPlayerWeaponFire",localPlayer,function()
	if (getPedTotalAmmo(localPlayer) <= 1) then cancelEvent(); end
end);

 

Link to comment
2 hours ago, Fist said:

as title says, is it possible to cancel event onClientPlayerWeaponFire or onPlayerWeaponFire ? Tried both of them to cancel with cancelEvent but didn't work.

p.s: toggleControl is not solution for me, i want to play tick sound when player has 1 ammo. ( that 1 ammo would be fake bullet that ) and if i just toggle off fire control then i can't play that sound 'cause there would be no way to know when player wants to fire. Atleast i think that way.

here is code what i tried with.


addEventHandler("onClientPlayerWeaponFire",localPlayer,function()
	if (getPedTotalAmmo(localPlayer) <= 1) then cancelEvent(); end
end);

 

addEventHandler("onClientPlayerWeaponFire",localPlayer,function()
	if (getPedTotalAmmo(localPlayer) <= 1) then 
      cancelEvent()
    end
end)

 

Link to comment
Just now, kewizzle said:

addEventHandler("onClientPlayerWeaponFire",localPlayer,function()
	if (getPedTotalAmmo(localPlayer) <= 1) then 
      cancelEvent()
    end
end)

 

Why you give me same code that i wrote only differently sorted?

Link to comment
1 minute ago, kewizzle said:

the use of ";" isnt needed

i know that, it's just preference. I like code better how it looks with ";" and neither way it's not incorrect. Please, don't spam this topic if you don't know how solve this issue. You're not making any point here.

Link to comment
1 hour ago, Fist said:

i know that, it's just preference. I like code better how it looks with ";" and neither way it's not incorrect. Please, don't spam this topic if you don't know how solve this issue. You're not making any point here.

im working on a code for you...

Link to comment
20 minutes ago, kewizzle said:

refer to this topic.

 

toggle control still allows you to play a tick sound.

Please, close this topic and never open it again.

p.s i found different solution without using toggleControl and canceling event on fire.

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...