local QBCore = exports['qb-core']:GetCoreObject() RegisterNetEvent('md-houserobbery:server:accessbreak', function(tier) local src = source local Player = QBCore.Functions.GetPlayer(src) local luck = math.random(1,100) if tier <= 4 then if luck <= 20 then exports.ox_inventory:RemoveItem(src, 'lockpick', 1) end elseif tier == 5 then if luck <= 45 then exports.ox_inventory:RemoveItem(src, 'houselaptop', 1) end else if luck <= 85 then exports.ox_inventory:RemoveItem(src, 'mansionlaptop', 1) end end end) RegisterNetEvent('md-houserobberies:server:sellloot', function(itemName) local src = source local Player = QBCore.Functions.GetPlayer(src) local itemConfig for i = 1, #Config.BlackMarket do if Config.BlackMarket[i].item == itemName then itemConfig = Config.BlackMarket[i] break end end if not itemConfig then return end -- Don't allow players to turn any item into any amount of money local price = math.random(itemConfig.minvalue, itemConfig.maxvalue) -- Retrieve price from config don't trust client local itemsell = exports.ox_inventory:GetItem(src, itemName) if itemsell and itemsell.count > 0 then local success = exports.ox_inventory:RemoveItem(src, itemName, itemsell.count) if success then Player.Functions.AddMoney('cash', price * itemsell.count) lib.notify({description = string.format(Config.Locale["received_cash"], itemsell.count * price), type = "success"}) end end end) RegisterNetEvent('md-houserobberies:server:loseloot', function(item) local src = source local Player = QBCore.Functions.GetPlayer(src) local itemsell = exports.ox_inventory:GetItem(src, item) if itemsell and itemsell.count > 0 then local success = exports.ox_inventory:RemoveItem(src, item, itemsell.count) if success then lib.notify({description = string.format(Config.Locale["got_robbed"], itemsell.count, itemsell.label), type = "error"}) end end end) RegisterNetEvent('md-houserobbery:server:enterHouse', function(house) local src = source TriggerClientEvent('md-houserobbery:client:enterHouse', src, house) Config.Houses[house]['spawned'] = true TriggerClientEvent('md-houserobbery:client:setHouseState', -1, house, true) TriggerEvent('qb-log:server:CreateLog', 'houserobbery', 'Ev Soygunu Başladı', 'red', string.format("**Oyuncu:** %s (%s)\n**Ev ID:** %s", GetPlayerName(src), src, house)) Wait(1000 * 60 * Config.HouseTimer) Config.Houses[house]['spawned'] = false TriggerClientEvent('md-houserobbery:client:setHouseState', -1, house, false) end) RegisterNetEvent('md-houserobbery:server:setlootused', function(house, k) Config.Houses[house]['loot'][k].taken = true TriggerClientEvent('md-houserobbery:client:SetLootState', -1, house, k, true) Wait(1000 * 60 * Config.HouseTimer) Config.Houses[house]['loot'][k].taken = false TriggerClientEvent('md-houserobbery:client:SetLootState', -1, house, k, false) end) RegisterNetEvent('md-houserobbery:server:setlootstatebusy', function(house, k,state) Config.Houses[house]['loot'][k].busy = state TriggerClientEvent('md-houserobbery:client:SetLootStateBusy', -1, house, k, state) end) RegisterNetEvent('md-houserobbery:server:closeHouse', function(house) Config.Houses[house]['spawned'] = false TriggerClientEvent('md-houserobbery:client:setHouseState', -1, house, false) end) RegisterNetEvent('md-houserobberies:server:ptfx', function(loc) TriggerClientEvent('md-housrobberies:client:ptfx', -1, loc) end) RegisterNetEvent('md-houserobbery:server:GetLoot', function(tier, rewardtype, objectCoords) local src = source local Player = QBCore.Functions.GetPlayer(src) local info = Player.PlayerData.charinfo local playerCoords = GetEntityCoords(GetPlayerPed(src)) if #(playerCoords - objectCoords) > 3 then return end -- Prevent loot vacuums local chance = math.random(1,100) local cashamount = math.random(Config.CashMin, Config.CashMax) local randomItem = Config.Rewards[tier][rewardtype][math.random(1, #Config.Rewards[tier][rewardtype])] local itemInfo = exports.ox_inventory:Items()[randomItem] if itemInfo then if Config.EmptyChance <= chance then local amount = Config.ItemAmounts[randomItem] or 1 exports.ox_inventory:AddItem(src, randomItem, amount) if math.random(1, 100) <= 30 then exports.ox_inventory:AddItem(src, 'trojan_usb', 1) end if Config.CashChance <= chance then Player.Functions.AddMoney('cash', cashamount) end else lib.notify({description = Config.Locale["not_worth"], type = "error"}) end else print("Item not found in ox_inventory: ", randomItem) end end)