SHARE
TWEET

Server RPCs 101

NSKuber May 28th, 2020 841 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --How-to for SP-friendly server-sided RPCs
  2.  
  3. --The function which contains actual code
  4. local MyFunctionToExecuteOnAllMachines = function(arg1,arg2)
  5.     --code
  6. end
  7.  
  8. if not worldInfo:IsSinglePlayer() then
  9.     worldGlobals.CreateRPC("server","reliable","MyFunctionHost",function(arg1,arg2)
  10.         MyFunctionToExecuteOnAllMachines(arg1,arg2)
  11.     end)
  12. else
  13.     worldGlobals.MyFunctionHost = MyFunctionToExecuteOnAllMachines
  14. end
  15.  
  16. --And then you can just call "worldGlobals.MyFunctionHost" when needed and don't care for SP/MP checks
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top