Jump to content

[Help] Passing value from functions.


hank

Recommended Posts

How to pass parameters?

I have this code below:

passar = function(aa,bb) 
  
    local cc = aa 
    local dd = bb 
  
    return cc,dd 
end 
  
recebe = function() --I want to receive the value cc, dd function "pass". Here. How? 
     
end 
  

Link to comment

I'm not sure if I understood you, do you mean this?

passar = function ( aa, bb ) 
  
    local cc = aa 
    local dd = bb 
  
    return cc, dd 
end 
  
recebe = function ( ) --I want to receive the value cc, dd function "pass". Here. How? 
   local cc, dd = passar ( ) 
   print ( cc ..": ".. dd ) 
end 

Link to comment

Your code worked.

Something else.

pegarVar = function(aa,bb) 
      
        local cc = aa 
    local dd = bb 
  
    return cc, dd 
end 
addEvent("enviarVar",true) 
addEventHandler("enviarVar",getRootElement(),pegarVar) 
  
recebeVar = function() 
  
end 

Code client receives variables from the code server.

Now I want to pass the variables to other functions. (recebeVar receives variables cc,dd) How?

Link to comment
local cc, dd 
  
pegarVar = function(aa,bb) 
    cc = aa 
    dd = bb 
end 
addEvent("enviarVar",true) 
addEventHandler("enviarVar",getRootElement(),pegarVar) 
  
recebeVar = function ( ) 
end 

Now your variables will be global, so you can use them outside "pegarVar" function.

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