raptorr Posted September 2, 2013 Share Posted September 2, 2013 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
Fabioxps Posted September 2, 2013 Share Posted September 2, 2013 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
50p Posted September 2, 2013 Share Posted September 2, 2013 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
ixjf Posted September 3, 2013 Share Posted September 3, 2013 In fact, there's a quick workaround: addEventHandler("onClientRender", root, function() draw(YOUR_ARGUMENTS_GO_HERE) end) It will work in the same way: function draw(YOUR_PARAMETERS_GO_HERE) -- TODO end 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