Jump to content

bindKey bad argument ? :s


DarkLink

Recommended Posts

Posted

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/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

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

Posted

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?

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...