Advertisement
NSKuber

Server RPCs 101

May 28th, 2020
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement