Fantanic Posted March 18, 2014 Share Posted March 18, 2014 Hello , I would like to know if its posible to bind a key on playerlogin and unbind the key on playerlogout (i got some problems with login panel wich is ; if i press M for example M panel shows up bindKey("M", "down", showPanel) Greetings , Jonas Link to comment
cheez3d Posted March 18, 2014 Share Posted March 18, 2014 "onPlayerLogin" "onPlayerLogout" Link to comment
Fantanic Posted March 18, 2014 Author Share Posted March 18, 2014 Do i have to make a function or not Link to comment
cheez3d Posted March 18, 2014 Share Posted March 18, 2014 Of course you do have to make a function. Link to comment
Fantanic Posted March 18, 2014 Author Share Posted March 18, 2014 function bind() bindKey("M", "down", showPanel) end addEventHandler("onPlayerLogin",bind) function unbind() unBindKey("M", "down", showPanel) end addEventHandler("onPlayerQuit",unbind) ? Link to comment
Itachi Posted March 18, 2014 Share Posted March 18, 2014 [lua]function bind() bindKey("M", "down", showPanel) end addEventHandler("onPlayerLogin",bind) function unbind() unBindKey("M", "down", showPanel) end addEventHandler("onPlayerQuit",unbind) [/lua] ? function bind() bindKey("M", "down", showPanel) end addEventHandler("onPlayerLogin",bind) function unbind() unbindKey("M", "down", showPanel) end addEventHandler("onPlayerLogout",unbind) [/lua] Link to comment
DNL291 Posted March 18, 2014 Share Posted March 18, 2014 Use bindkey("M", "down", showPanel) when player log in and unbindKey("M", "down", showPanel) when the player log out. If bindkey is on the client-side, you will need to use triggerClientEvent. Link to comment
Fantanic Posted March 18, 2014 Author Share Posted March 18, 2014 What do u mean exactly with the triggerClientEvent , like this ; function unbind1() triggerClientEvent end addEventHandler("onPlayerLogout",unbind1) Link to comment
cheez3d Posted March 18, 2014 Share Posted March 18, 2014 -- serverside code local showPanel = function() triggerClientEvent("onPlayerRequestPanel",player) end addEventHandler("onPlayerLogin",root,function() bindKey(source,"m","down",showPanel,source) end) addEventHandler("onPlayerLogout",root,function() unbindKey(source,"m","down",showPanel) end) -- clientside code addEvent("onPlayerRequestPanel",true) addEventHandler("onPlayerRequestPanel",resourceRoot,function() -- your panel function here end) Link to comment
DNL291 Posted March 18, 2014 Share Posted March 18, 2014 What do u mean exactly with the triggerClientEvent , like this ; function unbind1() triggerClientEvent end addEventHandler("onPlayerLogout",unbind1) Like this: --Server addEventHandler( "onPlayerLogin", function() triggerClientEvent(source, "doEnablePanel", source) end ) addEventHandler( "onPlayerLogout", function() triggerClientEvent(source, "doDisablePanel", source) end ) --Client addEvent("doDisablePanel", true) addEvent("doEnablePanel", true) function disablePanel() unbindKey("M", "down", showPanel) end addEventHandler("doDisablePanel", root, disablePanel) function enablePanel() bindKey("M", "down", showPanel) end addEventHandler("doEnablePanel", root, enablePanel) The client must be in the same script that the panel is in. Link to comment
Fantanic Posted March 18, 2014 Author Share Posted March 18, 2014 bad argument expected element at argument 2 got function (server side) Link to comment
JR10 Posted March 18, 2014 Share Posted March 18, 2014 You forgot about the baseElement in addEventHandler. --Server addEventHandler( "onPlayerLogin", root, function() triggerClientEvent(source, "doEnablePanel", source) end ) addEventHandler( "onPlayerLogout", root, function() triggerClientEvent(source, "doDisablePanel", source) end ) Link to comment
DNL291 Posted March 18, 2014 Share Posted March 18, 2014 You forgot about the baseElement in addEventHandler. --Server addEventHandler( "onPlayerLogin", root, function() triggerClientEvent(source, "doEnablePanel", source) end ) addEventHandler( "onPlayerLogout", root, function() triggerClientEvent(source, "doDisablePanel", source) end ) Oh, my bad. 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