local ESX = exports['es_extended']:getSharedObject() -- Funcție pentru a găsi cea mai apropiată mașină folosind ox_lib local function GetClosestVehicleToPlayer() local ped = PlayerPedId() local coords = GetEntityCoords(ped) if IsPedInAnyVehicle(ped, false) then return GetVehiclePedIsIn(ped, false) end -- Caută mașina pe o rază de 3.0 metri return lib.getClosestVehicle(coords, 3.0, false) end -- LOGICA PENTRU CHEIE RegisterNetEvent('gn-carkeys:useKey', function() local vehicle = GetClosestVehicleToPlayer() if not vehicle or not DoesEntityExist(vehicle) then return lib.notify({title = 'Eroare', description = 'Nu e nicio mașină în apropiere!', type = 'error'}) end local plate = GetVehicleNumberPlateText(vehicle) ESX.TriggerServerCallback('gn-carkeys:checkOwner', function(isOwner) if not isOwner then return lib.notify({title = 'Eroare', description = 'Nu ai cheile de la această mașină.', type = 'error'}) end local lockStatus = GetVehicleDoorLockStatus(vehicle) local ped = PlayerPedId() -- Animație cheie lib.requestAnimDict('anim@mp_player_intmenu@key_fob@') TaskPlayAnim(ped, 'anim@mp_player_intmenu@key_fob@', 'fob_click', 8.0, 8.0, -1, 48, 1, false, false, false) if lockStatus == 1 or lockStatus == 0 then -- Încuie SetVehicleDoorsLocked(vehicle, 2) lib.notify({title = 'Vehicul', description = 'Mașina a fost încuiată.', type = 'success'}) SetVehicleLights(vehicle, 2) Wait(200) SetVehicleLights(vehicle, 0) else -- Descuie SetVehicleDoorsLocked(vehicle, 1) lib.notify({title = 'Vehicul', description = 'Mașina a fost descuiată.', type = 'success'}) SetVehicleLights(vehicle, 2) Wait(200) SetVehicleLights(vehicle, 0) Wait(200) SetVehicleLights(vehicle, 2) Wait(200) SetVehicleLights(vehicle, 0) end end, plate) end) -- LOGICA PENTRU LOCKPICK RegisterNetEvent('gn-carkeys:useLockpick', function() local ped = PlayerPedId() local vehicle = GetClosestVehicleToPlayer() if not vehicle or not DoesEntityExist(vehicle) then return lib.notify({title = 'Eroare', description = 'Nu e nicio mașină în apropiere!', type = 'error'}) end local lockStatus = GetVehicleDoorLockStatus(vehicle) if lockStatus == 1 or lockStatus == 0 then return lib.notify({title = 'Eroare', description = 'Mașina este deja descuiată!', type = 'error'}) end -- Animație spargere lib.requestAnimDict('veh@break_in@0h@p_m_one@') TaskPlayAnim(ped, 'veh@break_in@0h@p_m_one@', 'low_force_entry_ds', 8.0, 8.0, -1, 16, 0, false, false, false) -- Minigame ox_lib (W, A, S, D) local success = lib.skillCheck({'easy', 'easy', 'medium', 'hard'}, {'w', 'a', 's', 'd'}) ClearPedTasks(ped) if success then -- A trecut minigame-ul, aplicăm șansa de 50% local chance = math.random(1, 100) if chance <= 50 then -- S-a schimbat de la 30 la 50 SetVehicleDoorsLocked(vehicle, 1) SetVehicleAlarm(vehicle, true) StartVehicleAlarm(vehicle) lib.notify({title = 'Succes', description = 'Ai reușit să spargi yala mașinii!', type = 'success'}) else lib.notify({title = 'Eșec', description = 'Yala a rămas blocată și lockpick-ul s-a rupt. (50% șansă ratată)', type = 'error'}) TriggerServerEvent('gn-carkeys:removeLockpick') end else -- A picat minigame-ul direct lib.notify({title = 'Eșec', description = 'Ai rupt lockpick-ul încercând să o spargi.', type = 'error'}) TriggerServerEvent('gn-carkeys:removeLockpick') end end) -- Prinde exportul de la ox_inventory pentru cheie exports('folosesteCheie', function(data, slot) TriggerEvent('gn-carkeys:useKey') end) -- Prinde exportul de la ox_inventory pentru lockpick exports('folosesteLockpick', function(data, slot) TriggerEvent('gn-carkeys:useLockpick') end) -- COMENZI DE TEST RegisterCommand('testcheie', function() TriggerEvent('gn-carkeys:useKey') end) RegisterCommand('testsparge', function() TriggerEvent('gn-carkeys:useLockpick') end)