Jump to content

Calling exported functions


Drakath

Recommended Posts

Posted

If I want to call a client exported function from server-side script, do I always have to make a new server script which does triggerClientEvent in the exported function's resource? Isn't there a simpler way?

  • MTA Team
Posted

Make a resource (e.g. client-api), which has an exported function, which would triggerClientEvent it to the player and then call it (still from that client-api resource).

The "client-api" needs 3 parameters: string targetResource, string exportedFunction, table parameters

Posted

Now I have another problem. I have called a function with a text argument. In that function I addEventHandler for another function but I also need to pass this text to that function. addEventHandler does not allow custom arguments. How can I work around it?

  • MTA Team
Posted

Make that addEventHandler in your addEventHandler function (function in function) and the text will be available.

Posted

Not sure what you mean.

Here's the script:

addEvent("myEvent", true) 
function asdf(text) 
addEventHandler ( "onClientRender", root, draw ) 
end 
addEventHandler("myEvent", root, asdf) 
  
function draw (text) 
blablabla... 

How can I pass text to function draw?

Function asdf receives text from server-side script.

Posted
  
texts = {} 
addEvent("myEvent", true) 
function asdf(text) 
texts["draw"] = text 
addEventHandler ( "onClientRender", root, draw ) 
end 
addEventHandler("myEvent", root, asdf) 
  
function draw () 
        dxDrawText(texts['draw'], .......) 
  

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