Jump to content

How to do this?


MetaGamer

Recommended Posts

Well my question is how to return a function value in TriggerClientEvent. For example

client.lua

  
function Example() 
    return "Hey Brown Cow!" 
end 
addEvent("TheExample", true) 
addEventHandler("TheExample", getRootElement(), Example)  
  

server.lua

  
local msg = triggerClientEvent("TheExample", getRootElement()) 
ouputChatBox(tostring(msg)) 
  

The output should be "Hey Brown Cow!" not "true".

Link to comment

-- client side:

function Example() 
    triggerServerEvent("returnData",localPlayer,"Hey Brown Cow!") 
end 
addEvent("TheExample", true) 
addEventHandler("TheExample", getRootElement(), Example) 

-- server side:

triggerClientEvent("TheExample", getRootElement()) 
  
addEvent("returnData",true) 
addEventHandler("returnData",root, 
function (msg) 
     outputChatBox(tostring(msg)) 
end) 

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