enzoDs Posted September 1, 2019 Share Posted September 1, 2019 I have a problem making a client-side function return a server-side value to me, try this and triggers, but of course, the time it takes to get the trigger does the return returns nill (Sorry for the bad english) Spoiler Clientside: function getEngineVehData (id, parte) triggerServerEvent ( "onClientPreGetVehData", resourceRoot, getPlayerName(getLocalPlayer()), tonumber(id), parte ) function greetingHandler ( parte ) va = getElementData(getLocalPlayer(), "Dato") end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", localPlayer, greetingHandler ) return va end outputChatBox(getEngineVehData (1, "dsa")) Spoiler Serverside: function preGetEngineVehData (nombre, id, parte) triggerClientEvent ("onGreeting", getPlayerFromName(nombre), getEngineVehData (parte) ) setElementData(getPlayerFromName(nombre), "Dato", dato) end addEvent( "onClientPreGetVehData", true ) addEventHandler( "onClientPreGetVehData", resourceRoot, preGetEngineVehData ) Link to comment
Moderators IIYAMA Posted September 1, 2019 Moderators Share Posted September 1, 2019 @enzoDs You can't return later without coroutine which is your last resort, how about you solve your issue with a callback? async functionalities are very complex to build, as you do have to mind delays, process flow and cleaning of used code. This enchantment allows you to use callbacks: You can also use the code as inspiration for your own. Link to comment
enzoDs Posted September 2, 2019 Author Share Posted September 2, 2019 Excuse me, I still can't make that function of getting on the client side, could you help me more please? I would greatly appreciate it Link to comment
Moderators IIYAMA Posted September 2, 2019 Moderators Share Posted September 2, 2019 4 hours ago, enzoDs said: Excuse me, I still can't make that function of getting on the client side, could you help me more please? I would greatly appreciate it After the installation you should be able to run this. callBack should be a function as 3e argument where the end-result goes to. function getEngineVehData (id, parte, callBack) callServer("preGetEngineVehData", getPlayerName(localPlayer), id, parte, callBack) return true end function preGetEngineVehData (nombre, id, parte) --... return "something" 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