local ESX = exports["es_extended"]:getSharedObject() local showVehicleExtraOptions = false local vehicleOptionsTimeout = 0 local showInsideVehicleOptions = false local insideVehicleOptionsTimeout = 0 local showPlayerExtraOptions = false local playerOptionsTimeout = 0 local isRepairing = false -- Variabile Trash Search local showTrashOptions = false local trashOptionsTimeout = 0 local isSearchingTrash = false -- Variabile Bench/Sit local showBenchOptions = false local benchOptionsTimeout = 0 local isSitting = false local sitBenchEntity = nil -- Variabile NPC Scroll local showNpcOptions = false local npcOptionsTimeout = 0 local followNPC = nil -- Variabile pentru VÂNZARE la NPC local soldNPCs = {} -- { [npcHandle] = true } - NPC-uri la care ai vândut deja local isSelling = false -- Guard contra spam -- ============================================================ -- OFFSET BANCA - Regleaza aici pozitia caracterului pe banca -- X = stanga(-) / dreapta(+) -- Y = inapoi(-) / inainte(+) -- Z = jos(-) / sus(+) -- ============================================================ local BENCH_OFFSET_X = 0.0 local BENCH_OFFSET_Y = 0.0 local BENCH_OFFSET_Z = 0.3 -- Variabile pentru FUEL SERVICE (NPC) local serviceNPC = nil local npcPump = nil local isReceivingService = false local serviceVehicle = nil -- Variabile pentru DUEL local inDuel = false local duelOpponent = nil local pendingDuel = nil local drawDuelRequest = false -- Variabile pentru LIBER (mod vulnerabil fără duel) local isLiber = false local liberEndTime = 0 local liberRemainingText = "" -- Variabile pentru DUEL BLIP (hartă) local duelBlip = nil -- Variabile pentru JEFUIRE (fxThief integrat) local isRobbing = false -- Variabile pentru CARRY (cară jucător) local isCarrying = false local carriedPlayer = nil -- Variabile pentru GRUPA local myGroupData = nil -- { groupId, leader, members = { {id, name}, ... } } local groupBlips = {} -- { [serverId] = blipHandle } local showGroupUI = false local pendingGroupInvite = nil -- { from = serverId, name = string } local drawGroupInvite = false local TrashCan_Models = { `prop_bin_01a`, `prop_bin_02a`, `prop_bin_03a`, `prop_bin_04a`, `prop_bin_05a`, `prop_bin_06a`, `prop_bin_07a`, `prop_bin_07b`, `prop_bin_07c`, `prop_bin_07d`, `prop_bin_08open`, `prop_bin_10a`, `prop_bin_11a`, `prop_bin_12a`, `prop_bin_13a`, `prop_bin_14a`, `prop_cs_bin_01`, `prop_cs_bin_01_cab`, `prop_recyclebin_01a`, `prop_recyclebin_02a`, `prop_recyclebin_02_d`, `prop_dumpster_01a`, `prop_dumpster_02a`, `prop_dumpster_02b`, `prop_dumpster_3a`, `prop_dumpster_4a`, `prop_dumpster_4b` } local Bench_Models = { `prop_bench_01a`, `prop_bench_01b`, `prop_bench_01c`, `prop_bench_02`, `prop_bench_03`, `prop_bench_04`, `prop_bench_05`, `prop_bench_06`, `prop_bench_08`, `prop_bench_09`, `prop_bench_10`, `prop_bench_11`, `v_res_tre_stool`, `prop_table_02_chr`, `prop_table_03b_chr`, `prop_chair_01a`, `prop_chair_02`, `prop_chair_03`, `prop_chair_04a`, `prop_chair_08`, `prop_chair_09`, `prop_chair_10`, `prop_off_chair_01`, `prop_off_chair_03`, `prop_off_chair_04`, `prop_off_chair_04b`, `prop_off_chair_05`, `prop_cs_office_chair`, `prop_park_bench_01a` } -- Coordonate pompe de benzină (stații din GTA V) local GasStationPumps = { -- Davis Avenue (Sud) vector3(265.6, -1261.3, 29.1), vector3(265.6, -1263.8, 29.1), vector3(265.6, -1266.3, 29.1), -- Grove Street vector3(-47.9, -1761.8, 29.4), vector3(-47.9, -1764.3, 29.4), -- Mirror Park vector3(1208.9, -1402.5, 35.2), vector3(1208.9, -1405.0, 35.2), -- Ron Petroleum (Route 68) vector3(1181.4, -330.8, 69.3), vector3(1181.4, -333.3, 69.3), -- Harmony vector3(1687.0, 4929.5, 42.1), vector3(1687.0, 4932.0, 42.1), -- Grapeseed vector3(1701.5, 6416.0, 32.7), -- Paleto Bay vector3(179.9, 6602.8, 31.9), -- Great Ocean Highway vector3(-1437.0, -276.9, 46.2), vector3(-1437.0, -274.4, 46.2), -- Pacific Bluffs vector3(-2096.2, -320.2, 13.2), -- Puerto Del Sol vector3(-724.6, -935.8, 19.2), -- Little Seoul vector3(-526.0, -1211.3, 18.2), -- Strawberry Ave vector3(-70.9, -1762.2, 29.5), -- Senora Freeway vector3(2580.9, 362.0, 108.5), -- Sandy Shores vector3(1785.0, 3330.5, 41.4) } local InteractionPoints = { {coords = vector3(-33.0, -1100.0, 26.0), label = "Showroom", icon = "fa-solid fa-car-rear"}, {coords = vector3(425.0, -806.0, 24.0), label = "Magazin Haine", icon = "fa-solid fa-shirt"}, {coords = vector3(18.0, -1100.0, 29.0), label = "Gun Shop", icon = "fa-solid fa-gun"}, } -- ============================================================ -- EVENIMENTE DUEL (Pornire, Oprire, Acceptare) -- ============================================================ RegisterNetEvent('duel:receiveRequest') AddEventHandler('duel:receiveRequest', function(challengerId) pendingDuel = challengerId drawDuelRequest = true -- Activează textul de pe mijlocul ecranului Citizen.CreateThread(function() local timer = 1000 -- 10 secunde timp de răspuns while timer > 0 and pendingDuel == challengerId do Citizen.Wait(10) if IsControlJustPressed(0, 246) then -- Tasta Y TriggerServerEvent('duel:accept', pendingDuel) pendingDuel = nil drawDuelRequest = false return end timer = timer - 1 end if pendingDuel == challengerId then ESX.ShowNotification("~y~Cererea de duel a expirat.") pendingDuel = nil drawDuelRequest = false end end) end) -- Text pe mijlocul ecranului (NUI - stilul ZSX) Citizen.CreateThread(function() while true do if drawDuelRequest then Citizen.Wait(0) -- Trimite mesaj NUI să arate prompt-ul ZSX SendNUIMessage({ action = 'showDuelPrompt' }) else Citizen.Wait(500) -- Trimite mesaj NUI să ascundă prompt-ul SendNUIMessage({ action = 'hideDuelPrompt' }) end end end) local duelEndedSent = false -- Guard contra trigger dublu RegisterNetEvent('duel:start') AddEventHandler('duel:start', function(opponentId) inDuel = true duelOpponent = opponentId duelEndedSent = false -- Reset guard pentru noul duel CreateDuelBlip(opponentId) ESX.ShowNotification("~r~DUELUL A ÎNCEPUT! ~w~Fie ca cel mai bun să câștige!") end) RegisterNetEvent('duel:stop') AddEventHandler('duel:stop', function(scoreText) inDuel = false duelOpponent = nil RemoveDuelBlip() ESX.ShowNotification("~g~Duelul s-a încheiat. Ai învins!") -- BOOM EFFECT: VICTORY SendNUIMessage({ action = "showBoomEffect", won = true, score = scoreText or "" }) end) -- ============================================================ -- FIX: SISTEM DE MOARTE EXTREM DE SIGUR (Nu se mai buguiește) -- ============================================================ local function HandleDuelDeath() if inDuel and not duelEndedSent then duelEndedSent = true TriggerServerEvent('duel:ended', duelOpponent) inDuel = false duelOpponent = nil RemoveDuelBlip() ESX.ShowNotification("~r~Ai pierdut duelul!") -- BOOM EFFECT: YOU LOSE SendNUIMessage({ action = "showBoomEffect", won = false, score = "" }) end end -- ============================================================ -- LIBER KILL DETECTION — Detectează cine te-a omorât în mod LIBER -- ============================================================ local liberKillSent = false -- Guard contra trigger dublu local function HandleLiberKill() if not isLiber or liberKillSent then return end local playerPed = PlayerPedId() local killerEntity = GetPedSourceOfDeath(playerPed) if killerEntity and killerEntity ~= 0 and killerEntity ~= playerPed then if IsEntityAPed(killerEntity) and IsPedAPlayer(killerEntity) then local killerPlayerId = NetworkGetPlayerIndexFromPed(killerEntity) if killerPlayerId and killerPlayerId ~= -1 then local killerServerId = GetPlayerServerId(killerPlayerId) if killerServerId and killerServerId > 0 then liberKillSent = true TriggerServerEvent('liber:playerKilled', killerServerId) end end end end end -- Reset guard la respawn RegisterNetEvent('esx:onPlayerSpawn') AddEventHandler('esx:onPlayerSpawn', function() liberKillSent = false end) -- Funcționează perfect cu scripturile de ambulanță ESX AddEventHandler('esx:onPlayerDeath', function(data) HandleDuelDeath() HandleLiberKill() end) -- Primeste scorul de la server cand pierzi (dupa respawn) RegisterNetEvent('duel:youLost') AddEventHandler('duel:youLost', function(scoreText) SendNUIMessage({ action = "showBoomEffect", won = false, score = scoreText or "" }) end) -- Funcționează perfect cu motorul de bază FiveM (de siguranță) AddEventHandler('baseevents:onPlayerDied', function(killerId, data) HandleDuelDeath() HandleLiberKill() end) AddEventHandler('baseevents:onPlayerKilled', function(killerId, data) HandleDuelDeath() HandleLiberKill() end) -- ============================================================ -- SISTEM ANTI-HIT (No PvP Damage dacă nu ești în duel sau LIBER) -- Dacă ești LIBER, poți ataca doar alți jucători cu LIBER activ -- ============================================================ Citizen.CreateThread(function() while true do Citizen.Wait(1000) local playerPed = PlayerPedId() if inDuel or isLiber then NetworkSetFriendlyFireOption(true) SetCanAttackFriendly(playerPed, true, true) else NetworkSetFriendlyFireOption(false) SetCanAttackFriendly(playerPed, false, false) end end end) -- Thread: Dacă ești LIBER (nu duel), blochează tragerea în jucători fără LIBER -- Verifică target-ul la care aimezi — dacă nu are isLiber statebag, disable shooting Citizen.CreateThread(function() while true do if isLiber and not inDuel then Citizen.Wait(0) local playerPed = PlayerPedId() if IsPedShooting(playerPed) or IsPlayerFreeAiming(PlayerId()) then -- Verifică dacă avem un target valid local success, targetEntity = GetEntityPlayerIsFreeAimingAt(PlayerId()) if success and DoesEntityExist(targetEntity) and IsEntityAPed(targetEntity) and IsPedAPlayer(targetEntity) then -- Găsește server ID-ul target-ului local targetPlayerId = NetworkGetPlayerIndexFromPed(targetEntity) if targetPlayerId ~= -1 then local targetServerId = GetPlayerServerId(targetPlayerId) local targetIsLiber = Player(targetServerId).state.isLiber if not targetIsLiber then -- Target-ul NU are LIBER — fă-l invincibil temporar pentru mine -- Disable shooting control (nu lăsa să tragă) DisablePlayerFiring(PlayerId(), true) -- Notificare scurtă (cu cooldown) if not _liberNotifCooldown or GetGameTimer() > _liberNotifCooldown then ESX.ShowNotification("~r~Nu poți ataca acest jucător! ~w~Nu are modul LIBER activ.") _liberNotifCooldown = GetGameTimer() + 3000 end end end end end else Citizen.Wait(1000) end end end) -- ============================================================ -- PASIV MODE — Protecție doar contra jucătorilor -- NPC-urile te pot lovi normal, doar jucătorii trec prin tine -- ============================================================ Citizen.CreateThread(function() while true do local myPed = PlayerPedId() local myId = PlayerId() -- EU mereu full vizibil if GetEntityAlpha(myPed) ~= 255 then ResetEntityAlpha(myPed) end if not isLiber and not inDuel then -- No collision doar cu vehiculele conduse de JUCĂTORI local vehicles = GetGamePool('CVehicle') for _, veh in ipairs(vehicles) do if DoesEntityExist(veh) then local driver = GetPedInVehicleSeat(veh, -1) if driver and driver ~= 0 and IsPedAPlayer(driver) then -- Vehicul condus de jucător → trece prin mine SetEntityNoCollisionEntity(myPed, veh, false) SetEntityNoCollisionEntity(veh, myPed, false) end end end end -- Parcurge toți jucătorii din jur for _, playerId in ipairs(GetActivePlayers()) do if playerId ~= myId then local targetPed = GetPlayerPed(playerId) if targetPed and DoesEntityExist(targetPed) then local targetServerId = GetPlayerServerId(playerId) local targetIsLiber = Player(targetServerId).state.isLiber if not targetIsLiber then -- NU e pe LIBER → transparent + no collision SetEntityAlpha(targetPed, 80, false) SetEntityNoCollisionEntity(myPed, targetPed, false) SetEntityNoCollisionEntity(targetPed, myPed, false) else -- E pe LIBER → vizibil normal if GetEntityAlpha(targetPed) ~= 255 then ResetEntityAlpha(targetPed) end end end end end Citizen.Wait(500) end end) -- ============================================================ -- AFISARE CHAT GLOBAL PENTRU DUEL (ZSX_UIV2) -- ============================================================ RegisterNetEvent('duel:syncChatMessage') AddEventHandler('duel:syncChatMessage', function(mesajText) TriggerEvent('ZSX_UIV2:Chat:AddMessage', 'fas fa-trophy', mesajText, '#EE1C3E', false, false, 'DUEL') end) -- ============================================================ -- /boom TEST COMMAND — Testeaza efectul boom -- ============================================================ RegisterCommand('boom', function(source, args) local testWon = true local testScore = "3 — 1" if args[1] == "lose" then testWon = false testScore = "1 — 3" end if args[2] then testScore = table.concat(args, " ", 2) end SendNUIMessage({ action = "showBoomEffect", won = testWon, score = testScore }) end, false) -- ============================================================ -- /duel (id) — Provocare duel de la distanță -- ============================================================ RegisterCommand('duel', function(source, args) if #args < 1 then ESX.ShowNotification("~r~Folosește: /duel [id jucător]") return end local targetId = tonumber(args[1]) if not targetId then ESX.ShowNotification("~r~ID invalid! Folosește: /duel [id jucător]") return end if inDuel then ESX.ShowNotification("~r~Ești deja într-un duel!") return end TriggerServerEvent('duel:requestRemote', targetId) ESX.ShowNotification("~y~Ai trimis o cerere de duel către jucătorul ID " .. targetId .. "!") end, false) -- ============================================================ -- /liber — Mod vulnerabil (30 minute PvP deschis) -- ============================================================ RegisterCommand('liber', function(source, args) if isLiber then -- Arată timpul rămas local remaining = math.max(0, math.floor((liberEndTime - GetGameTimer()) / 1000)) local mins = math.floor(remaining / 60) local secs = remaining % 60 ESX.ShowNotification("~y~Modul LIBER este activ! ~w~Timp rămas: ~r~" .. mins .. "m " .. secs .. "s") return end -- Activează modul liber isLiber = true liberEndTime = GetGameTimer() + (30 * 60 * 1000) -- 30 minute TriggerServerEvent('liber:activate') ESX.ShowNotification("~r~MODUL LIBER ACTIVAT! ~w~Ești vulnerabil timp de ~r~30 de minute~w~. Poți fi atacat fără duel!") TriggerEvent('ZSX_UIV2:Chat:AddMessage', 'fas fa-skull-crossbones', 'Ai activat modul LIBER! Ești vulnerabil 30 de minute.', '#EE1C3E', false, false, 'LIBER') end, false) -- Thread: Timer /liber — dezactivare automată după 30 minute Citizen.CreateThread(function() while true do if isLiber then if GetGameTimer() >= liberEndTime then isLiber = false liberEndTime = 0 TriggerServerEvent('liber:deactivate') ESX.ShowNotification("~g~Modul LIBER a expirat! ~w~Nu mai ești vulnerabil.") TriggerEvent('ZSX_UIV2:Chat:AddMessage', 'fas fa-shield-halved', 'Modul LIBER a expirat. Ești din nou protejat.', '#00cc66', false, false, 'LIBER') end Citizen.Wait(1000) else Citizen.Wait(5000) end end end) -- Sync liber la reconectare RegisterNetEvent('liber:syncState') AddEventHandler('liber:syncState', function(active, remainingMs) if active and remainingMs > 0 then isLiber = true liberEndTime = GetGameTimer() + remainingMs ESX.ShowNotification("~r~MODUL LIBER este încă activ! ~w~Timp rămas: ~r~" .. math.floor(remainingMs / 60000) .. " minute") end end) -- ============================================================ -- DUEL BLIP — Arată oponentul pe hartă în timpul duelului -- ============================================================ function CreateDuelBlip(targetServerId) RemoveDuelBlip() -- Curăță blip-ul vechi local targetPlayer = GetPlayerFromServerId(targetServerId) if targetPlayer == -1 then return end local targetPed = GetPlayerPed(targetPlayer) if not DoesEntityExist(targetPed) then return end duelBlip = AddBlipForEntity(targetPed) SetBlipSprite(duelBlip, 303) -- Skull icon SetBlipColour(duelBlip, 1) -- Roșu SetBlipScale(duelBlip, 1.0) SetBlipFlashes(duelBlip, true) SetBlipRoute(duelBlip, true) SetBlipRouteColour(duelBlip, 1) -- Ruta roșie BeginTextCommandSetBlipName("STRING") AddTextComponentSubstringPlayerName("DUEL — Oponent") EndTextCommandSetBlipName(duelBlip) end function RemoveDuelBlip() if duelBlip and DoesBlipExist(duelBlip) then SetBlipRoute(duelBlip, false) RemoveBlip(duelBlip) duelBlip = nil end end -- ============================================================ -- NPC MINIGAME SYSTEM -- ============================================================ local npcGameData = {} local activeNpc = nil local isInGame = false local MAX_PLAYS = 3 local GAME_TYPES = {"rps", "barbut", "war"} math.randomseed(GetGameTimer()) local function findNearbyNPC(coords) local pool = GetGamePool("CPed") local closest, closestDist = nil, 3.5 for _, ped in ipairs(pool) do if not IsPedAPlayer(ped) and not IsPedDeadOrDying(ped, true) then local dist = #(coords - GetEntityCoords(ped)) if dist < closestDist then closestDist = dist closest = ped end end end return closest end local function getNpcGameType(npcHandle) if not npcGameData[npcHandle] then local t = GAME_TYPES[math.random(#GAME_TYPES)] npcGameData[npcHandle] = {type = t, count = 0} end return npcGameData[npcHandle] end local function loadAnimDict(dict) RequestAnimDict(dict) local t = 0 while not HasAnimDictLoaded(dict) and t < 30 do Citizen.Wait(100) t = t + 1 end end local function playResultAnim(ped, won) if not DoesEntityExist(ped) then return end Citizen.CreateThread(function() if won then loadAnimDict("move_m@victory@a") if HasAnimDictLoaded("move_m@victory@a") then TaskPlayAnim(ped, "move_m@victory@a", "enter", 8.0, -8.0, 4500, 0, 0, false, false, false) end else loadAnimDict("anim@mp_player_intros@warped_michael@") if HasAnimDictLoaded("anim@mp_player_intros@warped_michael@") then TaskPlayAnim(ped, "anim@mp_player_intros@warped_michael@", "intro", 8.0, -8.0, 4500, 0, 0, false, false, false) end end Citizen.Wait(4500) if DoesEntityExist(ped) then ClearPedTasks(ped) end end) end local function cleanupGame() if activeNpc and DoesEntityExist(activeNpc) then FreezeEntityPosition(activeNpc, false) ClearPedTasks(activeNpc) end isInGame = false activeNpc = nil SetNuiFocus(false, false) end RegisterNUICallback('npcGameResult', function(data, cb) local won = data.won if activeNpc and npcGameData[activeNpc] then npcGameData[activeNpc].count = npcGameData[activeNpc].count + 1 end TriggerServerEvent('npc_minigame:processResult', won) local playerPed = PlayerPedId() playResultAnim(playerPed, won) if activeNpc and DoesEntityExist(activeNpc) then playResultAnim(activeNpc, not won) end cb('ok') end) RegisterNUICallback('closeNpcGame', function(data, cb) cleanupGame() cb('ok') end) Citizen.CreateThread(function() while true do Citizen.Wait(0) if isInGame and (IsControlJustPressed(0, 200) or IsControlJustPressed(0, 177)) then SendNUIMessage({ action = "forceCloseGame" }) cleanupGame() end end end) Citizen.CreateThread(function() while true do if isInGame and activeNpc and DoesEntityExist(activeNpc) then local playerPed = PlayerPedId() local pb = GetPedBoneCoords(playerPed, 31086, 0.0, 0.0, 0.0) local nb = GetPedBoneCoords(activeNpc, 31086, 0.0, 0.0, 0.0) local pOn, px, py = GetScreenCoordFromWorldCoord(pb.x, pb.y, pb.z + 0.55) local nOn, nx, ny = GetScreenCoordFromWorldCoord(nb.x, nb.y, nb.z + 0.55) SendNUIMessage({ action = "updateHeadPositions", player = {visible = pOn, x = px, y = py}, npc = {visible = nOn, x = nx, y = ny} }) Citizen.Wait(0) else Citizen.Wait(300) end end end) function GetClosestVehicleDoor(vehicle, playerCoords) local doors = { {index = 0, bone = "door_dside_f"}, {index = 1, bone = "door_pside_f"}, {index = 2, bone = "door_dside_r"}, {index = 3, bone = "door_pside_r"} } local closestDoor, closestDist = 0, 999 for _, door in ipairs(doors) do local bi = GetEntityBoneIndexByName(vehicle, door.bone) if bi ~= -1 then local bc = GetWorldPositionOfEntityBone(vehicle, bi) local dist = #(playerCoords - bc) if dist < closestDist then closestDist = dist closestDoor = door.index end end end return closestDoor end -- ============================================================ -- Funcție: Cel mai aproape jucător (INCLUSIV MORȚI) -- ESX.Game.GetClosestPlayer() poate ignora morții -- ============================================================ function GetClosestPlayerIncludingDead() local playerPed = PlayerPedId() local playerCoords = GetEntityCoords(playerPed) local closestPlayer = -1 local closestDistance = 999.0 for _, playerId in ipairs(GetActivePlayers()) do if playerId ~= PlayerId() then local targetPed = GetPlayerPed(playerId) if targetPed and DoesEntityExist(targetPed) then local dist = #(playerCoords - GetEntityCoords(targetPed)) if dist < closestDistance then closestDistance = dist closestPlayer = playerId end end end end return closestPlayer, closestDistance end -- ============================================================ -- THREAD: Scroll mouse (pentru Masini si Jucatori) -- ============================================================ Citizen.CreateThread(function() while true do Citizen.Wait(0) if IsControlJustPressed(0, 241) or IsControlJustPressed(0, 242) then local playerPed = PlayerPedId() if IsPedInAnyVehicle(playerPed, false) then showInsideVehicleOptions = true insideVehicleOptionsTimeout = GetGameTimer() + 4000 else local coords = GetEntityCoords(playerPed) -- Verificăm jucători în jur (inclusiv morți) local closestPlayer, closestDistance = GetClosestPlayerIncludingDead() if closestPlayer ~= -1 and closestDistance < 2.0 then showPlayerExtraOptions = true playerOptionsTimeout = GetGameTimer() + 4000 end -- Verificăm mașini în jur local vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 3.5, 0, 71) if vehicle ~= 0 then showVehicleExtraOptions = true vehicleOptionsTimeout = GetGameTimer() + 4000 end -- Verificăm coșuri de gunoi în jur for _, model in pairs(TrashCan_Models) do local trash = GetClosestObjectOfType(coords.x, coords.y, coords.z, 2.0, model, false, false, false) if trash ~= 0 then showTrashOptions = true trashOptionsTimeout = GetGameTimer() + 4000 break end end -- Verificăm bănci/scaune în jur for _, model in pairs(Bench_Models) do local bench = GetClosestObjectOfType(coords.x, coords.y, coords.z, 1.8, model, false, false, false) if bench ~= 0 then showBenchOptions = true benchOptionsTimeout = GetGameTimer() + 4000 break end end -- Verificăm NPC-uri în jur local nearbyNpc = findNearbyNPC(GetEntityCoords(playerPed)) if nearbyNpc then showNpcOptions = true npcOptionsTimeout = GetGameTimer() + 4000 end end end -- Timere pentru ascundere meniuri if showVehicleExtraOptions and GetGameTimer() > vehicleOptionsTimeout then showVehicleExtraOptions = false end if showInsideVehicleOptions and GetGameTimer() > insideVehicleOptionsTimeout then showInsideVehicleOptions = false end if showPlayerExtraOptions and GetGameTimer() > playerOptionsTimeout then showPlayerExtraOptions = false end if showTrashOptions and GetGameTimer() > trashOptionsTimeout then showTrashOptions = false end if showBenchOptions and GetGameTimer() > benchOptionsTimeout then showBenchOptions = false end if showNpcOptions and GetGameTimer() > npcOptionsTimeout then showNpcOptions = false end end end) -- ============================================================ -- THREAD: NPC urmărire (pe jos + în mașină) -- ============================================================ Citizen.CreateThread(function() while true do Citizen.Wait(500) if followNPC ~= nil and DoesEntityExist(followNPC) then local playerPed = PlayerPedId() -- Blochează mereu evenimentele AI ca să nu fugă SetBlockingOfNonTemporaryEvents(followNPC, true) SetPedFleeAttributes(followNPC, 0, false) if IsPedInAnyVehicle(playerPed, false) then local vehicle = GetVehiclePedIsIn(playerPed, false) if not IsPedInVehicle(followNPC, vehicle, false) then -- Forțează direct NPC-ul în mașină (fără animație, fără să fugă) local seatIndex = -1 for seat = 0, GetVehicleMaxNumberOfPassengers(vehicle) - 1 do if IsVehicleSeatFree(vehicle, seat) then seatIndex = seat break end end if seatIndex >= 0 then SetPedIntoVehicle(followNPC, vehicle, seatIndex) end end else -- Jucătorul nu e în mașină → scoate NPC-ul dacă e în mașină if IsPedInAnyVehicle(followNPC, false) then local npcVeh = GetVehiclePedIsIn(followNPC, false) TaskLeaveVehicle(followNPC, npcVeh, 0) Citizen.Wait(1000) else TaskGoToEntity(followNPC, playerPed, -1, 1.5, 1.0, 0, 0) end end end end end) -- ============================================================ -- CARRY: Event-uri client pentru sincronizare -- ============================================================ -- Eu sunt cel CĂRAT — mă atașez de cel care mă cară RegisterNetEvent('carry:attachToCarrier') AddEventHandler('carry:attachToCarrier', function(carrierServerId) local carrierPed = GetPlayerPed(GetPlayerFromServerId(carrierServerId)) if not DoesEntityExist(carrierPed) then return end loadAnimDict("nm") AttachEntityToEntity(PlayerPedId(), carrierPed, 0, 0.27, 0.15, 0.63, 0.5, 0.5, 180.0, false, false, false, false, 2, false) TaskPlayAnim(PlayerPedId(), "nm", "firemans_carry", 8.0, -8.0, 100000, 33, 0, false, false, false) isCarrying = true carriedPlayer = GetPlayerFromServerId(carrierServerId) end) -- Eu sunt cel CĂRAT — mă detașez RegisterNetEvent('carry:detach') AddEventHandler('carry:detach', function() isCarrying = false carriedPlayer = nil ClearPedSecondaryTask(PlayerPedId()) DetachEntity(PlayerPedId(), true, false) end) -- ============================================================ -- THREAD: Carry — menține animația + reaplică dacă se pierde -- ============================================================ Citizen.CreateThread(function() while true do if isCarrying and carriedPlayer then local myPed = PlayerPedId() -- Dacă EU car (am animația de carrying), menține animația if IsEntityPlayingAnim(myPed, "missfinale_c2mcs_1", "fin_c2_mcs_1_camman", 3) then -- OK, animația rulează elseif not IsEntityAttached(myPed) then -- Sunt cel care cară, reaplică animația dacă s-a pierdut if not IsPedInAnyVehicle(myPed, false) then loadAnimDict("missfinale_c2mcs_1") TaskPlayAnim(myPed, "missfinale_c2mcs_1", "fin_c2_mcs_1_camman", 8.0, -8.0, 100000, 49, 0, false, false, false) end end -- Drop dacă intru în mașină — pun victima pe locul din spate if IsPedInAnyVehicle(myPed, false) and not IsEntityAttached(myPed) then local vehicle = GetVehiclePedIsIn(myPed, false) local targetPed = GetPlayerPed(carriedPlayer) if DoesEntityExist(targetPed) then -- Detach victima TriggerServerEvent('carry:stop', GetPlayerServerId(carriedPlayer)) -- Pune victima în loc liber din spate Citizen.Wait(500) if DoesEntityExist(targetPed) and DoesEntityExist(vehicle) then for seat = 0, GetVehicleMaxNumberOfPassengers(vehicle) - 1 do if IsVehicleSeatFree(vehicle, seat) then SetPedIntoVehicle(targetPed, vehicle, seat) break end end end end ClearPedSecondaryTask(myPed) isCarrying = false carriedPlayer = nil end -- Drop dacă target-ul nu mai există if carriedPlayer and not DoesEntityExist(GetPlayerPed(carriedPlayer)) then ClearPedSecondaryTask(myPed) isCarrying = false carriedPlayer = nil end Citizen.Wait(500) else Citizen.Wait(1000) end end end) -- ============================================================ -- THREAD PRINCIPAL: Detecție + display NUI -- ============================================================ Citizen.CreateThread(function() while true do local sleep = 500 local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) local foundPoint = false local displayData = {} if isRepairing then CloseUI() Citizen.Wait(1000) goto continue_loop end -- 2. Puncte statice if not foundPoint then for _, point in pairs(InteractionPoints) do if #(coords - point.coords) < 2.5 then displayData = { target = point.coords, label = point.label, key = "E", icon = point.icon } foundPoint = true break end end end -- 3. Vehicule if not foundPoint then local inVehicle = IsPedInAnyVehicle(playerPed, false) -- Verifică fuel service când ești în vehicul lângă pompă if inVehicle and not isReceivingService then local currentVehicle = GetVehiclePedIsIn(playerPed, false) local vehCoords = GetEntityCoords(currentVehicle) local closestPump, pumpDist = GetClosestGasPump(vehCoords) -- Dacă ești lângă pompă și rezervorul nu e plin if closestPump and pumpDist < 5.0 and GetVehicleFuelLevel(currentVehicle) < 95.0 then local options = {{label = "Solicită alimentare", key = "E", icon = "fa-solid fa-gas-pump"}} displayData = { target = vehCoords + vector3(0, 0, 1.0), options = options, vehicle = currentVehicle, isFuelService = true, pumpCoords = closestPump } foundPoint = true end end if not foundPoint and inVehicle and showInsideVehicleOptions then local currentVehicle = GetVehiclePedIsIn(playerPed, false) local options = { {label = "Șofer", key = "G", icon = "fa-solid fa-car"}, {label = "Dreapta", key = "H", icon = "fa-solid fa-chair"}, {label = "Spate", key = "X", icon = "fa-solid fa-chair"} } displayData = { target = coords + vector3(0, 0, 1.0), options = options, vehicle = currentVehicle, isInsideVehicle = true } foundPoint = true elseif not inVehicle then -- Verifică vehicule local vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 3.5, 0, 71) if vehicle ~= 0 then local vCoords = GetEntityCoords(vehicle) local options = {} if showVehicleExtraOptions then table.insert(options, {label = "Deschide ușa", key = "G", icon = "fa-solid fa-door-open"}) table.insert(options, {label = "Deschide capota", key = "H", icon = "fa-solid fa-car-burst"}) end local isHoodOpen = GetVehicleDoorAngleRatio(vehicle, 4) > 0.1 local isNearEngine = false if isHoodOpen then local engineBone = GetEntityBoneIndexByName(vehicle, "engine") local enginePos = vCoords if engineBone ~= -1 then enginePos = GetWorldPositionOfEntityBone(vehicle, engineBone) else enginePos = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, 2.0, 0.0) end if #(coords - enginePos) < 1.5 then isNearEngine = true table.insert(options, {label = "Repară mașina", key = "X", icon = "fa-solid fa-wrench"}) end end displayData = { target = vCoords + vector3(0, 0, 1.0), options = options, vehicle = vehicle, isVehicle = true, isNearEngine = isNearEngine } foundPoint = true end end end -- 4. JUCĂTORI (DUEL / JEFUIRE / CARRY) - Doar cand dai SCROLL if not foundPoint and not isInGame and not isRepairing and not isRobbing and showPlayerExtraOptions then local closestPlayer, closestDistance = GetClosestPlayerIncludingDead() if closestPlayer ~= -1 and closestDistance < 2.0 then local targetPed = GetPlayerPed(closestPlayer) local targetCoords = GetEntityCoords(targetPed) local targetServerId = GetPlayerServerId(closestPlayer) local isTargetDead = IsEntityDead(targetPed) or IsPedFatallyInjured(targetPed) or Player(targetServerId).state.isDead == true if isTargetDead then -- MORT → E Jefuiește + Q Cară local options = { {label = "Jefuiește", key = "E", icon = "fa-solid fa-mask"}, {label = "Cară", key = "Q", icon = "fa-solid fa-hands-holding"} } displayData = { target = targetCoords + vector3(0, 0, 0.5), options = options, isRobDead = true, isPlayerMenu = true, robPlayer = closestPlayer, targetPlayer = targetServerId } foundPoint = true else -- VIU → G Duel + Q Cară + H Grupa local options = { {label = "Provocare Duel", key = "G", icon = "fa-solid fa-crosshairs"}, {label = "Cară", key = "Q", icon = "fa-solid fa-hands-holding"}, {label = "Grupa", key = "H", icon = "fa-solid fa-users-line"} } displayData = { target = targetCoords + vector3(0, 0, 1.0), options = options, isPlayer = true, isPlayerMenu = true, targetPlayer = targetServerId, carryTarget = closestPlayer } foundPoint = true end end end -- 5. NPC Minigame + Vânzare (doar cu SCROLL) if not foundPoint and not isInGame and not isSelling and showNpcOptions then local nearbyNpc = findNearbyNPC(coords) if nearbyNpc then local npcData = getNpcGameType(nearbyNpc) local npcC = GetEntityCoords(nearbyNpc) local maxedOut = npcData.count >= MAX_PLAYS local alreadySold = soldNPCs[nearbyNpc] == true local npcOptions = {} if maxedOut then npcOptions[#npcOptions + 1] = { key = "G", icon = "fa-solid fa-person-walking-arrow-right", label = "Du-te la altcineva!" } else npcOptions[#npcOptions + 1] = { key = "G", icon = "fa-solid fa-dice", label = "Interacționează" } end if alreadySold then npcOptions[#npcOptions + 1] = { key = "X", icon = "fa-solid fa-ban", label = "Deja vândut!" } npcOptions[#npcOptions + 1] = { key = "H", icon = "fa-solid fa-ban", label = "Deja vândut!" } else npcOptions[#npcOptions + 1] = { key = "X", icon = "fa-solid fa-bottle-water", label = "Vinde Apă ($1000)" } npcOptions[#npcOptions + 1] = { key = "H", icon = "fa-solid fa-burger", label = "Vinde Burger ($1000)" } end displayData = { target = npcC + vector3(0, 0, 1.3), options = npcOptions, isNpc = true, npcHandle = nearbyNpc, maxedOut = maxedOut, gameType = npcData.type, alreadySold = alreadySold } foundPoint = true end end -- 6. Coșuri de gunoi (doar cu SCROLL) if not foundPoint and not isSearchingTrash and showTrashOptions then for _, model in pairs(TrashCan_Models) do local trash = GetClosestObjectOfType(coords.x, coords.y, coords.z, 2.0, model, false, false, false) if trash ~= 0 then local trashCoords = GetEntityCoords(trash) displayData = { target = trashCoords + vector3(0, 0, 1.0), label = "Caută în gunoi", key = "F", icon = "fa-solid fa-dumpster", isTrashCan = true, trashEntity = trash } foundPoint = true break end end end -- 7. Bănci / Scaune (doar cu SCROLL) if not foundPoint and showBenchOptions then for _, model in pairs(Bench_Models) do local bench = GetClosestObjectOfType(coords.x, coords.y, coords.z, 1.8, model, false, false, false) if bench ~= 0 then local benchCoords = GetEntityCoords(bench) if isSitting and sitBenchEntity == bench then displayData = { target = benchCoords + vector3(0, 0, 1.0), label = "Ridică-te", key = "G", icon = "fa-solid fa-person-walking", isBench = true, benchEntity = bench } else displayData = { target = benchCoords + vector3(0, 0, 1.0), label = "Așează-te", key = "G", icon = "fa-solid fa-chair", isBench = true, benchEntity = bench } end foundPoint = true break end end end -- ---- Afișare NUI ---- if foundPoint then sleep = 0 local onScreen, x, y = GetScreenCoordFromWorldCoord( displayData.target.x, displayData.target.y, displayData.target.z) if onScreen then SendNUIMessage({ action = "updateClosestTarget", display = true, entity = {x = x, y = y, data = displayData} }) -- Logica de butoane if displayData.isFuelService then -- E pentru a solicita fuel service if IsControlJustPressed(0, 38) then if not isReceivingService then StartFuelService(displayData.vehicle, displayData.pumpCoords) end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 38) then SendNUIMessage({action = "buttonReset"}) end elseif displayData.isPlayerMenu then -- G (47) = Provocare Duel (doar viu) if displayData.isPlayer and IsControlJustPressed(0, 47) then if not inDuel then TriggerServerEvent('duel:request', displayData.targetPlayer) ESX.ShowNotification("~y~Ai trimis o cerere de duel!") showPlayerExtraOptions = false else ESX.ShowNotification("~r~Ești deja într-un duel!") end SendNUIMessage({action = "buttonClick"}) elseif displayData.isPlayer and IsControlJustReleased(0, 47) then SendNUIMessage({action = "buttonReset"}) end -- E (38) = Jefuiește (doar mort) if displayData.isRobDead and IsControlJustPressed(0, 38) then if not isRobbing then isRobbing = true showPlayerExtraOptions = false local robTarget = displayData.robPlayer Citizen.CreateThread(function() local robPed = PlayerPedId() loadAnimDict("mini@repair") TaskPlayAnim(robPed, "mini@repair", "fixing_a_ped", 1.0, -1.0, -1, 49, 0, false, false, false) exports.ox_inventory:openInventory('player', GetPlayerServerId(robTarget)) Citizen.Wait(3000) if DoesEntityExist(robPed) then ClearPedTasks(robPed) ClearPedSecondaryTask(robPed) end isRobbing = false end) end SendNUIMessage({action = "buttonClick"}) elseif displayData.isRobDead and IsControlJustReleased(0, 38) then SendNUIMessage({action = "buttonReset"}) end -- Q (44) = Cară jucător (mort sau viu) if IsControlJustPressed(0, 44) then local carryTarget = displayData.robPlayer or displayData.carryTarget if carryTarget then if isCarrying and carriedPlayer then -- Lasă jos isCarrying = false ClearPedSecondaryTask(PlayerPedId()) TriggerServerEvent('carry:stop', GetPlayerServerId(carriedPlayer)) carriedPlayer = nil ESX.ShowNotification("~y~Ai lăsat jucătorul jos.") else -- Ridică isCarrying = true carriedPlayer = carryTarget showPlayerExtraOptions = false local targetServerId = GetPlayerServerId(carryTarget) -- Animație pe mine (cel care cară) loadAnimDict("missfinale_c2mcs_1") TaskPlayAnim(PlayerPedId(), "missfinale_c2mcs_1", "fin_c2_mcs_1_camman", 8.0, -8.0, -1, 49, 0, false, false, false) -- Trimite la server să sincronizeze attach pe clientul victimei TriggerServerEvent('carry:start', targetServerId) ESX.ShowNotification("~g~Cari jucătorul. Scroll + Q pentru a-l lăsa jos.") end end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 44) then SendNUIMessage({action = "buttonReset"}) end -- H (74) = Grupa (doar jucator viu) if displayData.isPlayer and IsControlJustPressed(0, 74) then if displayData.targetPlayer then TriggerServerEvent('grupa:invite', displayData.targetPlayer) showPlayerExtraOptions = false end SendNUIMessage({action = "buttonClick"}) elseif displayData.isPlayer and IsControlJustReleased(0, 74) then SendNUIMessage({action = "buttonReset"}) end elseif displayData.isVehicle then if IsControlJustPressed(0, 23) then TaskEnterVehicle(playerPed, displayData.vehicle, -1, -1, 1.0, 1, 0) SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 23) then SendNUIMessage({action = "buttonReset"}) end if showVehicleExtraOptions and IsControlJustPressed(0, 47) then local door = GetClosestVehicleDoor(displayData.vehicle, coords) if GetVehicleDoorAngleRatio(displayData.vehicle, door) < 0.1 then SetVehicleDoorOpen(displayData.vehicle, door, false, false) else SetVehicleDoorShut(displayData.vehicle, door, false) end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 47) then SendNUIMessage({action = "buttonReset"}) end if showVehicleExtraOptions and IsControlJustPressed(0, 74) then if GetVehicleDoorAngleRatio(displayData.vehicle, 4) < 0.1 then SetVehicleDoorOpen(displayData.vehicle, 4, false, false) else SetVehicleDoorShut(displayData.vehicle, 4, false) end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 74) then SendNUIMessage({action = "buttonReset"}) end if displayData.isNearEngine and IsControlJustPressed(0, 73) then if not isRepairing then isRepairing = true Citizen.CreateThread(function() TaskTurnPedToFaceEntity(playerPed, displayData.vehicle, 1000) Citizen.Wait(1000) loadAnimDict("mini@repair") TaskPlayAnim(playerPed, "mini@repair", "fixing_a_ped", 8.0, -8.0, -1, 1, 0, false, false, false) ESX.ShowNotification("~y~Repari mașina...") Citizen.Wait(10000) ClearPedTasks(playerPed) SetVehicleFixed(displayData.vehicle) SetVehicleDeformationFixed(displayData.vehicle) ESX.ShowNotification("~g~Mașină reparată cu succes!") isRepairing = false end) end SendNUIMessage({action = "buttonClick"}) elseif displayData.isNearEngine and IsControlJustReleased(0, 73) then SendNUIMessage({action = "buttonReset"}) end elseif displayData.isInsideVehicle then if IsControlJustPressed(0, 47) then if IsVehicleSeatFree(displayData.vehicle, -1) then SetPedIntoVehicle(playerPed, displayData.vehicle, -1) else ESX.ShowNotification("~r~Locul șoferului este ocupat!") end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 47) then SendNUIMessage({action = "buttonReset"}) end if IsControlJustPressed(0, 74) then if IsVehicleSeatFree(displayData.vehicle, 0) then SetPedIntoVehicle(playerPed, displayData.vehicle, 0) else ESX.ShowNotification("~r~Acest loc este ocupat!") end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 74) then SendNUIMessage({action = "buttonReset"}) end if IsControlJustPressed(0, 73) then if IsVehicleSeatFree(displayData.vehicle, 1) then SetPedIntoVehicle(playerPed, displayData.vehicle, 1) elseif IsVehicleSeatFree(displayData.vehicle, 2) then SetPedIntoVehicle(playerPed, displayData.vehicle, 2) else ESX.ShowNotification("~r~Locurile din spate sunt ocupate sau mașina are doar 2 uși!") end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 73) then SendNUIMessage({action = "buttonReset"}) end elseif displayData.isNpc then -- G (47) = Interacționează / minigame if IsControlJustPressed(0, 47) then if displayData.maxedOut then ESX.ShowNotification("~y~Ai jucat deja de " .. MAX_PLAYS .. " ori cu acest NPC! Mergi la altcineva.") elseif not isInGame then activeNpc = displayData.npcHandle isInGame = true FreezeEntityPosition(activeNpc, true) TaskStandStill(activeNpc, -1) SetNuiFocus(true, true) local nd = getNpcGameType(activeNpc) SendNUIMessage({ action = "startNpcGame", gameType = nd.type }) end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 47) then SendNUIMessage({action = "buttonReset"}) end -- X (73) = Vinde Apă ($1000) if IsControlJustPressed(0, 73) then local npc = displayData.npcHandle if displayData.alreadySold then ESX.ShowNotification("~r~Ai vândut deja ceva acestui NPC!") elseif not isSelling then isSelling = true showNpcOptions = false soldNPCs[npc] = true TriggerServerEvent('npc:sellItem', 'water') Citizen.SetTimeout(2000, function() isSelling = false end) end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 73) then SendNUIMessage({action = "buttonReset"}) end -- H (74) = Vinde Burger ($1000) if IsControlJustPressed(0, 74) then local npc = displayData.npcHandle if displayData.alreadySold then ESX.ShowNotification("~r~Ai vândut deja ceva acestui NPC!") elseif not isSelling then isSelling = true showNpcOptions = false soldNPCs[npc] = true TriggerServerEvent('npc:sellItem', 'burger') Citizen.SetTimeout(2000, function() isSelling = false end) end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 74) then SendNUIMessage({action = "buttonReset"}) end elseif displayData.isTrashCan then -- F (control 23) pentru a căuta în gunoi if IsControlJustPressed(0, 23) then if not isSearchingTrash then isSearchingTrash = true showTrashOptions = false Citizen.CreateThread(function() local searchPed = PlayerPedId() -- Întoarce-te spre coșul de gunoi if displayData.trashEntity and DoesEntityExist(displayData.trashEntity) then TaskTurnPedToFaceEntity(searchPed, displayData.trashEntity, 1000) Citizen.Wait(1000) end -- Încarcă animația (același dict ca mechanic-ul) loadAnimDict("mini@repair") -- Variabile pentru control local searchComplete = false local searchCancelled = false -- Pornește animația EXACT când pornește progress bar-ul TaskPlayAnim(searchPed, "mini@repair", "fixing_a_ped", 8.0, -8.0, -1, 1, 0, false, false, false) -- Progress bar cu durata de 5 secunde (jumătate din 10) exports['ZSX_UIV2']:ProgressBar( 'fas fa-dumpster', -- icon 'Cauți prin gunoi...', -- text 5000, -- duration (5 secunde - JUMĂTATE) function() -- onComplete searchComplete = true -- Oprește animația INSTANT if DoesEntityExist(searchPed) then ClearPedTasks(searchPed) end -- Oferă item-ul INSTANT după închiderea progress bar-ului local items = {"bread", "water"} local chosenItem = items[math.random(#items)] TriggerServerEvent('trashcan:giveItem', chosenItem) if chosenItem == "bread" then ESX.ShowNotification("~g~Ai găsit pâine!") else ESX.ShowNotification("~b~Ai găsit apă!") end isSearchingTrash = false end, function() -- onCancel searchCancelled = true -- Oprește animația INSTANT if DoesEntityExist(searchPed) then ClearPedTasks(searchPed) end ESX.ShowNotification("~r~Ai oprit căutarea!") isSearchingTrash = false end, true, -- canCancel true, -- disableControls nil, -- anim nil, -- prop1 nil -- prop2 ) end) end SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 23) then SendNUIMessage({action = "buttonReset"}) end elseif displayData.isBench then -- G (control 47) pentru a te așeza / ridica if IsControlJustPressed(0, 47) then if isSitting and sitBenchEntity == displayData.benchEntity then -- Ridică-te ClearPedTasksImmediately(playerPed) isSitting = false sitBenchEntity = nil ESX.ShowNotification("~y~Te-ai ridicat.") else -- Așezează-te if displayData.benchEntity and DoesEntityExist(displayData.benchEntity) then local benchCoords = GetEntityCoords(displayData.benchEntity) local benchHeading = GetEntityHeading(displayData.benchEntity) -- TaskStartScenarioAtPosition cu teleportToScenario=true: -- GTA pozitioneaza singur personajul exact ca NPC-urile pe banca -- Nu mai calculam Z manual - scenariul stie inaltimea scaunului TaskStartScenarioAtPosition( playerPed, "PROP_HUMAN_SEAT_BENCH", benchCoords.x + BENCH_OFFSET_X, benchCoords.y + BENCH_OFFSET_Y, benchCoords.z + BENCH_OFFSET_Z, benchHeading + 180.0, -1, -- durata (-1 = indefinit) true, -- sittingScenario true -- teleportToScenario (GTA face snap automat) ) isSitting = true sitBenchEntity = displayData.benchEntity ESX.ShowNotification("~g~Te-ai așezat. Scroll + [G] pentru a te ridica.") end end showBenchOptions = false SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, 47) then SendNUIMessage({action = "buttonReset"}) end else local keyHandle = (displayData.key == "F") and 23 or 38 if IsControlJustPressed(0, keyHandle) then SendNUIMessage({action = "buttonClick"}) elseif IsControlJustReleased(0, keyHandle) then SendNUIMessage({action = "buttonReset"}) end end else CloseUI() end else CloseUI() end ::continue_loop:: Citizen.Wait(sleep) end end) function CloseUI() SendNUIMessage({action = "updateClosestTarget", display = false}) end -- ============================================================ -- SISTEM GRUPA — CLIENT (Blip-uri, UI, Comenzi) -- ============================================================ -- Primeste sync de la server RegisterNetEvent('grupa:sync') AddEventHandler('grupa:sync', function(data) myGroupData = data UpdateGroupBlips() -- Update NUI UI if showGroupUI then SendNUIMessage({ action = 'updateGroupUI', data = myGroupData }) end end) -- Scos din grupa RegisterNetEvent('grupa:removed') AddEventHandler('grupa:removed', function() myGroupData = nil ClearAllGroupBlips() showGroupUI = false SendNUIMessage({ action = 'hideGroupUI' }) end) -- Primeste invitatie de grupa RegisterNetEvent('grupa:receiveInvite') AddEventHandler('grupa:receiveInvite', function(fromId, fromName) -- Ascunde orice invitatie anterioara SendNUIMessage({ action = 'hideGroupInvite' }) pendingGroupInvite = { from = fromId, name = fromName } drawGroupInvite = true -- Arata invitatia cu numele real local displayName = fromName or ("ID " .. tostring(fromId)) SendNUIMessage({ action = 'showGroupInvite', name = displayName }) Citizen.CreateThread(function() local timer = 1000 -- 10 secunde local thisInviteFrom = fromId while timer > 0 and pendingGroupInvite and pendingGroupInvite.from == thisInviteFrom do Citizen.Wait(10) if IsControlJustPressed(0, 246) then -- Y TriggerServerEvent('grupa:acceptInvite', thisInviteFrom) pendingGroupInvite = nil drawGroupInvite = false SendNUIMessage({ action = 'hideGroupInvite' }) return end timer = timer - 1 end -- Timpul a expirat SAU alta invitatie a venit if pendingGroupInvite and pendingGroupInvite.from == thisInviteFrom then ESX.ShowNotification("~y~Invitația de grupă a expirat.") pendingGroupInvite = nil drawGroupInvite = false end SendNUIMessage({ action = 'hideGroupInvite' }) end) end) -- Blip-uri pentru membrii grupei function UpdateGroupBlips() ClearAllGroupBlips() if not myGroupData or not myGroupData.members then return end local myId = GetPlayerServerId(PlayerId()) for _, member in ipairs(myGroupData.members) do if member.id ~= myId then local targetPlayer = GetPlayerFromServerId(member.id) if targetPlayer ~= -1 then local targetPed = GetPlayerPed(targetPlayer) if DoesEntityExist(targetPed) then local blip = AddBlipForEntity(targetPed) local isDead = IsEntityDead(targetPed) or IsPedFatallyInjured(targetPed) if isDead then SetBlipSprite(blip, 310) -- X cross SetBlipColour(blip, 1) -- Rosu else SetBlipSprite(blip, 1) -- Punct simplu SetBlipColour(blip, 0) -- Alb end SetBlipScale(blip, 0.8) SetBlipDisplay(blip, 2) SetBlipShrink(blip, true) BeginTextCommandSetBlipName("STRING") AddTextComponentSubstringPlayerName("Grupa — " .. member.name) EndTextCommandSetBlipName(blip) groupBlips[member.id] = blip end end end end end function ClearAllGroupBlips() for id, blip in pairs(groupBlips) do if DoesBlipExist(blip) then RemoveBlip(blip) end end groupBlips = {} end -- Thread: Update blip-uri grupa (stare mort/viu + pozitie) Citizen.CreateThread(function() while true do if myGroupData and myGroupData.members and #myGroupData.members > 1 then local myId = GetPlayerServerId(PlayerId()) for _, member in ipairs(myGroupData.members) do if member.id ~= myId then local targetPlayer = GetPlayerFromServerId(member.id) local blip = groupBlips[member.id] if targetPlayer ~= -1 and blip and DoesBlipExist(blip) then local targetPed = GetPlayerPed(targetPlayer) if DoesEntityExist(targetPed) then local isDead = IsEntityDead(targetPed) or IsPedFatallyInjured(targetPed) if isDead then SetBlipSprite(blip, 310) SetBlipColour(blip, 1) else SetBlipSprite(blip, 1) SetBlipColour(blip, 0) end end elseif targetPlayer == -1 and blip and DoesBlipExist(blip) then -- Jucatorul nu mai e in range, blip offline SetBlipSprite(blip, 310) SetBlipColour(blip, 1) end end end Citizen.Wait(2000) else Citizen.Wait(5000) end end end) -- /mgrupa — Arată UI-ul grupei pe ecran (5 secunde apoi dispare) RegisterCommand('mgrupa', function(source, args) if not myGroupData then TriggerServerEvent('grupa:requestSync') Citizen.Wait(500) end if not myGroupData then ESX.ShowNotification("~r~Nu ești într-o grupă!") return end showGroupUI = true SendNUIMessage({ action = 'showGroupUI', data = myGroupData }) -- Auto-hide după 5 secunde Citizen.CreateThread(function() Citizen.Wait(5000) if showGroupUI then showGroupUI = false SendNUIMessage({ action = 'hideGroupUI' }) end end) end, false) -- /pgrup — Paraseste grupa RegisterCommand('pgrup', function(source, args) TriggerServerEvent('grupa:leave') end, false) -- /kick(id) — Liderul scoate un jucator RegisterCommand('kick', function(source, args) if #args < 1 then ESX.ShowNotification("~r~Folosește: /kick [id jucător]") return end local targetId = tonumber(args[1]) if not targetId then ESX.ShowNotification("~r~ID invalid! Folosește: /kick [id]") return end TriggerServerEvent('grupa:kick', targetId) end, false) -- ============================================================ -- FUEL SYSTEM - NPC SERVICE STATION (ZSX Style) -- ============================================================ -- NPC care face service local serviceNPC = nil local npcPump = nil local isReceivingService = false local serviceVehicle = nil function GetClosestGasPump(coords) local closestDist = 5.0 local closestPump = nil for _, pumpCoords in ipairs(GasStationPumps) do local dist = #(coords - pumpCoords) if dist < closestDist then closestDist = dist closestPump = pumpCoords end end return closestPump, closestDist end function SpawnServiceNPC(pumpCoords) local npcModel = GetHashKey("a_m_m_genfat_01") RequestModel(npcModel) while not HasModelLoaded(npcModel) do Citizen.Wait(1) end -- Spawn lângă tonomat serviceNPC = CreatePed(4, npcModel, pumpCoords.x, pumpCoords.y, pumpCoords.z, 0.0, false, true) SetEntityAsMissionEntity(serviceNPC, true, true) SetBlockingOfNonTemporaryEvents(serviceNPC, true) SetPedFleeAttributes(serviceNPC, 0, false) SetPedCombatAttributes(serviceNPC, 17, true) return serviceNPC end function AttachPumpToNPC() if not serviceNPC then return end local boneIndex = GetPedBoneIndex(serviceNPC, 57005) local nozzleModel = GetHashKey("prop_cs_fuel_nozle") -- Pompă benzină RequestModel(nozzleModel) while not HasModelLoaded(nozzleModel) do Citizen.Wait(1) end npcPump = CreateObject(nozzleModel, 0, 0, 0, true, true, true) -- Attach offset pentru pompă AttachEntityToEntity(npcPump, serviceNPC, boneIndex, 0.11, 0.02, -0.01, -110.0, 0.0, 0.0, true, true, false, true, 1, true) end function DetachPumpFromNPC() if npcPump then DeleteObject(npcPump) npcPump = nil end end function CleanupServiceNPC() if serviceNPC then DetachPumpFromNPC() DeleteEntity(serviceNPC) serviceNPC = nil end isReceivingService = false serviceVehicle = nil end function StartFuelService(vehicle, pumpCoords) if isReceivingService then return end isReceivingService = true serviceVehicle = vehicle local ped = PlayerPedId() -- Freeze player în vehicul FreezeEntityPosition(vehicle, true) SetVehicleEngineOn(vehicle, false, true, true) -- Notificare ESX.ShowNotification("~y~Angajatul stației pregătește alimentarea...") Citizen.CreateThread(function() -- 1. Spawn NPC local npc = SpawnServiceNPC(pumpCoords) if not npc then ESX.ShowNotification("~r~Eroare la spawning NPC!") CleanupServiceNPC() FreezeEntityPosition(vehicle, false) return end Citizen.Wait(500) -- 2. NPC merge la pompă TaskGoToCoordAnyMeans(npc, pumpCoords.x, pumpCoords.y, pumpCoords.z, 1.0, 0, 0, 786603, 0xbf800000) -- Așteaptă să ajungă local timeout = 0 while #(GetEntityCoords(npc) - pumpCoords) > 1.5 and timeout < 100 do Citizen.Wait(100) timeout = timeout + 1 end if timeout >= 100 then ESX.ShowNotification("~r~NPC nu poate ajunge la pompă!") CleanupServiceNPC() FreezeEntityPosition(vehicle, false) return end Citizen.Wait(500) -- 3. Animație ridică pompa TaskTurnPedToFaceCoord(npc, pumpCoords.x, pumpCoords.y, pumpCoords.z, 1000) Citizen.Wait(1000) loadAnimDict("weapon@w_sp_jerrycan") TaskPlayAnim(npc, "weapon@w_sp_jerrycan", "fire", 8.0, 1.0, 2000, 1, 0, false, false, false) Citizen.Wait(1500) -- Attach pompă AttachPumpToNPC() ESX.ShowNotification("~g~Angajatul se îndreaptă către vehicul...") Citizen.Wait(500) -- 4. NPC merge la vehicul (ușa dreapta spate) local vehCoords = GetEntityCoords(vehicle) local vehHeading = GetEntityHeading(vehicle) -- Calculează poziția la ușa DREAPTA SPATE local offset = GetOffsetFromEntityInWorldCoords(vehicle, 1.5, -2.5, 0.0) TaskGoToCoordAnyMeans(npc, offset.x, offset.y, offset.z, 1.0, 0, 0, 786603, 0xbf800000) -- Așteaptă să ajungă timeout = 0 while #(GetEntityCoords(npc) - offset) > 2.0 and timeout < 100 do Citizen.Wait(100) timeout = timeout + 1 end if timeout >= 100 then ESX.ShowNotification("~r~NPC nu poate ajunge la vehicul!") CleanupServiceNPC() FreezeEntityPosition(vehicle, false) return end Citizen.Wait(500) -- 5. Se întoarce către vehicul și începe alimentarea TaskTurnPedToFaceEntity(npc, vehicle, 1000) Citizen.Wait(1000) loadAnimDict("timetable@gardener@filling_can") TaskPlayAnim(npc, "timetable@gardener@filling_can", "gar_ig_5_filling_can", 2.0, 2.0, -1, 1, 0, false, false, false) -- 6. Start ZSX Progress Bar local fuelComplete = false local fuelCancelled = false exports['ZSX_UIV2']:ProgressBar( 'fas fa-gas-pump', -- icon 'Alimentare în curs... $1000', -- text 30000, -- duration (30 secunde) function() -- onComplete fuelComplete = true end, function() -- onCancel fuelCancelled = true ClearPedTasks(npc) ESX.ShowNotification("~r~Alimentare anulată!") end, false, -- canCancel (locked) true, -- disableControls nil, -- anim nil, -- prop1 nil -- prop2 ) -- 7. Progress automat până la plin (~30 secunde) -- Bucla se oprește INSTANT când progress bar-ul se termină local currentFuel = GetVehicleFuelLevel(vehicle) local fuelTarget = 100.0 local fuelIncrement = 0.11 -- ~30 secunde local startTime = GetGameTimer() local duration = 30000 -- 30 secunde while GetGameTimer() - startTime < duration and isReceivingService and not fuelComplete and not fuelCancelled do Citizen.Wait(33) -- ~30fps currentFuel = currentFuel + fuelIncrement if currentFuel > fuelTarget then currentFuel = fuelTarget end SetVehicleFuelLevel(vehicle, currentFuel) end -- OPREȘTE animația NPC-ului INSTANT când s-a terminat progress bar-ul if DoesEntityExist(npc) then ClearPedTasks(npc) end -- Scurt delay pentru sincronizare cu callback Citizen.Wait(300) -- 8. Plată TriggerServerEvent('fuel:payForFuel', 1000) ESX.ShowNotification("~g~Alimentare completă! Plătit: $1000") Citizen.Wait(300) -- 9. NPC se întoarce la pompă TaskGoToCoordAnyMeans(npc, pumpCoords.x, pumpCoords.y, pumpCoords.z, 1.0, 0, 0, 786603, 0xbf800000) timeout = 0 while #(GetEntityCoords(npc) - pumpCoords) > 1.5 and timeout < 100 do Citizen.Wait(100) timeout = timeout + 1 end Citizen.Wait(500) -- 10. Pune pompa la loc TaskTurnPedToFaceCoord(npc, pumpCoords.x, pumpCoords.y, pumpCoords.z, 1000) Citizen.Wait(1000) loadAnimDict("weapon@w_sp_jerrycan") TaskPlayAnim(npc, "weapon@w_sp_jerrycan", "fire", 8.0, 1.0, 2000, 1, 0, false, false, false) Citizen.Wait(1500) DetachPumpFromNPC() ClearPedTasks(npc) -- 11. Cleanup final Citizen.Wait(1000) CleanupServiceNPC() -- Unfreeze vehicul FreezeEntityPosition(vehicle, false) -- Setează fuel-ul DEFINITIV la 100% DUPĂ deblocare SetVehicleFuelLevel(vehicle, 100.0) Citizen.Wait(100) SetVehicleFuelLevel(vehicle, 100.0) -- dublu set pentru siguranță ESX.ShowNotification("~g~Serviciu complet! O zi bună!") end) end