bogdyutzu Posted January 12, 2013 Posted January 12, 2013 Hello, I have a problem with bindKey. I've tried to bind a player (client-side) when enter in colshape (also client-side) and unbind the player when he leave the colshape. But the problem is bindKey because is bind all players. This is the code: function onClientColShapeHit(element) if element == localPlayer then bindKey("mouse2", "up", onClientExitProp, getElementData(source, "pickup")) end end function onClientColShapeLeave(element) if element == localPlayer then unbindKey("mouse2", "up") end end
Drakath Posted January 12, 2013 Posted January 12, 2013 function onClientColShapeHit(element) if element == localPlayer then bindKey(source, "mouse2", "up", onClientExitProp, getElementData(source, "pickup")) end end function onClientColShapeLeave(element) if element == localPlayer then unbindKey(source, "mouse2", "up") end end
ChoTax Posted January 12, 2013 Posted January 12, 2013 try this .. function onClientColShapeHit() bindKey(localPlayer, "mouse2", "up" ) end addEventHandler("onClientColShapeHit",getRootElement(),onClientColShapeHit) function onClientColShapeLeave() unbindKey(localPlayer, "mouse2", "up") end addEventHandler("onClientColShapeLeave",getRootElement(),onClientColShapeLeave)
MR.S3D Posted January 12, 2013 Posted January 12, 2013 try this .. function onClientColShapeHit() bindKey(localPlayer, "mouse2", "up" ) end addEventHandler("onClientColShapeHit",getRootElement(),onClientColShapeHit) function onClientColShapeLeave() unbindKey(localPlayer, "mouse2", "up") end addEventHandler("onClientColShapeLeave",getRootElement(),onClientColShapeLeave) this does not make any sense in clinent side player element not Required Required Arguments should be bindKey (key, keyState, function) more info : [url=https://wiki.multitheftauto.com/wiki/BindKey]https://wiki.multitheftauto.com/wiki/BindKey[/url] [url=https://wiki.multitheftauto.com/wiki/UnBindKey]https://wiki.multitheftauto.com/wiki/UnBindKey[/url]
Castillo Posted January 12, 2013 Posted January 12, 2013 He should check though, if the hit element is the local player, else, it'll bind the key when a remote player hits it.
iPrestege Posted January 12, 2013 Posted January 12, 2013 He should check though, if the hit element is the local player, else, it'll bind the key when a remote player hits it. Is this true? function ShowGui() guiSetVisible(GUIEditor_Window[1],not guiGetVisible(GUIEditor_Window[1])) showCursor(guiGetVisible(GUIEditor_Window[1])) guiSetInputEnabled(guiGetVisible(GUIEditor_Window[1])) end bindKey("F1","down",ShowGui) ColShape = createColRectangle (x, y, Width, Height ) -- Create ColShape addEventHandler( "onClientColShapeHit", ColShape, -- Event On Hit function ( thePlayer ) if ( thePlayer == localPlayer ) then -- Check LocalPlayer unbindKey ( "F1", "down", ShowGui ) -- UnbindKey end end ) addEventHandler( "onClientColShapeLeave", ColShape,-- OnLeave function ( thePlayer ) if ( thePlayer == localPlayer ) then -- LocalPlayer bindKey ( "F1", "down", ShowGui ) --BindTheKey end end )
iPrestege Posted January 12, 2013 Posted January 12, 2013 Yeah, it should work. Yes works already, but how do I calculate the Height and Widtht?
ualexen92 Posted January 12, 2013 Posted January 12, 2013 (edited) you all are wrong complete wrong... Red dod Is the wrong probleme only player 1 must be bind if he enter is hes con 1 so probleme is when you bind a player he bind all the player on server... strange think is because is work from client script to althor player one... wrong good the player 1 don't have to bind player 2 to explain the real probleme function onClientPickupHit() bindKey("mouse2", "up", onClientEnterProp, source) end function onClientPickupLeave() unbindKey("mouse2", "up") end addEventHandler("onClientElementStreamIn", g_Root, function() if getElementData(source, "owner") then table.insert(g_streamedProps, source) -- Hook when player hit the enter-pickup and bind him addEventHandler("onClientPickupHit", source, onClientPickupHit) -- Hook when player leave the enter-pickup and unbind him (pickups use shapes, so we can hook leave event) addEventHandler("onClientPickupLeave", source, onClientPickupLeave) end end Is only happen is sourceElement is create on server side Edited January 12, 2013 by Guest
Castillo Posted January 12, 2013 Posted January 12, 2013 you all are wrong complete wrong...Red dod Is the wrong probleme only player 1 must be bind if he enter is hes con 1 so probleme is when you bind a player he bind all the player on server... strange think is because is work from client script to althor player one... wrong good the player 1 don't have to bind player 2 With Mr.Pres[T]ege's script it'll only bind the key to the one who hit it.
ualexen92 Posted January 12, 2013 Posted January 12, 2013 I explain the reason of his probleme ...to explain the real probleme function onClientPickupHit() bindKey("mouse2", "up", onClientEnterProp, source) end function onClientPickupLeave() unbindKey("mouse2", "up") end addEventHandler("onClientElementStreamIn", g_Root, function() if getElementData(source, "owner") then table.insert(g_streamedProps, source) -- Hook when player hit the enter-pickup and bind him addEventHandler("onClientPickupHit", source, onClientPickupHit) -- Hook when player leave the enter-pickup and unbind him (pickups use shapes, so we can hook leave event) addEventHandler("onClientPickupLeave", source, onClientPickupLeave) end end Is only happen is sourceElement is create on server side ps: bindKey should have a playerSource on clientside like server one
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