DarkLink Posted June 12, 2011 Share Posted June 12, 2011 Guys i am trying to use a bind key to turn on and off lights of vehicle.. but it says always on console : bad argument @ 'bindKey ' i have this code for bindKey : bindKey ( keyPresser, "l", "down", VehicleLights ) can u guys explain me what i am doing wrong ? thanks. Edit: VehicleLights is my other function that turn on and off lights . Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 you can't just put that, you have to put: addEventHandler ( "onPlayerJoin", getRootElement(), function() bindKey (keyPresser, "l", "down", VehicleLights ) end) addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), function() for index, player in pairs(getElementsByType("player")) do unbindKey (keyPresser, "l", "down", VehicleLights ) end end) So when the player joins they could press the button. Link to comment
JR10 Posted June 12, 2011 Share Posted June 12, 2011 wrong, addEventHandler ( "onPlayerJoin", getRootElement(), function() bindKey (keyPresser, "l", "down", VehicleLights ) end) addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), function() for index, player in pairs(getElementsByType("player")) do unbindKey (keyPresser, "l", "down", VehicleLights ) end end) keyPresser is not defined, you should addEventHandler ( "onPlayerJoin", getRootElement(), function() bindKey (source, "l", "down", VehicleLights ) end) addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), function() for index, player in pairs(getElementsByType("player")) do unbindKey (player, "l", "down", VehicleLights ) end end) Link to comment
CowTurbo Posted June 12, 2011 Share Posted June 12, 2011 keyPresser is player argument, was you know that ? Try to do add something like function onPlayerJoinBind () bindKey ( source, "l", "down", VehicleLights ) end addEventHandler ( "onPlayerJoin", getRootElement(), onPlayerJoinBind ) function onResourceStartBind () for i,v in ipairs ( getElementsByType("player")) do bindKey ( v, "l", "down", VehicleLights ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStartBind ) EDIT: someone was before me.. EDIT2: Why you guys unbinding key on start? Link to comment
DarkLink Posted June 12, 2011 Author Share Posted June 12, 2011 thanks for ur reply jay, but i cant understand the second part of the handler... when u unbindKey? why do i need to unbind..? thanks Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 because if the player is not in the vehicle and he presses it then it doesn't trigger anything. Link to comment
DarkLink Posted June 12, 2011 Author Share Posted June 12, 2011 but jay why the handler when resource start? there is no problem if they press the key and are not in vehicle.. because the function only does something if player is on vehicle Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 oooh nevermind, I misread then, anyways, your welcome Link to comment
DarkLink Posted June 12, 2011 Author Share Posted June 12, 2011 I already made it to work, thanks all that reply No problem jay bb Link to comment
karlis Posted June 13, 2011 Share Posted June 13, 2011 "l" is improper keybind, use "L" Link to comment
Deagle Posted June 13, 2011 Share Posted June 13, 2011 Are you sure about that karlis ? I had a script for lighting up the headlights and the key from the script was "l" and it was working. Link to comment
karlis Posted June 13, 2011 Share Posted June 13, 2011 Are you sure about that karlis ?I had a script for lighting up the headlights and the key from the script was "l" and it was working. im sure lowercase doesn't work with /bind. afaik bindKey is same as /bind Link to comment
Deagle Posted June 13, 2011 Share Posted June 13, 2011 Ehm thats really lol ... Lowercase letters are working with /bind , for example /bind m say Visit my site! 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