Jump to content

Executing Server Functions on the Client Side with a Return Value


Swimer

Recommended Posts

Posted (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 by Swimer
Changed the code to be more clear
Posted (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 by Burak5312
  • Like 1
Posted
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

  • Moderators
Posted
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.

 

  • Like 1

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