diff --git a/.github/workflows/zip-release.yml b/.github/workflows/zip-release.yml deleted file mode 100644 index 4be812c..0000000 --- a/.github/workflows/zip-release.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build ZIP - -on: - push: - branches: [ main ] - workflow_dispatch: - -permissions: - contents: write - - -jobs: - zip: - runs-on: ubuntu-latest - - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Set zip name - run: | - REPO="${GITHUB_REPOSITORY##*/}" - echo "ZIP_NAME=${REPO}.zip" >> "$GITHUB_ENV" - - - name: Create flat zip (no root folder) - run: | - cd "$GITHUB_WORKSPACE" - zip -r "${ZIP_NAME}" ./* \ - -x "web/react/*" "web/react/**" \ - -x ".git/*" ".git/**" \ - -x "**/node_modules/**" \ - -x ".gitignore" \ - -x ".github/**" \ - -x "**/*.zip" - - - name: Upload to GitHub Release (always overwrite 'latest') - uses: softprops/action-gh-release@v2 - with: - tag_name: latest - name: Latest Build - body: | - This is an automatically built ZIP from the latest push to `main`. - draft: false - prerelease: false - files: | - ${{ env.ZIP_NAME }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 9679193..272b866 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ coverage/ # Temporary folders tmp/ temp/ +playerScaling.json \ No newline at end of file diff --git a/client/client.lua b/client/client.lua index e44d34c..0cc9e41 100644 --- a/client/client.lua +++ b/client/client.lua @@ -1,5 +1,21 @@ ---https://github.com/alp1x/um-ped-scale ---Main scaling function based off of this script +--[[ + 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. +]] + + + local function norm(vec) local mag = math.sqrt(vec.x ^ 2 + vec.y ^ 2 + vec.z ^ 2) if mag > 0 then @@ -113,7 +129,6 @@ RegisterNUICallback('get_config', function(data, cb) end) RegisterNetEvent('nass_pedscaler:openMenu', function() - print("Opening ped scaler menu...") SetNuiFocus(true, true) SendNUIMessage({ action = "visible", diff --git a/config.lua b/config.lua index e6154c4..3b2b00e 100644 --- a/config.lua +++ b/config.lua @@ -1,3 +1,16 @@ +--[[ + ███╗ ██╗ █████╗ ███████╗███████╗ ██████╗ ███████╗██████╗ ███████╗ ██████╗ █████╗ ██╗ ███████╗██████╗ + ████╗ ██║██╔══██╗██╔════╝██╔════╝ ██╔══██╗██╔════╝██╔══██╗██╔════╝██╔════╝██╔══██╗██║ ██╔════╝██╔══██╗ + ██╔██╗ ██║███████║███████╗███████╗ ██████╔╝█████╗ ██║ ██║███████╗██║ ███████║██║ █████╗ ██████╔╝ + ██║╚██╗██║██╔══██║╚════██║╚════██║ ██╔═══╝ ██╔══╝ ██║ ██║╚════██║██║ ██╔══██║██║ ██╔══╝ ██╔══██╗ + ██║ ╚████║██║ ██║███████║███████║███████╗██║ ███████╗██████╔╝███████║╚██████╗██║ ██║███████╗███████╗██║ ██║ + ╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚══════╝╚═════╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ + + https://discord.gg/nass + + Please support the development of this script by joining our discord server. +]] + Config = {} Config.locale = Locales["en"] diff --git a/server/database.lua b/server/database.lua index e69de29..90d6625 100644 --- a/server/database.lua +++ b/server/database.lua @@ -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) \ No newline at end of file diff --git a/server/framework/esx.lua b/server/framework/esx.lua index e69de29..6d498bc 100644 --- a/server/framework/esx.lua +++ b/server/framework/esx.lua @@ -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) \ No newline at end of file diff --git a/server/framework/qb.lua b/server/framework/qb.lua index e69de29..94e76a4 100644 --- a/server/framework/qb.lua +++ b/server/framework/qb.lua @@ -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) \ No newline at end of file diff --git a/server/framework/standalone.lua b/server/framework/standalone.lua new file mode 100644 index 0000000..8e7179d --- /dev/null +++ b/server/framework/standalone.lua @@ -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) \ No newline at end of file diff --git a/server/server.lua b/server/server.lua index 680372c..947c20b 100644 --- a/server/server.lua +++ b/server/server.lua @@ -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)