Jump to content

getZoneName


Axel

Recommended Posts

I'm getting a strange error on this little script:

function onClientPlayerWeaponFireFun(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 
local x,y,z = getElementPosition(source) 
    if getZoneName(tonumber(x),tonumber(y),tonumber(z),true) == "San Fierro" then  
        cancelEvent() 
    end 
end 
addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFun ) 

No error, but i can still shot with guns in SF..

Link to comment

This event can't be canceled

you need to disable fire

toggleControl("fire",false) 

function onClientPlayerWeaponFireFun(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 
local x,y,z = getElementPosition(source) 
    if getZoneName(tonumber(x),tonumber(y),tonumber(z),true) == "San Fierro" then 
        toggleControl("fire",false) 
    else 
        toggleControl("fire",true) 
    end 
end 
addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFun ) 

also use bindKey better

function xxx() 
local x,y,z = getElementPosition(localPlayer) 
    if getZoneName(tonumber(x),tonumber(y),tonumber(z),true) == "San Fierro" then 
        toggleControl("fire",false) 
    else 
        toggleControl("fire",true) 
    end 
end 
bindKey("fire", "down", xxx) 

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...