FuriouZ Posted March 1, 2014 Share Posted March 1, 2014 Hello! I have a problem or question how i can bind key in client to server function I tried many ways ,but still i cant figure it out so here's the code I know the problem is in bindKey function, but i can't find correct way to do it client: addEventHandler ( "onClientResourceStart", getRootElement(), function() local gTeam = getPlayerTeam(localPlayer) local StuntageTeam = getTeamFromName("Stuntage Arena") if ( gTeam and StuntageTeam and gTeam == StuntageTeam ) then bindKey(source,"R","down", (triggerServerEvent("onPlayerRequestFix", getLocalPlayer())) else unbindKey(source,"R","down", (triggerServerEvent("onPlayerRequestFix", getLocalPlayer())) end end ) server: addEvent("onPlayerRequestFix",true); addEventHandler("onPlayerRequestFix",getRootElement(), function() if (isPedInVehicle (source)) then theVehicle = getPedOccupiedVehicle(source) fixVehicle(theVehicle) else cancelEvent() end end ) Link to comment
WhoAmI Posted March 1, 2014 Share Posted March 1, 2014 function key () triggerServerEvent("onPlayerRequestFix", getLocalPlayer()) end addEventHandler ( "onClientResourceStart", getRootElement(), function() local gTeam = getPlayerTeam(localPlayer) local StuntageTeam = getTeamFromName("Stuntage Arena") if ( gTeam and StuntageTeam and gTeam == StuntageTeam ) then bindKey("R","down", key) else unbindKey(source,"R","down", key) end end ) Anyway, can't you do like this? function name () if (isPedInVehicle (source)) then theVehicle = getPedOccupiedVehicle(source) fixVehicle(theVehicle) else cancelEvent() end end ) for k,v in ipairs (getElementsByType("players")) do bindKey(v, "R", down, name) end Link to comment
FuriouZ Posted March 1, 2014 Author Share Posted March 1, 2014 There was some mistakes in first code, but thanks , got it working now Link to comment
cheez3d Posted March 1, 2014 Share Posted March 1, 2014 bindKey's third argument must be a function. If you use triggerServerEvent as the 3rd argument it will return true or false. 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