local ESX = exports["es_extended"]:getSharedObject() local lastLevel = nil local function playCelebration() SetNotificationTextEntry("STRING") AddTextComponentString("~g~playCelebration apelat!") DrawNotification(false, true) ExecuteCommand("e celebrate") end -- Comanda de TEST (Scrie /lvlup in chat) RegisterCommand('lvlup', function() TriggerEvent('esx_npc_xp:testAnimation') end) -- Handler pentru Test RegisterNetEvent('esx_npc_xp:testAnimation') AddEventHandler('esx_npc_xp:testAnimation', function() local mockLevel = 99 SendNUIMessage({ action = "show_lvlup", level = mockLevel }) ShakeGameplayCam('SMALL_EXPLOSION_SHAKE', 0.2) playCelebration() end) -- Integrare cu sistemul tau de XP RegisterNetEvent('esx_npc_xp:updateUI') AddEventHandler('esx_npc_xp:updateUI', function(xp, level) if lastLevel ~= nil and level > lastLevel then SendNUIMessage({ action = "show_lvlup", level = level }) ShakeGameplayCam('SMALL_EXPLOSION_SHAKE', 0.2) playCelebration() end lastLevel = level end) -- Detectare Kill (Curatat) Citizen.CreateThread(function() DecorRegister("counted", 2) while true do Citizen.Wait(1000) local playerPed = PlayerPedId() local handle, ped = FindFirstPed() local finished = false repeat if not IsPedAPlayer(ped) and IsPedDeadOrDying(ped) then if GetPedSourceOfDeath(ped) == playerPed and not DecorExistOn(ped, "counted") then DecorSetBool(ped, "counted", true) TriggerServerEvent('esx_npc_xp:addXP') end end finished, ped = FindNextPed(handle) until not finished EndFindPed(handle) end end)