ba0e5364bb
Moved a lot of things around, fixed a lot of bugs, made the animations and sounds public. Special thanks to CuckyDev for helping me track down all the small problems that were lingering, and for fixing a major issue with the simulation rate. There's still some stuff to fix and improve, but now this should be more portable and useable by the wider community! 🎉
Co-Authored-By: Regan Green <cuckydev@gmail.com>
58 lines
1.3 KiB
Lua
58 lines
1.3 KiB
Lua
--!strict
|
|
local Validators: { [string]: (Player, ...any) -> boolean } = {}
|
|
type Echo = () -> ()
|
|
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local Core = script.Parent.Parent
|
|
|
|
local Shared = require(Core.Shared)
|
|
local Sounds = Shared.Sounds
|
|
|
|
local lazy = Instance.new("RemoteEvent")
|
|
lazy.Parent = ReplicatedStorage
|
|
lazy.Name = "LazyNetwork"
|
|
lazy.Archivable = false
|
|
|
|
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
|
|
local rootPart = character and character.PrimaryPart
|
|
|
|
if rootPart then
|
|
local particles = rootPart:FindFirstChild("Particles")
|
|
local particle = particles and particles:FindFirstChild(name)
|
|
|
|
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)
|