Swimer Posted February 20, 2022 Share Posted February 20, 2022 (edited) I need to get the result of a server function from an event handler. local plTeam = getPlayerTeam(localPlayer) if plTeam then if isPlayerInTeam(plr, plTeam) then local friend = getPlayerFriend(plr) -- Execute server-side function "getPlayerFriend(player)" text = friend.." ["..id.."]" end end Edited February 20, 2022 by Swimer Changed the code to be more clear Link to comment
βurak Posted February 20, 2022 Share Posted February 20, 2022 (edited) unfortunately you can't do this by default but you can run it on server side with "triggerServerEvent" and then pass the return value back to client side with "triggerClientEvent" Edited February 20, 2022 by Burak5312 1 Link to comment
Scripting Moderators ds1-e Posted February 20, 2022 Scripting Moderators Share Posted February 20, 2022 4 hours ago, Swimer said: I need to get the result of a server function from an event handler. local plTeam = getPlayerTeam(localPlayer) if plTeam then if isPlayerInTeam(plr, plTeam) then local friend = getPlayerFriend(plr) -- Execute server-side function "getPlayerFriend(player)" text = friend.." ["..id.."]" end end Try this, but carefully read full page. Might require some changes though. https://wiki.multitheftauto.com/wiki/CallServerFunction Link to comment
Swimer Posted February 21, 2022 Author Share Posted February 21, 2022 12 hours ago, srslyyyy said: Try this, but carefully read full page. Might require some changes though. https://wiki.multitheftauto.com/wiki/CallServerFunction can it be used for my purposes? So that the function returns a string exactly when it was called? Link to comment
Moderators IIYAMA Posted February 21, 2022 Moderators Share Posted February 21, 2022 19 minutes ago, Swimer said: So that the function returns a string exactly when it was called? My library can do that, if you really want to be able to do it that way. 1 Link to comment
Rakashy Posted February 21, 2022 Share Posted February 21, 2022 An "easy" alternative would be to use elementData to set a value and check this value on the client side with getElementData 1 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