Jump to content

How to give arguments to function on handler?


Recommended Posts

Posted

Is possible to pass arguments to the function that is called from the handler??

I mean..

I have this handler:

  
function() 
  
local x,y = 10,50 
addEventHandler("onClientRender", getRootElement(), doSomething) 
  
end 
  
function doSomething() 
  -- HOW can I have access here to that arguments above? the x and the y ? thanks alot in advance... 
end 
  
  

EDIT: I tryed this but doesnt work !

  
addEventHandler("onClientRender", getRootElement(), showInfoAboutTimes(x,y)) 
  

Gives me this error :

[2012-07-07 20:43:28] WARNING: bp\client_testbar.lua:11: Bad argument @ 'addEventHandler' [Expected function at argument 3, got none]

Thanks again

Posted

What do you mean? Do you mean this?

  
function doSomething() 
     outputChatBox("X: " .. x .. " Y: " .. y) 
end 
  

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted

No, is not.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

make it global, without local

  
function() 
  
x,y = 10,50 
addEventHandler("onClientRender", getRootElement(), doSomething) 
  
end 
  
function doSomething() 
  -- HOW can I have access here to that arguments above? the x and the y ? thanks alot in advance... 
end 
  
  

CiTLh.png
Posted
addEventHandler( 'onClientRender', root, function( ) doSomething( x, y ); end ); 

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

No problem :)

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

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...