Added Database
This commit is contained in:
1 parent
477f3d51f0
commit
5c0267981d
9 files changed
+107
-51
No files matched your search
@@ -0,0 +1,23 @@
|
||||
playerScaling = json.decode(LoadResourceFile(GetCurrentResourceName(), "./playerScaling.json")) or {}
|
||||
|
||||
function onPlayerLoaded(identifier, source)
|
||||
local playerscale = playerScaling[identifier]
|
||||
if playerscale and playerscale ~= 1.0 then
|
||||
TriggerClientEvent('nass_pedscaler:syncScale', -1, source, playerscale)
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('onResourceStart', function(resourceName)
|
||||
if (GetCurrentResourceName() ~= resourceName) then return end
|
||||
Wait(1000)
|
||||
for _, player in pairs(GetPlayers()) do
|
||||
onPlayerLoaded(getPlayerIdentifier(player), player)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
AddEventHandler('onResourceStop', function(resourceName)
|
||||
if (GetCurrentResourceName() ~= resourceName) then return end
|
||||
|
||||
SaveResourceFile(GetCurrentResourceName(), "playerScaling.json", json.encode(playerScaling), -1)
|
||||
end)
|
||||
@@ -0,0 +1,11 @@
|
||||
if GetResourceState('es_extended') ~= 'started' then return end
|
||||
ESX = exports["es_extended"]:getSharedObject()
|
||||
|
||||
function getPlayerIdentifier(source)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
return xPlayer.identifier
|
||||
end
|
||||
|
||||
AddEventHandler('esx:playerLoaded', function(playerId, xPlayer, isNew)
|
||||
onPlayerLoaded(xPlayer.identifier, playerId)
|
||||
end)
|
||||
@@ -0,0 +1,11 @@
|
||||
if GetResourceState('qb-core') ~= 'started' then return end
|
||||
QBCore = exports["qb-core"]:GetCoreObject()
|
||||
|
||||
function getPlayerIdentifier(source)
|
||||
local xPlayer = QBCore.Functions.GetPlayer(source)
|
||||
return xPlayer.PlayerData.citizenid
|
||||
end
|
||||
|
||||
AddEventHandler('QBCore:Server:PlayerLoaded', function(Player)
|
||||
onPlayerLoaded(Player.PlayerData.citizenid, Player.PlayerData.source)
|
||||
end)
|
||||
@@ -0,0 +1,11 @@
|
||||
if GetResourceState('qb-core') == 'started' then return end
|
||||
if GetResourceState('es_extended') == 'started' then return end
|
||||
|
||||
function getPlayerIdentifier(source)
|
||||
return GetPlayerIdentifierByType(source, 'license')
|
||||
end
|
||||
|
||||
AddEventHandler('playerJoining', function(playerId)
|
||||
local identifier = getPlayerIdentifier(playerId)
|
||||
onPlayerLoaded(identifier, playerId)
|
||||
end)
|
||||
@@ -1,5 +1,23 @@
|
||||
--[[
|
||||
https://github.com/alp1x/um-ped-scale
|
||||
Main scaling function based off of this script
|
||||
|
||||
███╗ ██╗ █████╗ ███████╗███████╗ ██████╗ ███████╗██████╗ ███████╗ ██████╗ █████╗ ██╗ ███████╗██████╗
|
||||
████╗ ██║██╔══██╗██╔════╝██╔════╝ ██╔══██╗██╔════╝██╔══██╗██╔════╝██╔════╝██╔══██╗██║ ██╔════╝██╔══██╗
|
||||
██╔██╗ ██║███████║███████╗███████╗ ██████╔╝█████╗ ██║ ██║███████╗██║ ███████║██║ █████╗ ██████╔╝
|
||||
██║╚██╗██║██╔══██║╚════██║╚════██║ ██╔═══╝ ██╔══╝ ██║ ██║╚════██║██║ ██╔══██║██║ ██╔══╝ ██╔══██╗
|
||||
██║ ╚████║██║ ██║███████║███████║███████╗██║ ███████╗██████╔╝███████║╚██████╗██║ ██║███████╗███████╗██║ ██║
|
||||
╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚══════╝╚═════╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
https://discord.gg/nass
|
||||
|
||||
Please support the development of this script by joining our discord server.
|
||||
]]
|
||||
|
||||
RegisterNetEvent('nass_pedscaler:syncScale', function(scale)
|
||||
local src = source
|
||||
playerScaling[getPlayerIdentifier(src)] = scale
|
||||
|
||||
TriggerClientEvent('nass_pedscaler:syncScale', -1, src, scale)
|
||||
end)
|
||||
|
||||
@@ -16,6 +34,7 @@ if Config.commands.resetScale.enabled then
|
||||
RegisterCommand(Config.commands.resetScale.command, function(source, args)
|
||||
local id = tonumber(args[1]) or source
|
||||
if hasPermission(source, id == source and "resetSelf" or "resetOther") then
|
||||
playerScaling[getPlayerIdentifier(id)] = nil
|
||||
TriggerClientEvent('nass_pedscaler:syncScale', -1, id, nil)
|
||||
end
|
||||
end, false)
|
||||
|
||||
Reference in new issue
Block a user