Hugo_Almeidowski Posted January 23, 2019 Share Posted January 23, 2019 (edited) Nothing happens when I press W! function playerPressedKey(button, press) if button == "w" then outputChatBox("You pressed the " .. button .. " key!") end end addEventHandler("onClientKey", root, playerPressedKey) And also, if I made a table with various buttons, for example: movement = {"w", "s", "d", "a", "shift"} and substituted the "w" in the first code with movement, would it work (in the fixed version that you're please gonna tell me)? And is there anything wrong with this code? function playerPressedKey(button, press, thePlayer) if button == "w" then setPedAnimation(thePlayer) end end addEventHandler("onClientKey", root, playerPressedKey) Thanks! Edited January 23, 2019 by Hugo_Almeidowski Link to comment
Hugo_Almeidowski Posted January 23, 2019 Author Share Posted January 23, 2019 30 minutes ago, DNL291 said: Show your meta.xml. Ohhhh thaanks It was set to server. my bad! 2 minutes ago, Hugo_Almeidowski said: Ohhhh thaanks It was set to server. my bad! I changed it to client, ant it work, but now I have another problem. This function stoped working. function toggleSit(thePlayer) setPedAnimation(thePlayer, "ped", "seat_down", -1, false, false, false, true) end addCommandHandler("sit", toggleSit) So, I made two lua scripts. One for client and one for server. The one above was sent to the server script. And the one below was sent to the client script. function playerPressedKey(button, press, thePlayer) if button == "w" then setPedAnimation(thePlayer) end end addEventHandler("onClientKey", root, playerPressedKey) This one was supposed to stop the sit anim in the server script, but it doesn't. why? Link to comment
Peti Posted January 23, 2019 Share Posted January 23, 2019 (edited) function playerPressedKey(button, press) if press then if button == "w" then setPedAnimation(localPlayer) end end end addEventHandler("onClientKey", root, playerPressedKey) I think this should work. Edited January 23, 2019 by Peti 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