2022-10-13 03:53:17 -05:00
|
|
|
--!strict
|
|
|
|
local Validators: { [string]: (Player, ...any) -> boolean } = {}
|
|
|
|
type Echo = () -> ()
|
|
|
|
|
|
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
2023-07-07 22:01:02 -05:00
|
|
|
local Core = script.Parent.Parent
|
|
|
|
|
|
|
|
local Shared = require(Core.Shared)
|
|
|
|
local Sounds = Shared.Sounds
|
2022-10-13 03:53:17 -05:00
|
|
|
|
|
|
|
local lazy = Instance.new("RemoteEvent")
|
|
|
|
lazy.Parent = ReplicatedStorage
|
|
|
|
lazy.Name = "LazyNetwork"
|
2023-07-07 22:01:02 -05:00
|
|
|
lazy.Archivable = false
|
2022-10-13 03:53:17 -05:00
|
|
|
|
|
|
|
function Validators.PlaySound(player: Player, name: string)
|
|
|
|
local sound: Instance? = Sounds[name]
|
|
|
|
|
|
|
|
if sound and sound:IsA("Sound") then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function Validators.SetParticle(player: Player, name: string, set: boolean?)
|
|
|
|
if typeof(name) ~= "string" then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
local character = player.Character
|
2023-07-07 22:01:02 -05:00
|
|
|
local rootPart = character and character.PrimaryPart
|
2022-10-13 03:53:17 -05:00
|
|
|
|
|
|
|
if rootPart then
|
|
|
|
local particles = rootPart:FindFirstChild("Particles")
|
2023-07-08 18:42:28 -05:00
|
|
|
local particle = particles and particles:FindFirstChild(name, true)
|
2022-10-13 03:53:17 -05:00
|
|
|
|
|
|
|
if particle then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function Validators.SetAngle(player: Player, angle: Vector3int16)
|
|
|
|
return typeof(angle) == "Vector3int16"
|
|
|
|
end
|
|
|
|
|
|
|
|
local function onNetworkReceive(player: Player, cmd: string, ...)
|
|
|
|
local validate = Validators[cmd]
|
|
|
|
|
|
|
|
if validate and validate(player, ...) then
|
|
|
|
lazy:FireAllClients(player, cmd, ...)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
lazy.OnServerEvent:Connect(onNetworkReceive)
|