1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-12 16:56:50 +02:00
parent 9178871ecd
commit 640cdd069b
9 changed files with 583 additions and 269 deletions

View file

@ -44,6 +44,7 @@ UpdateStateValueForListeners = function(uNetId, key, value)
end
for k,v in pairs(EntitiesStates[uNetId].listeners) do
TriggerEvent("Utility:Net:UpdateStateValue", uNetId, key, value)
TriggerClientEvent("Utility:Net:UpdateStateValue", v, uNetId, key, value)
end
end
@ -161,6 +162,7 @@ RegisterNetEvent("Utility:Net:GetState", function(uNetId)
local source = source
if not EntitiesStates[uNetId] then
warn("GetState: No state found for "..uNetId)
TriggerClientEvent("Utility:Net:GetState"..uNetId, source, nil)
return
end
@ -168,6 +170,19 @@ RegisterNetEvent("Utility:Net:GetState", function(uNetId)
ListenStateUpdates(source, uNetId)
TriggerClientEvent("Utility:Net:GetState"..uNetId, source, EntitiesStates[uNetId].states)
end)
-- Single value
RegisterNetEvent("Utility:Net:GetStateValue", function(uNetId, key)
local source = source
if not EntitiesStates[uNetId] then
warn("GetStateValue: No state found for "..uNetId)
TriggerClientEvent("Utility:Net:GetStateValue"..uNetId, source, nil)
return
end
TriggerClientEvent("Utility:Net:GetStateValue"..uNetId, source, EntitiesStates[uNetId].states[key])
end)
--#endregion
-- On player disconnect remove all listeners of that player (prevent useless bandwidth usage)