Jump to content

Pass arguments thought eventHandler


raptorr

Recommended Posts

Hello,

Is there any way to pass arguments to the function through eventHandler?

This it what I mean:

function example(arg1, arg2) -- how to pass these arguments 
    --some function  
end 
addEventHandler("onClientRender", getRootElement(), example) 

Thanks in advance.

Link to comment
Hello,

Is there any way to pass arguments to the function through eventHandler?

This it what I mean:

function example(arg1, arg2) -- how to pass these arguments 
    --some function  
end 
addEventHandler("onClientRender", getRootElement(), example) 

Thanks in advance.

EXEMPLE

  
local gotArea = false 
local area = { } 
local theArea = { } 
  
local gangZones = { 
    ['Idlewood'] = { lx = '2082.80542', by = '-1680.55737', x = '100', y = '100', r = '0', g = '0', b = '0', a = '180', visible = root }; 
} 
  
local areas = { 
    ['Idlewood'] = { x = '2082.80542', y = '-1680.55737', width = '100', height = '100', visible = root }; 
} 
  
addEventHandler ( 'onResourceStart', resourceRoot, 
    function ( ) 
        for _, zone in pairs ( gangZones ) do 
            area[_] = createRadarArea ( zone.lx, zone.by, zone.x, zone.y, zone.r, zone.g, zone.b, zone.a, zone.visible ); 
        end 
  
        for _, area in pairs ( areas ) do 
            theArea[_] = createColRectangle ( area.x, area.y, area.width, area.height ); 
            addEventHandler ( 'onColShapeHit', theArea[_], onHitGangZone ); 
            addEventHandler ( 'onColShapeLeave', theArea[_], onLeaveGangZone ); 
        end 
    end 
) 
Link to comment
Hello,

Is there any way to pass arguments to the function through eventHandler?

This it what I mean:

function example(arg1, arg2) -- how to pass these arguments 
    --some function  
end 
addEventHandler("onClientRender", getRootElement(), example) 

Thanks in advance.

The MTA events have their own parameters and you can't add or change them. If you want to pass args to the handlers you have to create your own event. Then you can pass any arguments in triggerEvent, triggerClientEvent or triggerServerEvent.

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