ed
This commit is contained in:
parent
510e3ffcf2
commit
f43cf424cf
305 changed files with 34683 additions and 0 deletions
|
@ -0,0 +1,65 @@
|
|||
Batch = Batch or {}
|
||||
Batch.Event = Batch.Event or {}
|
||||
Batch.Event.Queued = Batch.Event.Queued or {}
|
||||
Batch.Event.IsQueued = Batch.Event.IsQueued or false
|
||||
|
||||
local SERVER = IsDuplicityVersion()
|
||||
|
||||
-- could do a callback from client to server back to client with a time stamp. Use that timestamp to generate some random string/number and use that fo
|
||||
-- this event name. Would help by masking from exploits. Thinking about making a module out of it
|
||||
|
||||
--- This is used to batch single events together to reduce network strain
|
||||
---
|
||||
if SERVER then
|
||||
function Batch.Event.Queue(src, event, ...)
|
||||
if src == -1 then
|
||||
src = GetPlayers()
|
||||
for k, v in pairs(src) do
|
||||
local strSrc = tostring(v)
|
||||
Batch.Event.Queued[strSrc] = Batch.Event.Queued[strSrc] or {}
|
||||
table.insert(Batch.Event.Queued[strSrc], {
|
||||
src = v,
|
||||
event = event,
|
||||
args = {...}
|
||||
})
|
||||
end
|
||||
else
|
||||
local strSrc = tostring(src)
|
||||
Batch.Event.Queued[strSrc] = Batch.Event.Queued[strSrc] or {}
|
||||
table.insert(Batch.Event.Queued[strSrc], {
|
||||
src = src,
|
||||
event = event,
|
||||
args = {...}
|
||||
})
|
||||
end
|
||||
|
||||
if Batch.Event.IsQueued then return end
|
||||
Batch.Event.IsQueued = true
|
||||
SetTimeout(100, function()
|
||||
for k, v in pairs(Batch.Event.Queued) do
|
||||
TriggerClientEvent('community_bridge:client:BatchEvents', v.src, v)
|
||||
end
|
||||
Batch.Event.IsQueued = false
|
||||
Batch.Event.Queued = {}
|
||||
end)
|
||||
end
|
||||
return Batch
|
||||
else
|
||||
|
||||
Batch.Event.Fire = function(array)
|
||||
local playerSrc = PlayerId()
|
||||
for k, v in pairs(array) do
|
||||
if v.src == playerSrc then
|
||||
local event = v.event
|
||||
local args = v.args
|
||||
TriggerEvent(event, table.unpack(args))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RegisterNetEvent('community_bridge:client:BatchEvents', function(array)
|
||||
Batch.Event.Fire(array)
|
||||
end)
|
||||
|
||||
return Batch
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
-- Test file for FiveM Community Bridge Extension
|
||||
-- Try the following to test extension features:
|
||||
|
||||
-- 1. Type "CommunityBridge." (with the dot) and you should see auto-completion
|
||||
-- CommunityBridge.
|
||||
|
||||
-- 2. Type "AddEventHandler" and see parameter hints
|
||||
-- AddEventHandler(
|
||||
|
||||
-- 3. Hover over these function names to see documentation:
|
||||
-- GetPlayerData, SetPlayerData, TriggerEvent, RegisterNetEvent
|
||||
|
||||
-- 4. Try these snippets (type the word and press Tab):
|
||||
-- event
|
||||
-- thread
|
||||
-- command
|
||||
-- cbget
|
||||
-- cbset
|
||||
|
||||
-- 5. Test signature help - start typing a function call:
|
||||
-- CommunityBridge.GetPlayerData(
|
||||
|
||||
print("Extension test file loaded")
|
Loading…
Add table
Add a link
Reference in a new issue