local cooldown = 0 local w = false local wait = 10000 -- Sistem grup jaf local grupActiv = {} local leaderJaf = nil local sesiuneInvitatie = nil local grupConfirmat = false local arestati = {} local stand = { {x = -627.23, y = -234.98, z = 38.52, h=50.97, ax= -626.61, ay= -235.62, v=1, broken = false}, {x = -627.67, y = -234.35, z = 38.52, h=232.01, ax= -628.19, ay= -233.54, v=2, broken = false}, {x = -626.53, y = -233.52, z = 38.52, h=232.01, ax= -627.11, ay= -232.84, v=3, broken = false}, {x = -626.09, y = -234.15, z = 38.52, h=45.05, ax= -625.50, ay= -234.92, v=4, broken = false}, {x = -625.27, y = -238.31, z = 38.52, h=232.01, ax= -625.81, ay= -237.49, v=5, broken = false}, {x = -626.26, y = -239.03, z = 38.52, h=232.01, ax= -626.82, ay= -238.41, v=6, broken = false}, {x = -623.98, y = -230.73, z = 38.52, h=309.21, ax= -624.84, ay= -231.33, v=7, broken = false}, {x = -622.50, y = -232.60, z = 38.52, h=309.21, ax= -623.55, ay= -233.28, v=8, broken = false}, {x = -619.87, y = -234.82, z = 38.05, h=232.01, ax= -620.37, ay= -234.0, v=9, broken = false}, {x = -618.79, y = -234.05, z = 38.05, h=232.01, ax= -619.40, ay= -233.13, v=10, broken = false}, {x = -617.11, y = -230.20, z = 38.05, h=299.83, ax= -617.99, ay= -230.73, v=11, broken = false}, {x = -617.87, y = -229.15, z = 38.05, h=299.83, ax= -618.85, ay= -229.86, v=12, broken = false}, {x = -619.16, y = -227.18, z = 38.05, h=299.83, ax= -620.07, ay= -227.90, v=13, broken = false}, {x = -619.99, y = -226.15, z = 38.05, h=299.83, ax= -620.84, ay= -226.85, v=14, broken = false}, {x = -625.25, y = -227.24, z = 38.05, h=48.83, ax= -624.74, ay= -228.36, v=15, broken = false}, {x = -624.27, y = -226.64, z = 38.05, h=48.83, ax= -623.71, ay= -227.53, v=16, broken = false}, {x = -623.58, y = -228.57, z = 38.05, h=232.01, ax= -624.35, ay= -227.72, v=17, broken = false}, {x = -621.48, y = -228.84, z = 38.05, h=128.82, ax= -620.57, ay= -228.39, v=18, broken = false}, {x = -620.17, y = -230.90, z = 38.05, h=128.82, ax= -619.41, ay= -230.07, v=19, broken = false}, {x = -620.60, y = -232.90, z = 38.05, h=35.14, ax= -619.87, ay= -233.88, v=20, broken = false} } ESX = nil TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) ----------------------------- -- Invita membri (leaderul e automat inclus) -- members = lista cu ID-urile celorlalti jucatori (1-3 persoane) -- total grup = leader + members = 2-4 persoane ----------------------------- RegisterServerEvent('av_vangelico:inviteMembers') AddEventHandler('av_vangelico:inviteMembers', function(members) local src = source if w then TriggerClientEvent('av_vangelico:notify_err', src, 'Jaful este in cooldown, asteptati!') return end if sesiuneInvitatie then TriggerClientEvent('av_vangelico:notify_err', src, 'Exista deja o sesiune de jaf in curs!') return end -- Valideaza membrii - exclud leaderul daca s-a bagat si pe el local validMembers = {} for _, id in ipairs(members) do local idNum = tonumber(id) if idNum and idNum ~= src and GetPlayerName(idNum) ~= nil then -- Evita duplicate local exists = false for _, v in ipairs(validMembers) do if v == idNum then exists = true break end end if not exists then table.insert(validMembers, idNum) end end end -- Validare: minim 1 alt jucator (total 2 cu leaderul), maxim 3 (total 4) if #validMembers < 1 then TriggerClientEvent('av_vangelico:notify_err', src, 'Trebuie sa inviti cel putin 1 jucator valid! (minim 2 total)') return end if #validMembers > 3 then TriggerClientEvent('av_vangelico:notify_err', src, 'Poti invita maxim 3 jucatori! (maxim 4 total cu tine)') return end local leaderName = GetPlayerName(src) sesiuneInvitatie = { leaderId = src, members = validMembers, -- doar ceilalti, nu leaderul acceptari = {}, refuzuri = {} } -- Trimite invitatii for _, id in ipairs(validMembers) do TriggerClientEvent('av_vangelico:primitiInvitatie', id, leaderName) end print('^3[AV-Vangelico]: ^2Leader ' .. leaderName .. ' (ID:' .. src .. ') a invitat ' .. #validMembers .. ' jucatori^0') end) ----------------------------- -- Raspuns invitatie ----------------------------- RegisterServerEvent('av_vangelico:raspunsInvitatie') AddEventHandler('av_vangelico:raspunsInvitatie', function(accepted) local src = source if not sesiuneInvitatie then return end -- Verifica ca src e in lista invitati local esteInvitat = false for _, id in ipairs(sesiuneInvitatie.members) do if id == src then esteInvitat = true break end end if not esteInvitat then return end -- Verifica sa nu fi raspuns deja for _, id in ipairs(sesiuneInvitatie.acceptari) do if id == src then return end end for _, id in ipairs(sesiuneInvitatie.refuzuri) do if id == src then return end end local playerName = GetPlayerName(src) if accepted then table.insert(sesiuneInvitatie.acceptari, src) TriggerClientEvent('av_vangelico:notify_accept', sesiuneInvitatie.leaderId, playerName) else table.insert(sesiuneInvitatie.refuzuri, src) TriggerClientEvent('av_vangelico:invitatieRespinsa', sesiuneInvitatie.leaderId, playerName) end local totalRaspunsuri = #sesiuneInvitatie.acceptari + #sesiuneInvitatie.refuzuri if totalRaspunsuri >= #sesiuneInvitatie.members then -- Toti au raspuns local leaderId = sesiuneInvitatie.leaderId if #sesiuneInvitatie.acceptari >= 1 then -- Grup valid: leader + cei care au acceptat local totiMembrii = {} table.insert(totiMembrii, leaderId) -- leaderul e primul for _, id in ipairs(sesiuneInvitatie.acceptari) do table.insert(totiMembrii, id) end grupActiv = {} arestati = {} for _, id in ipairs(totiMembrii) do grupActiv[id] = true end leaderJaf = leaderId grupConfirmat = false -- Trimite grupFormat la toti membrii for _, id in ipairs(totiMembrii) do local isLeader = (id == leaderId) TriggerClientEvent('av_vangelico:grupFormat', id, totiMembrii, isLeader) end print('^3[AV-Vangelico]: ^2Grup format: ' .. #totiMembrii .. ' membri (leader ID:' .. leaderId .. ')^0') else TriggerClientEvent('av_vangelico:notify_err', leaderId, 'Nimeni nu a acceptat invitatia. Jaful a fost anulat.') end sesiuneInvitatie = nil end end) ----------------------------- -- Leader confirma jaful ----------------------------- RegisterServerEvent('av_vangelico:confirmaJaf') AddEventHandler('av_vangelico:confirmaJaf', function() local src = source if src ~= leaderJaf then return end grupConfirmat = true for id, _ in pairs(grupActiv) do TriggerClientEvent('av_vangelico:jafulIncepe', id) end print('^3[AV-Vangelico]: ^2Jaf confirmat de leader ID:' .. src .. '^0') end) ----------------------------- -- Bomba plantata -> wanted + spargere la toti ----------------------------- RegisterServerEvent('av_vangelico:bombaPlantata') AddEventHandler('av_vangelico:bombaPlantata', function() local src = source print('^3[AV-Vangelico]: ^2Bomba plantata de ID:' .. src .. '^0') for id, _ in pairs(grupActiv) do if not arestati[id] then TriggerClientEvent('av_vangelico:setWanted', id, Config.WantedLevel) TriggerClientEvent('av_vangelico:startSpargere', id) end end -- Porneste timerul server-side TriggerEvent('av_vangelico:pornesteTimer') end) ----------------------------- -- Jucator arestat ----------------------------- RegisterServerEvent('av_vangelico:jucatorArestat') AddEventHandler('av_vangelico:jucatorArestat', function() local src = source arestati[src] = true local name = GetPlayerName(src) print('^3[AV-Vangelico]: ^1' .. name .. ' (ID:' .. src .. ') a fost arestat^0') end) ----------------------------- -- Notificare accept membru catre leader ----------------------------- RegisterNetEvent('av_vangelico:notify_accept') -- folosit prin TriggerClientEvent ----------------------------- -- Smash counter ----------------------------- RegisterServerEvent('av_vangelico:smash_counter') AddEventHandler('av_vangelico:smash_counter', function(x, y, z, status) for i = 1, #stand do if stand[i].x == x and stand[i].y == y and stand[i].z == z then stand[i].broken = true end end TriggerClientEvent("av_vangelico:breakable_units", -1, stand) end) RegisterServerEvent('av_vangelico:effect') AddEventHandler('av_vangelico:effect', function(carga) w = true print('^3[AV-Vangelico]: ^2Cooldown started^0') cooldown = os.time() TriggerClientEvent('av_vangelico:bombaFx', -1, carga) TriggerClientEvent("av_vangelico:breakable_units", -1, stand) TriggerClientEvent("av_vangelico:statusUpdate", -1, false) end) -- Timer jaf activ (setat cand bomba e plantata) local jafTimerStart = nil local jafTimerActiv = false function tableLength(t) local count = 0 for _ in pairs(t) do count = count + 1 end return count end function getVitrineSparte() local sparte = 0 for i = 1, #stand do if stand[i].broken then sparte = sparte + 1 end end return sparte end -- Clientul anunta serverul ca bomba a fost plantata -> pornim timerul server-side RegisterServerEvent('av_vangelico:pornesteTimer') AddEventHandler('av_vangelico:pornesteTimer', function() if jafTimerActiv then return end jafTimerActiv = true jafTimerStart = os.time() local timpTotal = Config.RobTime * 60 -- in secunde print('^3[AV-Vangelico]: ^2Timer jaf pornit - ' .. timpTotal .. ' secunde^0') -- Thread timer server-side Citizen.CreateThread(function() while jafTimerActiv do Citizen.Wait(1000) local timpScurs = os.time() - jafTimerStart local timpRamas = timpTotal - timpScurs local vitrineSparte = getVitrineSparte() local vitrineTotale = #stand -- Trimite update HUD la toti membrii for id, _ in pairs(grupActiv) do TriggerClientEvent('av_vangelico:hudUpdate', id, timpRamas, vitrineSparte, vitrineTotale) end -- Verifica daca toate vitrinele au fost sparte -> SUCCES if vitrineSparte >= vitrineTotale then jafTimerActiv = false print('^3[AV-Vangelico]: ^2Toate vitrinele sparte - JAF REUSIT!^0') for id, _ in pairs(grupActiv) do TriggerClientEvent('av_vangelico:jafReusit', id) end TriggerClientEvent('av_vangelico:change_timer_status', -1, true, false) return end -- Verifica daca timpul a expirat -> FAIL if timpRamas <= 0 then jafTimerActiv = false print('^3[AV-Vangelico]: ^1Timer expirat cu ' .. vitrineSparte .. '/' .. vitrineTotale .. ' vitrine sparte - JAF PIERDUT^0') for id, _ in pairs(grupActiv) do TriggerClientEvent('av_vangelico:jafPierdut', id) end TriggerClientEvent('av_vangelico:change_timer_status', -1, true, false) return end end end) end) -- Pastram event-ul vechi pentru compatibilitate dar nu mai face nimic important RegisterServerEvent("av_vangelico:timer") AddEventHandler("av_vangelico:timer", function() -- nu mai e folosit pentru timer, serverul gestioneaza acum end) RegisterServerEvent('av_vangelico:gas') AddEventHandler('av_vangelico:gas', function() TriggerClientEvent('av_vangelico:smoke', -1) TriggerClientEvent('av_vangelico:notify', -1) end) RegisterServerEvent('av_vangelico:stand') AddEventHandler('av_vangelico:stand', function() local xPlayer = ESX.GetPlayerFromId(source) if Config.RewardMoney then xPlayer.addAccountMoney(Config.Account, Config.Money) xPlayer.showNotification(Config.Lang['stole'] .. '$' .. Config.Money) end if Config.RewardItem then for i = 1, #Config.Items do local item = Config.Items[i] xPlayer.addInventoryItem(item.item, item.amount) xPlayer.showNotification(Config.Lang['stole'] .. item.amount .. ' ' .. ESX.GetItemLabel(item.item)) end end end) ESX.RegisterServerCallback('av_vangelico:cooldown', function(source, cb) local xPlayers = ESX.GetPlayers() local cops = 0 for i = 1, #xPlayers do local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) if xPlayer.job.name == Config.PoliceJobName then cops = cops + 1 end end if cops >= Config.MinPolice and not w then cb(false) else cb(true) end end) ----------------------------- -- Thread cooldown ----------------------------- Citizen.CreateThread(function() while true do Citizen.Wait(wait) if w then wait = 1000 if (os.time() - cooldown) > Config.Cooldown and cooldown ~= 0 then print('^3[AV-Vangelico]: ^2Cooldown finished^0') w = false grupActiv = {} leaderJaf = nil grupConfirmat = false arestati = {} sesiuneInvitatie = nil for i = 1, #stand do stand[i].broken = false end jafTimerActiv = false jafTimerStart = nil TriggerClientEvent("av_vangelico:statusUpdate", -1, stand) TriggerClientEvent("av_vangelico:change_timer_status", -1, true, false) end else wait = 10000 end end end)