Jump to content

Cancel the 'onClientPlayerWeaponFire' Event


Recommended Posts

Helly guys...

I have a problem with my script. I made a pizza shop for my RPG server and everything is working fine but I wanted to disable all guns in the interiour. But as many of you should know the 'onClientPlayerWeaponFire' is not cancelable. I want to disable even the fists of the player. But with the client-sided functions I think this isn't really possible but I already saw a server where all weapons can't be fired. Is there any possibility to cancel the event for firing a weapon? Here is my code:

NOTE: debugscript says nothing and the 'ouputChatBox' at line 10 is working

EDIT: Yes, I tried onClientPedWeaponFire and onClientPlayerWeaponFire!

function createMarkersOnStart()
pizza1_enter = createMarker(-1807.91796875, 944.9990234375, 24.890625 + 1, "arrow", 1.5, 255, 255, 0, 127)
end
addEventHandler("onClientResourceStart", getRootElement(), createMarkersOnStart)
 
 
function hit(theElement, dimension)
function disableguns()
cancelEvent()
outputChatBox("event cancelled")
end
if (source == pizza1_enter) then
setElementInterior(theElement, 5, 370.6513671875, -131.3515625, 1001.4921875)
	pizza1_exit = createMarker(372.4521484375, -133.2509765625, 1001.4921875 + 1, "arrow", 1.5, 255, 255, 0, 127)
	pizza1_buy = createMarker(372.763671875, -119.2587890625, 1001.4921875 - 1, "cylinder", 1.5, 255, 0, 0, 127)
setElementInterior(pizza1_exit, 5)
setElementInterior(pizza1_buy, 5)
addEventHandler("onClientPedWeaponFire", getRootElement(), disableguns)
end
if (source == pizza1_buy) then
	showPizzaBuyGUI()
end
if (source == pizza1_exit) then
setElementInterior(theElement, 0)
setElementPosition(theElement, -1804.9384765625, 941.861328125, 24.890625)
	closePizzaBuyGUI()
removeEventHandler("onClientPedWeaponFire", getRootElement(), disableguns)
end
 
 
end
addEventHandler("onClientMarkerHit", getRootElement(), hit)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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