MAB Posted September 14, 2015 Share Posted September 14, 2015 the problem is that the "unbind" function isn't working.... local sf = createMarker (-1882.83887,865.99182,36.17188,"arrow",2,0,0,255,255) out = createMarker (161.37592,-96.44353,1002.80469,"arrow",2,0,0,255,255) setElementInterior(out,18) createBlipAttachedTo(sf,45) local dir = 0.020 setTimer( function() if dir == -0.020 then dir = 0.020 elseif dir == 0.020 then dir = -0.020 end end,1000,0 ) function float () local x,y,z = getElementPosition(sf) local place = z + dir setElementPosition(sf,x,y,place) local x2,y2,z2 = getElementPosition(out) local place2 = z2 + dir setElementPosition(out,x2,y2,place2) end addEventHandler("onClientRender", root,float) function bind (hit,dim) if getElementType(hit) == "player" and not isPedInVehicle(hit) and dim == true then bindKey ("h","down",onhit) end end addEventHandler("onClientMarkerHit",sf,bind) function unbind (hit) if hit == localPlayer then unbind("h","down",onhit) end end addEventHandler("onClientMarkerLeave",sf,unbind) function onhit () local x,y,z = getElementPosition(localPlayer) setElementData(localPlayer,"clo.x",x) setElementData(localPlayer,"clo.y",y) setElementData(localPlayer,"clo.z",z) fadeCamera(false) toggleAllControls(false) setElementFrozen(localPlayer,true) setTimer(enter,2000,1,localPlayer) unbindKey ("h","down",onhit) end function enter (player) if isElement(player) then setElementFrozen(player,false) toggleAllControls(true) fadeCamera(true) setElementInterior (player,18,161.48351,-94.52599,1001.80469) toggleControl ("fire",false) toggleControl ("aim_weapon",false) end end function outside (hit) fadeCamera(false) toggleAllControls(false) setElementFrozen(hit,true) setTimer(onleave,2000,1,localPlayer) end addEventHandler("onClientMarkerHit",out,outside) function onleave (player) if isElement(player) then setElementFrozen(player,false) toggleAllControls(true) fadeCamera(true) toggleControl ("fire",true) toggleControl ("aim_weapon",true) local x = getElementData(player,"clo.x") local y = getElementData(player,"clo.y") local z = getElementData(player,"clo.z") setElementInterior (player,0,x,y,z) end end Link to comment
LoOs Posted September 14, 2015 Share Posted September 14, 2015 unbind("h","down",onhit) unbind = unbindKey Link to comment
MAB Posted September 14, 2015 Author Share Posted September 14, 2015 unbind("h","down",onhit) unbind = unbindKey lol Link to comment
JR10 Posted September 16, 2015 Share Posted September 16, 2015 function unbind (hit) if hit == localPlayer then unbind("h","down",onhit) end end addEventHandler("onClientMarkerLeave",sf,unbind) You're calling the function itself again, only this time with different arguments so it will fail to continue because of the condition. function unbind (hit) if hit == localPlayer then unbindKey("h","down",onhit) end end addEventHandler("onClientMarkerLeave",sf,unbind) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now