From e5b05619d90bc1685e232b730b6ce2c4306be890 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:52:16 +0200 Subject: [PATCH] chore: use PlayerPedId() instead of GetPlayerPed(-1) --- .../bpt_RealisticVehicle/client.lua | 4 +- .../bpt_carshowroom/client/main.lua | 20 +- .../bpt_streetfight/client/client.lua | 512 ++++++++---------- 3 files changed, 223 insertions(+), 313 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_RealisticVehicle/client.lua b/server-data/resources/[bpt_addons]/bpt_RealisticVehicle/client.lua index 13b7ee03e..0c13dc06b 100644 --- a/server-data/resources/[bpt_addons]/bpt_RealisticVehicle/client.lua +++ b/server-data/resources/[bpt_addons]/bpt_RealisticVehicle/client.lua @@ -42,7 +42,7 @@ AddEventHandler("esx:setJob", function(job) end) local function isPedDrivingAVehicle() - local ped = GetPlayerPed(-1) + local ped = PlayerPedId() vehicle = GetVehiclePedIsIn(ped, false) if IsPedInAnyVehicle(ped, false) then -- Check if ped is in driver seat @@ -221,7 +221,7 @@ end Citizen.CreateThread(function() while true do Citizen.Wait(50) - local ped = GetPlayerPed(-1) + local ped = PlayerPedId() if isPedDrivingAVehicle() then vehicle = GetVehiclePedIsIn(ped, false) vehicleClass = GetVehicleClass(vehicle) diff --git a/server-data/resources/[bpt_addons]/bpt_carshowroom/client/main.lua b/server-data/resources/[bpt_addons]/bpt_carshowroom/client/main.lua index b7236f8f1..b2d4ce7e1 100644 --- a/server-data/resources/[bpt_addons]/bpt_carshowroom/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_carshowroom/client/main.lua @@ -140,7 +140,7 @@ function OpenShopMenu() ESX.UI.Menu.CloseAll() - local playerPed = GetPlayerPed(-1) + local playerPed = PlayerPedId() FreezeEntityPosition(playerPed, true) SetEntityVisible(playerPed, false) @@ -205,10 +205,10 @@ function OpenShopMenu() if data2.current.value == "no" then menu2.close() end - end, function(data2, menu2) + end, function(_, menu2) menu2.close() end) - end, function(data, menu) + end, function(_, menu) menu.close() DoScreenFadeOut(1000) @@ -217,7 +217,7 @@ function OpenShopMenu() DeleteKatalogVehicles() - local playerPed = GetPlayerPed(-1) + local playerPed = PlayerPedId() CurrentAction = "shop_menu" CurrentActionMsg = "shop menu" @@ -231,7 +231,7 @@ function OpenShopMenu() IsInShopMenu = false end, function(data, menu) local vehicleData = vehiclesByCategory[data.current.name][data.current.value + 1] - local playerPed = GetPlayerPed(-1) + local playerPed = PlayerPedId() DeleteKatalogVehicles() @@ -285,7 +285,7 @@ Citizen.CreateThread(function() end if CurrentAction == "go_down_from" then - local playerPed = GetPlayerPed(-1) + local playerPed = PlayerPedId() DoScreenFadeOut(3000) Wait(3000) DoScreenFadeIn(3000) @@ -293,7 +293,7 @@ Citizen.CreateThread(function() end if CurrentAction == "goTranslateCapp_from" then - local playerPed = GetPlayerPed(-1) + local playerPed = PlayerPedId() DoScreenFadeOut(3000) Wait(3000) DoScreenFadeIn(3000) @@ -312,9 +312,9 @@ Citizen.CreateThread(function() while true do Wait(0) - local coords = GetEntityCoords(GetPlayerPed(-1)) + local coords = GetEntityCoords(PlayerPedId()) - for k, v in pairs(Config.Zones) do + for _, v in pairs(Config.Zones) do if v.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance then DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) end @@ -327,7 +327,7 @@ Citizen.CreateThread(function() while true do Wait(0) - local coords = GetEntityCoords(GetPlayerPed(-1)) + local coords = GetEntityCoords(PlayerPedId()) local isInMarker = false local currentZone = nil diff --git a/server-data/resources/[bpt_addons]/bpt_streetfight/client/client.lua b/server-data/resources/[bpt_addons]/bpt_streetfight/client/client.lua index 069e166ea..0ede8bb4a 100644 --- a/server-data/resources/[bpt_addons]/bpt_streetfight/client/client.lua +++ b/server-data/resources/[bpt_addons]/bpt_streetfight/client/client.lua @@ -16,377 +16,287 @@ local winner = nil ESX = exports["es_extended"]:getSharedObject() CreateThread(function() - CreateBlip(Config.BLIP.coords, Config.BLIP.text, Config.BLIP.sprite, Config.BLIP.color, Config.BLIP.scale) - RunThread() + CreateBlip(Config.BLIP.coords, Config.BLIP.text, Config.BLIP.sprite, Config.BLIP.color, Config.BLIP.scale) + RunThread() end) RegisterNetEvent("bpt_streetfight:playerJoined") AddEventHandler("bpt_streetfight:playerJoined", function(side, id) - if side == 1 then - blueJoined = true - else - redJoined = true - end + if side == 1 then + blueJoined = true + else + redJoined = true + end - if id == GetPlayerServerId(PlayerId()) then - participating = true - putGloves() - end - players = players + 1 - fightStatus = STATUS_JOINED + if id == GetPlayerServerId(PlayerId()) then + participating = true + putGloves() + end + players = players + 1 + fightStatus = STATUS_JOINED end) RegisterNetEvent("bpt_streetfight:startFight") AddEventHandler("bpt_streetfight:startFight", function(fightData) - for _, value in ipairs(fightData) do - if value.id ~= GetPlayerServerId(PlayerId()) then - rival = value.id - elseif value.id == GetPlayerServerId(PlayerId()) then - participating = true - end - end + for _, value in ipairs(fightData) do + if value.id ~= GetPlayerServerId(PlayerId()) then + rival = value.id + elseif value.id == GetPlayerServerId(PlayerId()) then + participating = true + end + end - fightStatus = STATUS_STARTED - showCountDown = true - countdown() + fightStatus = STATUS_STARTED + showCountDown = true + countdown() end) RegisterNetEvent("bpt_streetfight:playerLeaveFight") AddEventHandler("bpt_streetfight:playerLeaveFight", function(id) - if id == GetPlayerServerId(PlayerId()) then - ESX.ShowNotification(TranslateCap("you_toofar")) - SetPedMaxHealth(PlayerPedId(), 200) - SetEntityHealth(PlayerPedId(), 200) - removeGloves() - elseif participating == true then - TriggerServerEvent("bpt_streetfight:pay", betAmount) - ESX.ShowNotification(TranslateCap("you_win") .. (betAmount * 2) .. "$") - SetPedMaxHealth(PlayerPedId(), 200) - SetEntityHealth(PlayerPedId(), 200) - removeGloves() - end - reset() + if id == GetPlayerServerId(PlayerId()) then + ESX.ShowNotification(TranslateCap("you_toofar")) + SetPedMaxHealth(PlayerPedId(), 200) + SetEntityHealth(PlayerPedId(), 200) + removeGloves() + elseif participating == true then + TriggerServerEvent("bpt_streetfight:pay", betAmount) + ESX.ShowNotification(TranslateCap("you_win") .. (betAmount * 2) .. "$") + SetPedMaxHealth(PlayerPedId(), 200) + SetEntityHealth(PlayerPedId(), 200) + removeGloves() + end + reset() end) RegisterNetEvent("bpt_streetfight:fightFinished") AddEventHandler("bpt_streetfight:fightFinished", function(looser) - if participating == true then - if looser ~= GetPlayerServerId(PlayerId()) and looser ~= -2 then - TriggerServerEvent("bpt_streetfight:pay", betAmount) - ESX.ShowNotification(TranslateCap("you_win") .. (betAmount * 2) .. "$") - SetPedMaxHealth(PlayerPedId(), 200) - SetEntityHealth(PlayerPedId(), 200) + if participating == true then + if looser ~= GetPlayerServerId(PlayerId()) and looser ~= -2 then + TriggerServerEvent("bpt_streetfight:pay", betAmount) + ESX.ShowNotification(TranslateCap("you_win") .. (betAmount * 2) .. "$") + SetPedMaxHealth(PlayerPedId(), 200) + SetEntityHealth(PlayerPedId(), 200) - TriggerServerEvent("bpt_streetfight:showWinner", GetPlayerServerId(PlayerId())) - end + TriggerServerEvent("bpt_streetfight:showWinner", GetPlayerServerId(PlayerId())) + end - if looser == GetPlayerServerId(PlayerId()) and looser ~= -2 then - ESX.ShowNotification(TranslateCap("you_lost") .. betAmount .. "$") - SetPedMaxHealth(PlayerPedId(), 200) - SetEntityHealth(PlayerPedId(), 200) - end + if looser == GetPlayerServerId(PlayerId()) and looser ~= -2 then + ESX.ShowNotification(TranslateCap("you_lost") .. betAmount .. "$") + SetPedMaxHealth(PlayerPedId(), 200) + SetEntityHealth(PlayerPedId(), 200) + end - if looser == -2 then - ESX.ShowNotification(TranslateCap("time_out")) - SetPedMaxHealth(PlayerPedId(), 200) - SetEntityHealth(PlayerPedId(), 200) - end + if looser == -2 then + ESX.ShowNotification(TranslateCap("time_out")) + SetPedMaxHealth(PlayerPedId(), 200) + SetEntityHealth(PlayerPedId(), 200) + end - removeGloves() - end - reset() + removeGloves() + end + reset() end) RegisterNetEvent("bpt_streetfight:raiseActualBet") AddEventHandler("bpt_streetfight:raiseActualBet", function() - betAmount = betAmount * 2 - if betAmount == 0 then - betAmount = 2000 - elseif betAmount > 100000 then - betAmount = 0 - end + betAmount = betAmount * 2 + if betAmount == 0 then + betAmount = 2000 + elseif betAmount > 100000 then + betAmount = 0 + end end) RegisterNetEvent("bpt_streetfight:winnerText") AddEventHandler("bpt_streetfight:winnerText", function(id) - showWinner = true - winner = id - Wait(5000) - showWinner = false - winner = nil + showWinner = true + winner = id + Wait(5000) + showWinner = false + winner = nil end) local actualCount = 0 function countdown() - for i = 5, 0, -1 do - actualCount = i - Wait(1000) - end - showCountDown = false - actualCount = 0 + for i = 5, 0, -1 do + actualCount = i + Wait(1000) + end + showCountDown = false + actualCount = 0 - if participating == true then - SetPedMaxHealth(PlayerPedId(), 500) - SetEntityHealth(PlayerPedId(), 500) - end + if participating == true then + SetPedMaxHealth(PlayerPedId(), 500) + SetEntityHealth(PlayerPedId(), 500) + end end function putGloves() - local ped = GetPlayerPed(-1) - local hash = GetHashKey("prop_boxing_glove_01") - while not HasModelLoaded(hash) do - RequestModel(hash) - Wait(0) - end - local pos = GetEntityCoords(ped) - local gloveA = CreateObject(hash, pos.x, pos.y, pos.z + 0.50, true, false, false) - local gloveB = CreateObject(hash, pos.x, pos.y, pos.z + 0.50, true, false, false) - table.insert(Gloves, gloveA) - table.insert(Gloves, gloveB) - SetModelAsNoLongerNeeded(hash) - FreezeEntityPosition(gloveA, false) - SetEntityCollision(gloveA, false, true) - ActivatePhysics(gloveA) - FreezeEntityPosition(gloveB, false) - SetEntityCollision(gloveB, false, true) - ActivatePhysics(gloveB) - if not ped then - ped = GetPlayerPed(-1) - end -- gloveA = L, gloveB = R - AttachEntityToEntity( - gloveA, - ped, - GetPedBoneIndex(ped, 0xEE4F), - 0.05, - 0.00, - 0.04, - 00.0, - 90.0, - -90.0, - true, - true, - false, - true, - 1, - true - ) -- object is attached to right hand - AttachEntityToEntity( - gloveB, - ped, - GetPedBoneIndex(ped, 0xAB22), - 0.05, - 0.00, - -0.04, - 00.0, - 90.0, - 90.0, - true, - true, - false, - true, - 1, - true - ) -- object is attached to right hand + local ped = PlayerPedId() + local hash = GetHashKey("prop_boxing_glove_01") + while not HasModelLoaded(hash) do + RequestModel(hash) + Wait(0) + end + local pos = GetEntityCoords(ped) + local gloveA = CreateObject(hash, pos.x, pos.y, pos.z + 0.50, true, false, false) + local gloveB = CreateObject(hash, pos.x, pos.y, pos.z + 0.50, true, false, false) + table.insert(Gloves, gloveA) + table.insert(Gloves, gloveB) + SetModelAsNoLongerNeeded(hash) + FreezeEntityPosition(gloveA, false) + SetEntityCollision(gloveA, false, true) + ActivatePhysics(gloveA) + FreezeEntityPosition(gloveB, false) + SetEntityCollision(gloveB, false, true) + ActivatePhysics(gloveB) + if not ped then + ped = PlayerPedId() + end -- gloveA = L, gloveB = R + AttachEntityToEntity(gloveA, ped, GetPedBoneIndex(ped, 0xEE4F), 0.05, 0.00, 0.04, 00.0, 90.0, -90.0, true, true, false, true, 1, true) -- object is attached to right hand + AttachEntityToEntity(gloveB, ped, GetPedBoneIndex(ped, 0xAB22), 0.05, 0.00, -0.04, 00.0, 90.0, 90.0, true, true, false, true, 1, true) -- object is attached to right hand end function removeGloves() - for _, v in pairs(Gloves) do - DeleteObject(v) - end + for _, v in pairs(Gloves) do + DeleteObject(v) + end end function spawnMarker(coords) - local centerRing = GetDistanceBetweenCoords(coords, vector3(-517.61, -1712.04, 20.46), true) - if centerRing < Config.DISTANCE and fightStatus ~= STATUS_STARTED then - DrawMarker( - 1, - Config.BETZONE.x, - Config.BETZONE.y, - Config.BETZONE.z, - 0.0, - 0.0, - 0.0, - 0, - 0.0, - 0.0, - 1.5, - 1.5, - 1.0, - 204, - 204, - 0, - 100, - false, - true, - 2, - false, - false, - false, - false - ) - DrawText3D( - Config.CENTER.x, - Config.CENTER.y, - Config.CENTER.z + 1.5, - "Giocatori: ~r~" .. players .. "/2 \n ~w~Scommessa: ~r~" .. betAmount .. "$ ", - 0.8 - ) - local blueZone = - GetDistanceBetweenCoords(coords, vector3(Config.BLUEZONE.x, Config.BLUEZONE.y, Config.BLUEZONE.z), true) - local redZone = - GetDistanceBetweenCoords(coords, vector3(Config.REDZONE.x, Config.REDZONE.y, Config.REDZONE.z), true) - local betZone = - GetDistanceBetweenCoords(coords, vector3(Config.BETZONE.x, Config.BETZONE.y, Config.BETZONE.z), true) + local centerRing = GetDistanceBetweenCoords(coords, vector3(-517.61, -1712.04, 20.46), true) + if centerRing < Config.DISTANCE and fightStatus ~= STATUS_STARTED then + DrawMarker(1, Config.BETZONE.x, Config.BETZONE.y, Config.BETZONE.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 1.5, 1.5, 1.0, 204, 204, 0, 100, false, true, 2, false, false, false, false) + DrawText3D(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z + 1.5, "Giocatori: ~r~" .. players .. "/2 \n ~w~Scommessa: ~r~" .. betAmount .. "$ ", 0.8) + local blueZone = GetDistanceBetweenCoords(coords, vector3(Config.BLUEZONE.x, Config.BLUEZONE.y, Config.BLUEZONE.z), true) + local redZone = GetDistanceBetweenCoords(coords, vector3(Config.REDZONE.x, Config.REDZONE.y, Config.REDZONE.z), true) + local betZone = GetDistanceBetweenCoords(coords, vector3(Config.BETZONE.x, Config.BETZONE.y, Config.BETZONE.z), true) - if blueJoined == false then - DrawText3D( - Config.BLUEZONE.x, - Config.BLUEZONE.y, - Config.BLUEZONE.z + 1.5, - "unisciti alla lotta [~b~E~w~]", - 0.4 - ) - if blueZone < Config.DISTANCE_INTERACTION then - ESX.ShowHelpNotification(TranslateCap("press_to_join_blue")) - if IsControlJustReleased(0, Config.E_KEY) and participating == false then - TriggerServerEvent("bpt_streetfight:join", betAmount, 0) - end - end - end + if blueJoined == false then + DrawText3D(Config.BLUEZONE.x, Config.BLUEZONE.y, Config.BLUEZONE.z + 1.5, "unisciti alla lotta [~b~E~w~]", 0.4) + if blueZone < Config.DISTANCE_INTERACTION then + ESX.ShowHelpNotification(TranslateCap("press_to_join_blue")) + if IsControlJustReleased(0, Config.E_KEY) and participating == false then + TriggerServerEvent("bpt_streetfight:join", betAmount, 0) + end + end + end - if redJoined == false then - DrawText3D(Config.REDZONE.x, Config.REDZONE.y, Config.REDZONE.z + 1.5, "unisciti alla lotta [~r~E~w~]", 0.4) - if redZone < Config.DISTANCE_INTERACTION then - ESX.ShowHelpNotification(TranslateCap("press_to_join_red")) - if IsControlJustReleased(0, Config.E_KEY) and participating == false then - TriggerServerEvent("bpt_streetfight:join", betAmount, 1) - end - end - end + if redJoined == false then + DrawText3D(Config.REDZONE.x, Config.REDZONE.y, Config.REDZONE.z + 1.5, "unisciti alla lotta [~r~E~w~]", 0.4) + if redZone < Config.DISTANCE_INTERACTION then + ESX.ShowHelpNotification(TranslateCap("press_to_join_red")) + if IsControlJustReleased(0, Config.E_KEY) and participating == false then + TriggerServerEvent("bpt_streetfight:join", betAmount, 1) + end + end + end - if betZone < Config.DISTANCE_INTERACTION and fightStatus ~= STATUS_JOINED and fightStatus ~= STATUS_STARTED then - ESX.ShowHelpNotification("premi ~INPUT_CONTEXT~ per cambiare la scommessa.") - if IsControlJustReleased(0, Config.E_KEY) then - TriggerServerEvent("bpt_streetfight:raiseBet", betAmount) - end - end - end + if betZone < Config.DISTANCE_INTERACTION and fightStatus ~= STATUS_JOINED and fightStatus ~= STATUS_STARTED then + ESX.ShowHelpNotification("premi ~INPUT_CONTEXT~ per cambiare la scommessa.") + if IsControlJustReleased(0, Config.E_KEY) then + TriggerServerEvent("bpt_streetfight:raiseBet", betAmount) + end + end + end end function get3DDistance(x1, y1, z1, x2, y2, z2) - local a = (x1 - x2) * (x1 - x2) - local b = (y1 - y2) * (y1 - y2) - local c = (z1 - z2) * (z1 - z2) - return math.sqrt(a + b + c) + local a = (x1 - x2) * (x1 - x2) + local b = (y1 - y2) * (y1 - y2) + local c = (z1 - z2) * (z1 - z2) + return math.sqrt(a + b + c) end function DrawText3D(x, y, z, text, scale) - local _, _x, _y = World3dToScreen2d(x, y, z) - local _, _, _ = table.unpack(GetGameplayCamCoords()) - SetTextScale(scale, scale) - SetTextFont(4) - SetTextProportional(1) - SetTextEntry("STRING") - SetTextCentre(1) - SetTextColour(255, 255, 255, 215) - AddTextComponentString(text) - DrawText(_x, _y) + local _, _x, _y = World3dToScreen2d(x, y, z) + local _, _, _ = table.unpack(GetGameplayCamCoords()) + SetTextScale(scale, scale) + SetTextFont(4) + SetTextProportional(1) + SetTextEntry("STRING") + SetTextCentre(1) + SetTextColour(255, 255, 255, 215) + AddTextComponentString(text) + DrawText(_x, _y) end function CreateBlip(coords, text, sprite, color, scale) - local blip = AddBlipForCoord(coords.x, coords.y) - SetBlipSprite(blip, sprite) - SetBlipScale(blip, scale) - SetBlipColour(blip, color) - SetBlipAsShortRange(blip, true) - BeginTextCommandSetBlipName("STRING") - AddTextComponentSubstringPlayerName(text) - EndTextCommandSetBlipName(blip) + local blip = AddBlipForCoord(coords.x, coords.y) + SetBlipSprite(blip, sprite) + SetBlipScale(blip, scale) + SetBlipColour(blip, color) + SetBlipAsShortRange(blip, true) + BeginTextCommandSetBlipName("STRING") + AddTextComponentSubstringPlayerName(text) + EndTextCommandSetBlipName(blip) end function reset() - redJoined = false - blueJoined = false - participating = false - players = 0 - fightStatus = STATUS_INITIAL + redJoined = false + blueJoined = false + participating = false + players = 0 + fightStatus = STATUS_INITIAL end function RunThread() - CreateThread(function() - while true do - Wait(0) - local coords = GetEntityCoords(PlayerPedId()) - spawnMarker(coords) - end - end) + CreateThread(function() + while true do + Wait(0) + local coords = GetEntityCoords(PlayerPedId()) + spawnMarker(coords) + end + end) end -- Alejar player - 1000 loop CreateThread(function() - while true do - if fightStatus == STATUS_STARTED and participating == false and GetEntityCoords(PlayerPedId()) ~= rival then - local coords = GetEntityCoords(GetPlayerPed(-1)) - if - get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z, coords.x, coords.y, coords.z) - < Config.TP_DISTANCE - then - ESX.ShowNotification(TranslateCap("step_away")) - for _ = 1, 1000 do - SetPedCoordsKeepVehicle(GetPlayerPed(-1), -521.58, -1723.58, 19.16) - local foundGround = GetGroundZFor_3dCoord(-521.58, -1723.58, 19.16) - if foundGround then - SetPedCoordsKeepVehicle(GetPlayerPed(_), -521.58, -1723.58, 19.16) - break - end - Wait(5) - end - end - end - Wait(1000) - end + while true do + if fightStatus == STATUS_STARTED and participating == false and GetEntityCoords(PlayerPedId()) ~= rival then + local coords = GetEntityCoords(PlayerPedId()) + if get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z, coords.x, coords.y, coords.z) < Config.TP_DISTANCE then + ESX.ShowNotification(TranslateCap("step_away")) + for _ = 1, 1000 do + SetPedCoordsKeepVehicle(PlayerPedId(), -521.58, -1723.58, 19.16) + local foundGround = GetGroundZFor_3dCoord(-521.58, -1723.58, 19.16) + if foundGround then + SetPedCoordsKeepVehicle(GetPlayerPed(_), -521.58, -1723.58, 19.16) + break + end + Wait(5) + end + end + end + Wait(1000) + end end) -- Main 0 loop CreateThread(function() - while true do - Wait(0) - if showCountDown == true then - DrawText3D( - Config.CENTER.x, - Config.CENTER.y, - Config.CENTER.z + 1.5, - "La lotta inizia in: " .. actualCount, - 2.0 - ) - elseif showCountDown == false and fightStatus == STATUS_STARTED then - if GetEntityHealth(PlayerPedId()) < 150 then - TriggerServerEvent("bpt_streetfight:finishFight", GetPlayerServerId(PlayerId())) - fightStatus = STATUS_INITIAL - end - end + while true do + Wait(0) + if showCountDown == true then + DrawText3D(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z + 1.5, "La lotta inizia in: " .. actualCount, 2.0) + elseif showCountDown == false and fightStatus == STATUS_STARTED then + if GetEntityHealth(PlayerPedId()) < 150 then + TriggerServerEvent("bpt_streetfight:finishFight", GetPlayerServerId(PlayerId())) + fightStatus = STATUS_INITIAL + end + end - if participating == true then - local coords = GetEntityCoords(GetPlayerPed(-1)) - if - get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z, coords.x, coords.y, coords.z) - > Config.LEAVE_FIGHT_DISTANCE - then - TriggerServerEvent("bpt_streetfight:leaveFight", GetPlayerServerId(PlayerId())) - end - end + if participating == true then + local coords = GetEntityCoords(PlayerPedId()) + if get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z, coords.x, coords.y, coords.z) > Config.LEAVE_FIGHT_DISTANCE then + TriggerServerEvent("bpt_streetfight:leaveFight", GetPlayerServerId(PlayerId())) + end + end - if showWinner == true and winner ~= nil then - local coords = GetEntityCoords(GetPlayerPed(-1)) - if get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z, coords.x, coords.y, coords.z) < 15 then - DrawText3D( - Config.CENTER.x, - Config.CENTER.y, - Config.CENTER.z + 2.5, - "~r~ID: " .. winner .. " gana!", - 2.0 - ) - end - end - end + if showWinner == true and winner ~= nil then + local coords = GetEntityCoords(PlayerPedId()) + if get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z, coords.x, coords.y, coords.z) < 15 then + DrawText3D(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z + 2.5, "~r~ID: " .. winner .. " gana!", 2.0) + end + end + end end)