Added extra syncing functions

This commit is contained in:
Nass committed 2025-10-10 21:58:21 -07:00
1 parent 937dc8940a
commit ee59a89cf2
3 files changed
+16 -4

No files matched your search

+10 -3
View File
@@ -51,6 +51,12 @@ end
local syncedScales = {} local syncedScales = {}
RegisterNetEvent('nass_pedscaler:syncCurrentScaling', function(players)
for k, v in pairs(players) do
TriggerEvent('nass_pedscaler:syncScale', tonumber(k), v)
end
end)
RegisterNetEvent('nass_pedscaler:syncScale', function(src, scale) RegisterNetEvent('nass_pedscaler:syncScale', function(src, scale)
if syncedScales[tostring(src)] ~= nil then if syncedScales[tostring(src)] ~= nil then
syncedScales[tostring(src)] = nil syncedScales[tostring(src)] = nil
@@ -128,6 +134,10 @@ RegisterNUICallback('get_config', function(data, cb)
cb('ok') cb('ok')
end) end)
RegisterNUICallback('getLocale', function(data, cb)
cb(Config.locale)
end)
RegisterNetEvent('nass_pedscaler:openMenu', function() RegisterNetEvent('nass_pedscaler:openMenu', function()
SetNuiFocus(true, true) SetNuiFocus(true, true)
SendNUIMessage({ SendNUIMessage({
@@ -136,6 +146,3 @@ RegisterNetEvent('nass_pedscaler:openMenu', function()
}) })
end) end)
RegisterNUICallback('getLocale', function(data, cb)
cb(Config.locale)
end)
+3
View File
@@ -1,10 +1,13 @@
playerScaling = json.decode(LoadResourceFile(GetCurrentResourceName(), "./playerScaling.json")) or {} playerScaling = json.decode(LoadResourceFile(GetCurrentResourceName(), "./playerScaling.json")) or {}
function onPlayerLoaded(identifier, source) function onPlayerLoaded(identifier, source)
TriggerClientEvent('nass_pedscaler:syncCurrentScaling', source, scaledPlayers)
local playerscale = playerScaling[identifier] local playerscale = playerScaling[identifier]
if playerscale and playerscale ~= 1.0 then if playerscale and playerscale ~= 1.0 then
TriggerClientEvent('nass_pedscaler:syncScale', -1, source, playerscale) TriggerClientEvent('nass_pedscaler:syncScale', -1, source, playerscale)
end end
end end
AddEventHandler('onResourceStart', function(resourceName) AddEventHandler('onResourceStart', function(resourceName)
+3 -1
View File
@@ -13,10 +13,11 @@
Please support the development of this script by joining our discord server. Please support the development of this script by joining our discord server.
]] ]]
scaledPlayers = {}
RegisterNetEvent('nass_pedscaler:syncScale', function(scale) RegisterNetEvent('nass_pedscaler:syncScale', function(scale)
local src = source local src = source
playerScaling[getPlayerIdentifier(src)] = scale playerScaling[getPlayerIdentifier(src)] = scale
scaledPlayers[tostring(src)] = scale
TriggerClientEvent('nass_pedscaler:syncScale', -1, src, scale) TriggerClientEvent('nass_pedscaler:syncScale', -1, src, scale)
end) end)
@@ -35,6 +36,7 @@ if Config.commands.resetScale.enabled then
local id = tonumber(args[1]) or source local id = tonumber(args[1]) or source
if hasPermission(source, id == source and "resetSelf" or "resetOther") then if hasPermission(source, id == source and "resetSelf" or "resetOther") then
playerScaling[getPlayerIdentifier(id)] = nil playerScaling[getPlayerIdentifier(id)] = nil
scaledPlayers[tostring(id)] = nil
TriggerClientEvent('nass_pedscaler:syncScale', -1, id, nil) TriggerClientEvent('nass_pedscaler:syncScale', -1, id, nil)
end end
end, false) end, false)