From f10c5566d187ef04700e18af01c095e16d6279d9 Mon Sep 17 00:00:00 2001 From: Springo_dev <171420535+springoooo@users.noreply.github.com> Date: Tue, 31 Dec 2024 09:04:15 +1100 Subject: [PATCH] Add files via upload --- springo-fixtextures/client/client.lua | 134 ++++++++++++++++++++++++++ springo-fixtextures/fxmanifest.lua | 20 ++++ springo-fixtextures/server/server.lua | 18 ++++ 3 files changed, 172 insertions(+) create mode 100644 springo-fixtextures/client/client.lua create mode 100644 springo-fixtextures/fxmanifest.lua create mode 100644 springo-fixtextures/server/server.lua diff --git a/springo-fixtextures/client/client.lua b/springo-fixtextures/client/client.lua new file mode 100644 index 0000000..415664f --- /dev/null +++ b/springo-fixtextures/client/client.lua @@ -0,0 +1,134 @@ +local isFixingTextures = false + +RegisterNetEvent('springo-fixtextures:client', function() + if isFixingTextures then return end + + isFixingTextures = true + local playerPed = PlayerPedId() + local coords = GetEntityCoords(playerPed) + local vehicles = {} + local peds = {} + + if IsPedInAnyVehicle(playerPed, false) then + lib.notify({ + title = "Error", + description = "You must exit your vehicle before using this command.", + type = "error" + }) + isFixingTextures = false + return + end + + local nearbyPlayers = false + local players = GetActivePlayers() + for _, player in ipairs(players) do + if player ~= PlayerId() then + local targetPed = GetPlayerPed(player) + local targetCoords = GetEntityCoords(targetPed) + if #(targetCoords - coords) <= 25.0 then + nearbyPlayers = true + break + end + end + end + + lib.notify({ + title = "Fixing Textures", + description = "Reloading your game world. Please wait...", + type = "info" + }) + + DoScreenFadeOut(1000) + while not IsScreenFadedOut() do + Wait(100) + end + + local radius = 50.0 + local handle, vehicle = FindFirstVehicle() + local success + repeat + if DoesEntityExist(vehicle) then + local vehicleCoords = GetEntityCoords(vehicle) + if #(vehicleCoords - coords) <= radius then + local vehicleData = { + handle = vehicle, + coords = vehicleCoords, + heading = GetEntityHeading(vehicle) + } + table.insert(vehicles, vehicleData) + end + end + success, vehicle = FindNextVehicle(handle) + until not success + EndFindVehicle(handle) + + handle, ped = FindFirstPed() + success = true + repeat + if DoesEntityExist(ped) and not IsPedAPlayer(ped) then + local pedCoords = GetEntityCoords(ped) + if #(pedCoords - coords) <= radius then + local pedData = { + handle = ped, + coords = pedCoords, + heading = GetEntityHeading(ped) + } + table.insert(peds, pedData) + end + end + success, ped = FindNextPed(handle) + until not success + EndFindPed(handle) + + local farAwayCoords = vector3(10000.0, 10000.0, 1000.0) + SetEntityCoordsNoOffset(playerPed, farAwayCoords.x, farAwayCoords.y, farAwayCoords.z, false, false, false) + + Wait(5000) + + SetEntityCoordsNoOffset(playerPed, coords.x, coords.y, coords.z, false, false, false) + + for _, vehicleData in pairs(vehicles) do + if DoesEntityExist(vehicleData.handle) then + SetEntityCoordsNoOffset(vehicleData.handle, vehicleData.coords.x, vehicleData.coords.y, vehicleData.coords.z, false, false, false) + SetEntityHeading(vehicleData.handle, vehicleData.heading) + SetVehicleOnGroundProperly(vehicleData.handle) + FreezeEntityPosition(vehicleData.handle, false) + SetEntityAsNoLongerNeeded(vehicleData.handle) + end + end + + for _, pedData in pairs(peds) do + if DoesEntityExist(pedData.handle) then + SetEntityCoordsNoOffset(pedData.handle, pedData.coords.x, pedData.coords.y, pedData.coords.z, false, false, false) + SetEntityHeading(pedData.handle, pedData.heading) + FreezeEntityPosition(pedData.handle, false) + SetEntityAsNoLongerNeeded(pedData.handle) + end + end + + local unfrozenradius = 60.0 + local unfrozenplayerCoords = GetEntityCoords(PlayerPedId()) + local unfrozenvehicles = GetGamePool('CVehicle') + + DoScreenFadeIn(1000) + while not IsScreenFadedIn() do + Wait(100) + end + + lib.notify({ + title = "Textures Fixed", + description = "Your game world has been reloaded successfully.", + type = "success" + }) + + isFixingTextures = false +end) + +RegisterNetEvent('springo-fixtextures:cooldownnotification', function(timeLeft) + lib.notify({ + title = "Cooldown Active", + description = "You must wait " .. timeLeft .. " seconds before using this command again.", + type = "error" + }) +end) + diff --git a/springo-fixtextures/fxmanifest.lua b/springo-fixtextures/fxmanifest.lua new file mode 100644 index 0000000..8faa319 --- /dev/null +++ b/springo-fixtextures/fxmanifest.lua @@ -0,0 +1,20 @@ +fx_version 'cerulean' +game 'gta5' + +author 'Springo' +version '1.0.0' +description 'springo_1 | A small script that takes you on a wild ride and assists in fixing your mushy textures!' + +lua54 'yes' + +shared_scripts { + '@ox_lib/init.lua', +} + +client_scripts{ + 'client/*.lua', +} + +server_script { + 'server/*.lua', +} \ No newline at end of file diff --git a/springo-fixtextures/server/server.lua b/springo-fixtextures/server/server.lua new file mode 100644 index 0000000..bba15b4 --- /dev/null +++ b/springo-fixtextures/server/server.lua @@ -0,0 +1,18 @@ +local cooldowns = {} + +lib.addCommand('fixtextures', { + help = 'Fix texture issues by reloading the world around you.', + restricted = false +}, function(source, args, raw) + local playerId = source + + if cooldowns[playerId] and cooldowns[playerId] > os.time() then + local timeLeft = cooldowns[playerId] - os.time() + TriggerClientEvent('springo-fixtextures:cooldownnotification', playerId, timeLeft) + return + end + + cooldowns[playerId] = os.time() + 30 + + TriggerClientEvent('springo-fixtextures:client', playerId) +end)