Karoffe Posted August 25, 2014 Share Posted August 25, 2014 function justatest(text) outputChatBox(text) end addEventHandler( "onClientResourceStart", getRootElement( ), justatest("Yes it is a test!!")) I want to call a function with it arguments in a event handler or a command.. actually it works, it outputs "Yes it is a test!!" but with an error "bad argument @addEventHandler [expected function at argument 3, got none]" is it possible to call the function with the argument without the error to happen ? Link to comment
Et-win Posted August 25, 2014 Share Posted August 25, 2014 addEventHandler( "onClientResourceStart", getRootElement( ), (function() justatest("Yes it is a test!!")end)) Link to comment
xXMADEXx Posted August 25, 2014 Share Posted August 25, 2014 You could also do something like this, using the eventName pre-defined variable. function justatest ( ) local text; if ( eventName == "onClientResourceStart" ) then text = "This is just a test!"; end if ( text ) then outputChatBox ( tostring ( text ) ) end end addEventHandler('onClientResourceStart', resourceRoot, justatest ) Link to comment
Karoffe Posted August 26, 2014 Author Share Posted August 26, 2014 (edited) Thanks again. but what if i want to remove the event handler ? Edited August 27, 2014 by Guest Link to comment
Karoffe Posted August 27, 2014 Author Share Posted August 27, 2014 Edit: Solved.., Thanks Et-Win and madex 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