-ffs-AbodyRulez Posted February 16, 2014 Share Posted February 16, 2014 I've created a function in Client side which will return true or false in some case. Is there any possible way that if a server sided function called that client function "using triggerClientEvent() most probably" to get the returned value from that client function?? For example: -- Server side local clientFunctionFlag = triggerClientEvent("blablab", source) anything like this? Link to comment
MTA Team 0xCiBeR Posted February 16, 2014 MTA Team Share Posted February 16, 2014 Well you can trigger back with triggerServerEvent Sending the values back to a handler on server-side. Link to comment
-ffs-AbodyRulez Posted February 16, 2014 Author Share Posted February 16, 2014 Could you post an example please? Link to comment
Anubhav Posted February 16, 2014 Share Posted February 16, 2014 EXAMPLE: Server: function greetingHandler ( message ) -- the predefined variable 'client' points to the player who triggered the event and should be used due to security issues outputChatBox ( "The client says: " .. message, client ) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", root, greetingHandler ) Client; function greetingCommand ( commandName ) triggerServerEvent ( "onGreeting", localPlayer, "Hello World!" ) -- localPlayer instead of root makes the client player the 'source' on the server function, eliminating the need for an additional player argument to be transferred. end addCommandHandler ( "greet", greetingCommand ) NOTE: Example is from WIKI. Link to comment
Moderators Citizen Posted February 16, 2014 Moderators Share Posted February 16, 2014 I've created a function in Client side which will return true or false in some case.Is there any possible way that if a server sided function called that client function "using triggerClientEvent() most probably" to get the returned value from that client function?? For example: -- Server side local clientFunctionFlag = triggerClientEvent("blablab", source) anything like this? No you can't do that, you have to trigger a client event that will then send back the result to another function on the server side through a triggerServerEvent. Process: server function 1 -> client function -> server function 2 Example: Server: function func1(thePlayer) triggerClientEvent(thePlayer, "needResult", root) end addCommandHandler("test", func1) addEvent("receiveResult", true) function func2( result ) outputChatBox("The result is "..tostring(result)) end addEventHandler("receiveResult", root, func2) Client: addEvent("needResult", true) function myFunc() local result = true triggerServerEvent("receiveResult", localPlayer, result) end addEventHandler("needResult", root, myFunc) Regards, Citizen 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