local Config = lib.require('shared') local Server = lib.require('sv_config') local workers = {} local ox_inventory, QBCore if Config.Inventory == 'ox' then ox_inventory = exports.ox_inventory elseif Config.Inventory == 'qb' then QBCore = exports['qb-core']:GetCoreObject() -- QBCore nesnesini alıyoruz end local function createBicycle(source) local veh = CreateVehicleServerSetter(joaat(Config.BikeModel), 'bike', Config.BikeSpawn.x, Config.BikeSpawn.y, Config.BikeSpawn.z, Config.BikeSpawn.w) local ped = GetPlayerPed(source) while not DoesEntityExist(veh) do Wait(0) end while GetVehiclePedIsIn(ped, false) ~= veh do TaskWarpPedIntoVehicle(ped, veh, -1) Wait(0) end return NetworkGetNetworkIdFromEntity(veh) end lib.callback.register('randol_paperboy:server:beginWork', function(source) if workers[source] then return false end local src = source local player if Config.Inventory == 'qb' then player = QBCore.Functions.GetPlayer(src) -- QBCore oyuncusunu alıyoruz end if Config.Inventory == 'ox' then TriggerClientEvent('ox_inventory:disarm', src, true) local count = ox_inventory:GetItemCount(src, 'WEAPON_ACIDPACKAGE') if count > 0 then ox_inventory:RemoveItem(src, 'WEAPON_ACIDPACKAGE', count) end elseif Config.Inventory == 'qb' then local item = player.Functions.GetItemByName('WEAPON_ACIDPACKAGE') if item then player.Functions.RemoveItem('WEAPON_ACIDPACKAGE', item.amount) end end local index = math.random(#Server.Areas) local generatedLocs = {} for i = 1, #Server.Areas[index].Locations do generatedLocs[#generatedLocs+1] = Server.Areas[index].Locations[i] end workers[src] = { locations = generatedLocs, payout = Server.Areas[index].Payout, totalPay = 0, entity = 0, } local amount = #workers[src].locations local netid = createBicycle(src) workers[src].entity = NetworkGetEntityFromNetworkId(netid) if Config.Inventory == 'ox' then ox_inventory:AddItem(src, 'WEAPON_ACIDPACKAGE', amount) elseif Config.Inventory == 'qb' then player.Functions.AddItem('WEAPON_ACIDPACKAGE', amount) end return workers[src], netid end) lib.callback.register('randol_paperboy:server:validateDrop', function(source, location, netid) if not workers[source] then return false end local src = source local pos = GetEntityCoords(GetPlayerPed(src)) local isValid = false if #(pos - location.xyz) > 35.0 then return false end for i = 1, #workers[src].locations do if workers[src].locations[i] == location then table.remove(workers[src].locations, i) isValid = true break end end if not isValid then return false end local payout = math.random(workers[src].payout.min, workers[src].payout.max) -- if NetworkGetNetworkIdFromEntity(GetVehiclePedIsIn(GetPlayerPed(source))) ~= netid then -- payout = 1 -- DoNotification(src, (Config.Locales.wrongVehicle), 'error') -- end workers[src].totalPay += payout DoNotification(src, (Config.Locales.addTotalPay):format(payout, workers[src].totalPay), 'success') return true, #workers[src].locations end) lib.callback.register('randol_paperboy:server:clockOut', function(source) if not workers[source] then DoNotification(source, Config.Locales.noActiveDelivery, 'error') return false end local src = source local player if Config.Inventory == 'qb' then player = QBCore.Functions.GetPlayer(src) end if workers[src].totalPay > 0 then if Config.Inventory == 'ox' then -- Assuming you have a function to add money in Ox AddMoney(src, 'cash', workers[src].totalPay) elseif Config.Inventory == 'qb' then player.Functions.AddMoney('cash', workers[src].totalPay) end DoNotification(src, (Config.Locales.receivedMessage):format(workers[src].totalPay), 'success') end if DoesEntityExist(workers[src].entity) then DeleteEntity(workers[src].entity) end if Config.Inventory == 'ox' then TriggerClientEvent('ox_inventory:disarm', src, true) local count = ox_inventory:GetItemCount(src, 'WEAPON_ACIDPACKAGE') if count > 0 then ox_inventory:RemoveItem(src, 'WEAPON_ACIDPACKAGE', count) end elseif Config.Inventory == 'qb' then local item = player.Functions.GetItemByName('WEAPON_ACIDPACKAGE') if item then player.Functions.RemoveItem('WEAPON_ACIDPACKAGE', item.amount) end end workers[src] = nil return true end) function OnServerPlayerUnload(src) if workers[src] then if DoesEntityExist(workers[src].entity) then DeleteEntity(workers[src].entity) end workers[src] = nil end end if Config.Inventory == 'ox' then local hookId = ox_inventory:registerHook('swapItems', function(payload) return false end, { print = false, itemFilter = { WEAPON_ACIDPACKAGE = true, }, inventoryFilter = { '^glove[%w]+', '^trunk[%w]+', '^drop-[%w]+', '^newdrop$' } }) AddEventHandler("onResourceStop", function(resource) if resource == GetCurrentResourceName() then exports.ox_inventory:removeHooks(hookId) end end) elseif Config.Inventory == 'qb' then -- QBCore'da item swap işlemlerini kontrol etmek için manuel bir yapı RegisterNetEvent('QBCore:Server:SwapItems', function(source, fromSlot, toSlot, fromItem, toItem) local src = source local itemName = fromItem.name or toItem.name -- Eğer WEAPON_ACIDPACKAGE itemi taşınmak isteniyorsa if itemName == 'WEAPON_ACIDPACKAGE' then local fromInv = fromSlot.inventory or "unknown" local toInv = toSlot.inventory or "unknown" -- Belirli envanterlere taşıma işlemini engelle if fromInv:match('^glove[%w]+') or fromInv:match('^trunk[%w]+') or fromInv:match('^drop-[%w]+') or fromInv == 'newdrop' or toInv:match('^glove[%w]+') or toInv:match('^trunk[%w]+') or toInv:match('^drop-[%w]+') or toInv == 'newdrop' then -- İşlemi iptal et TriggerClientEvent('QBCore:Notify', src, Config.Locales.cantTake, "error") CancelEvent() return end end end) -- QBCore tarafında oyuncu envanter değişikliklerini dinleyin AddEventHandler('QBCore:Server:InventoryUpdated', function(source, inventory) local src = source -- Envanter güncellendiğinde belirli itemleri kontrol edin (örneğin silahlar) for _, item in ipairs(inventory.items) do if item.name == 'WEAPON_ACIDPACKAGE' then -- Eğer item belirli envanterlere taşınmışsa, swap işlemini iptal edin if item.inventory:match('^glove[%w]+') or item.inventory:match('^trunk[%w]+') or item.inventory:match('^drop-[%w]+') or item.inventory == 'newdrop' then TriggerClientEvent('QBCore:Notify', src, Config.Locales.cantTake, "error") -- İsteğe bağlı olarak itemi geri taşıyabilirsiniz end end end end) end