--the thing is, u need to implement ur own process collection.
it can just be a
library, or set of libraries
--in mine, a collection is an interface that wraps around nameless libraries with
uniquely named fields, that can run some validation checks on each member of the
library
--lets me split up data across multiple files while keeping them consistent
--service
local service = {}
--core services
local global = _G.import "global"
local event = _G.import "event"
--util
local dictUtil = _G.import "dictUtil"
--data
local processCollection = _G.import "processCollection"
--roblox services
local runService = game:GetService("RunService")
local httpService = game:GetService("HttpService")
--private functions
local function processShared(player, eventName, playerSave, playerSession, ...)
local sharedProcess = processCollection:get(eventName)
if not sharedProcess then warn('No Shared process named ' .. eventName) return
end
--response
local response = {sharedProcess(player, playerSave, playerSession, ...)}
local status = [Link](response, 1)
return status, response
end
--setup network
if runService:IsServer() then
function [Link](eventName, func)
[Link](eventName, function(player, ...)
--data
local playerSave = [Link]('playerSave',player)
local playerSession = [Link]('playerSession',player)
local args = {...}
--processShared
local status, response = processShared(player, eventName, playerSave,
playerSession, unpack(args))
if status == true and func then
return {func(unpack(response))}
else
return {status}
end
end, {Returning=true})
end
else
function [Link](eventName, clientFunc, errorFunc, serverResponse,
getSharedResponse, makeRequestId)
return function(...)
--ref n
local player = [Link]
local playerSave = [Link]('playerSave',player)
local playerSession = [Link]('playerSession',player)
--processShared
local args = {...}
if makeRequestId then [Link](args, httpService:GenerateGUID())
end
--
local status, response = processShared(player, eventName, playerSave,
playerSession, ...)
if status == true then
[Link](function()
local serverResponsePack = [Link](eventName,
unpack([Link](args, getSharedResponse and response or {}))) or {}
if serverResponse then
serverResponse(unpack(serverResponsePack))
end
end)
if clientFunc then clientFunc(unpack(response)) end
elseif status ~= nil and errorFunc then
errorFunc(status)
end
return status
end
end
end
return service
--this is just the sync library for u to copy ok