mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 07:00:03 +00:00
pre v1.0.14
This commit is contained in:
parent
d065bc2e50
commit
d8526c7e25
5 changed files with 52 additions and 9 deletions
BIN
Warp.rbxm
BIN
Warp.rbxm
Binary file not shown.
|
@ -49,12 +49,13 @@ local ReliableEvent = Event.Reliable
|
|||
local UnreliableEvent = Event.Unreliable
|
||||
local RequestEvent = Event.Request
|
||||
|
||||
RateLimit.Protect()
|
||||
|
||||
local function initializeEachPlayer(player: Player)
|
||||
if not player then return end
|
||||
if not queueOut[player] then
|
||||
queueOut[player] = {}
|
||||
end
|
||||
|
||||
for Identifier: string in registeredIdentifier do
|
||||
if not player then break end
|
||||
if not queueOut[player][Identifier] then
|
||||
|
|
|
@ -4,21 +4,51 @@ local RateLimit = {}
|
|||
|
||||
local RunService = game:GetService("RunService")
|
||||
local Assert = require(script.Parent.Assert)
|
||||
local Event = require(script.Parent.Parent.Event).Reliable
|
||||
local Events = require(script.Parent.Parent.Event)
|
||||
local Reliable, Unreliable, Request = Events.Reliable, Events.Unreliable, Events.Request
|
||||
local Signal = require(script.Parent.Parent.Signal)("Warp_OnSpamSignal")
|
||||
|
||||
local map, activity, meta = {}, {}, {}
|
||||
setmetatable(meta , {
|
||||
__index = map,
|
||||
__newindex = function(self, key, value)
|
||||
if not activity[key] then
|
||||
activity[key] = os.clock()
|
||||
end
|
||||
if (os.clock()-activity[key]) >= 1 then
|
||||
activity[key] = os.clock()
|
||||
map[key] = 1
|
||||
return
|
||||
end
|
||||
if value >= 1e1 then -- 100
|
||||
Signal:Fire(key)
|
||||
return
|
||||
end
|
||||
map[key] = value
|
||||
end,
|
||||
})
|
||||
|
||||
local function onReceived(player: Player)
|
||||
if not meta[player] then
|
||||
meta[player] = 1
|
||||
return
|
||||
end
|
||||
meta[player] += 1
|
||||
end
|
||||
|
||||
function RateLimit.create(Identifier: string, entrance: number?, interval: number?)
|
||||
Assert(typeof(Identifier) == "string", "Identifier must a string type.")
|
||||
if RunService:IsServer() then
|
||||
Assert(typeof(entrance) == "number", "entrance must a number type.")
|
||||
Assert(entrance :: number > 0, "entrance must above 0.")
|
||||
Event:SetAttribute(Identifier.."_ent", entrance)
|
||||
Event:SetAttribute(Identifier.."_int", interval)
|
||||
Reliable:SetAttribute(Identifier.."_ent", entrance)
|
||||
Reliable:SetAttribute(Identifier.."_int", interval)
|
||||
else
|
||||
while (not Event:GetAttribute(Identifier.."_ent")) or (not Event:GetAttribute(Identifier.."_int")) do
|
||||
while (not Reliable:GetAttribute(Identifier.."_ent")) or (not Reliable:GetAttribute(Identifier.."_int")) do
|
||||
task.wait(0.1)
|
||||
end
|
||||
entrance = tonumber(Event:GetAttribute(Identifier.."_ent"))
|
||||
interval = tonumber(Event:GetAttribute(Identifier.."_int"))
|
||||
entrance = tonumber(Reliable:GetAttribute(Identifier.."_ent"))
|
||||
interval = tonumber(Reliable:GetAttribute(Identifier.."_int"))
|
||||
end
|
||||
local entrances: number = 0
|
||||
return function(incoming: number?): boolean
|
||||
|
@ -32,4 +62,14 @@ function RateLimit.create(Identifier: string, entrance: number?, interval: numbe
|
|||
end
|
||||
end
|
||||
|
||||
function RateLimit.Protect()
|
||||
if not RunService:IsServer() or Reliable:GetAttribute("Protected") then return end
|
||||
Reliable:SetAttribute("Protected", true)
|
||||
Unreliable:SetAttribute("Protected", true)
|
||||
Request:SetAttribute("Protected", true)
|
||||
Reliable.OnServerEvent:Connect(onReceived)
|
||||
Unreliable.OnServerEvent:Connect(onReceived)
|
||||
Request.OnServerEvent:Connect(onReceived)
|
||||
end
|
||||
|
||||
return RateLimit :: typeof(RateLimit)
|
|
@ -1,5 +1,5 @@
|
|||
-- Warp Library (@Eternity_Devs)
|
||||
-- version 1.0.13
|
||||
-- version 1.0.14
|
||||
--!strict
|
||||
--!native
|
||||
--!optimize 2
|
||||
|
@ -11,6 +11,8 @@ return {
|
|||
fromServerArray = Index.fromServerArray,
|
||||
fromClientArray = Index.fromClientArray,
|
||||
|
||||
OnSpamSignal = Index.OnSpamSignal,
|
||||
|
||||
Signal = Index.Signal,
|
||||
fromSignalArray = Index.fromSignalArray,
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "imezx/warp"
|
||||
version = "1.0.13"
|
||||
version = "1.0.14"
|
||||
registry = "https://github.com/UpliftGames/wally-index"
|
||||
realm = "shared"
|
||||
license = "MIT"
|
||||
|
|
Loading…
Reference in a new issue