DarkLink Posted June 12, 2011 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 . Borderpatrol Project Gamemode - Under Development (80%)
Jaysds1 Posted June 12, 2011 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. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted June 12, 2011 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) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
CowTurbo Posted June 12, 2011 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? http://mrteamgaming.eu
DarkLink Posted June 12, 2011 Author 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 Borderpatrol Project Gamemode - Under Development (80%)
Jaysds1 Posted June 12, 2011 Posted June 12, 2011 because if the player is not in the vehicle and he presses it then it doesn't trigger anything. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
DarkLink Posted June 12, 2011 Author 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 Borderpatrol Project Gamemode - Under Development (80%)
Jaysds1 Posted June 12, 2011 Posted June 12, 2011 oooh nevermind, I misread then, anyways, your welcome My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
DarkLink Posted June 12, 2011 Author Posted June 12, 2011 I already made it to work, thanks all that reply No problem jay bb Borderpatrol Project Gamemode - Under Development (80%)
karlis Posted June 13, 2011 Posted June 13, 2011 "l" is improper keybind, use "L" [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Deagle Posted June 13, 2011 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.
karlis Posted June 13, 2011 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 [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Deagle Posted June 13, 2011 Posted June 13, 2011 Ehm thats really lol ... Lowercase letters are working with /bind , for example /bind m say Visit my site!
karlis Posted June 13, 2011 Posted June 13, 2011 o.0 never worked for me [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
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