Jump to content

Is this possible ?


Karoffe

Recommended Posts

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

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

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