local QBCore = exports['qb-core']:GetCoreObject() -- Helper function to check if vehicle is blacklisted local function IsVehicleBlacklisted(model) for _, blacklistedModel in ipairs(Config.BlacklistedVehicles) do if model:lower() == blacklistedModel:lower() then return true end end return false end lib.callback.register('alizadev-vehicletransfer:server:GetMyVehicles', function(source) local src = source local Player = QBCore.Functions.GetPlayer(src) if not Player then return false end local MyVeh = MySQL.query.await('SELECT * FROM player_vehicles WHERE citizenid = ?', {Player.PlayerData.citizenid}) if MyVeh[1] then return MyVeh else return false end end) lib.callback.register('alizadev-vehicletransfer:server:GetPlayerInfo', function(source, tsrc) local tPlayer = QBCore.Functions.GetPlayer(tsrc) if not tPlayer then return false end local Target = { FullName = tPlayer.PlayerData.charinfo.firstname..' '..tPlayer.PlayerData.charinfo.lastname, CitizenId = tPlayer.PlayerData.citizenid } return Target end) RegisterNetEvent('alizadev-vehicletransfer:server:Confirmation:TransferVeh', function(buyerId, price, VehFullName, plate, model) local src = source local Player = QBCore.Functions.GetPlayer(src) if not Player then return end -- Check if vehicle is blacklisted and if player has permission if IsVehicleBlacklisted(model) then if not QBCore.Functions.HasPermission(src, 'god') then QBCore.Functions.Notify(src, Config.Locales['vehicle_blacklisted'], 'error', 5000) return end end local SellerFullName = Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname TriggerClientEvent('alizadev-vehicletransfer:client:Confirmation:TransferVeh', buyerId, src, SellerFullName, price, VehFullName, plate, model) end) RegisterNetEvent('alizadev-vehicletransfer:server:VehicleTransfered', function(plate, sellerId, price, model) local src = source local Player = QBCore.Functions.GetPlayer(src) local sPlayer = QBCore.Functions.GetPlayer(sellerId) if not Player or not sPlayer then return end -- Check if vehicle is blacklisted and if player has permission if IsVehicleBlacklisted(model) then if not QBCore.Functions.HasPermission(sellerId, 'god') then QBCore.Functions.Notify(sellerId, Config.Locales['vehicle_blacklisted'], 'error', 5000) QBCore.Functions.Notify(src, Config.Locales['vehicle_blacklisted'], 'error', 5000) return end end if Player.PlayerData.money[Config.Payment] >= price then Player.Functions.RemoveMoney(Config.Payment, price, 'Transfer Vehicle') sPlayer.Functions.AddMoney(Config.Payment, price, 'Transfer Vehicle') MySQL.update.await('UPDATE player_vehicles SET citizenid = ? WHERE plate = ?', {Player.PlayerData.citizenid, plate}) TriggerClientEvent('vehiclekeys:client:SetOwner', src, plate) QBCore.Functions.Notify(sellerId, Config.Locales['transfer_success_seller'], 'success', 5000) QBCore.Functions.Notify(src, Config.Locales['transfer_success_buyer'], 'success', 5000) -- Log eventi tetikle TriggerEvent('alizadev-vehicletransfer:server:LogTransfer', plate, sellerId, src, price, model) else QBCore.Functions.Notify(sellerId, Config.Locales['buyer_no_money'], 'error', 5000) QBCore.Functions.Notify(src, string.format(Config.Locales['not_enough_money'], Config.Payment), 'error', 5000) end end) RegisterNetEvent('alizadev-vehicletransfer:server:SendNotify', function(src, text, type, timer) QBCore.Functions.Notify(src, text, type, timer) end) QBCore.Commands.Add(Config.Command, "Aracını başka bir vatandaşa transfer et", {}, false, function(source) TriggerClientEvent('alizadev-vehicletransfer:client:TransferVeh', source) end) if Config.Item.Enable then QBCore.Functions.CreateUseableItem(Config.Item.ItemName, function(source, item) TriggerClientEvent('alizadev-vehicletransfer:client:TransferVeh', source) end) end RegisterNetEvent('alizadev-vehicletransfer:server:LogTransfer') AddEventHandler('alizadev-vehicletransfer:server:LogTransfer', function(plate, sellerId, buyerId, price, model) local src = source -- Satıcı bilgileri local sPlayer = QBCore.Functions.GetPlayer(sellerId) local sName = sPlayer.PlayerData.charinfo.firstname .. ' ' .. sPlayer.PlayerData.charinfo.lastname local sSteam = GetPlayerName(sellerId) local sCitizenId = sPlayer.PlayerData.citizenid local sJob = sPlayer.PlayerData.job.label -- Alıcı bilgileri local bPlayer = QBCore.Functions.GetPlayer(buyerId) local bName = bPlayer.PlayerData.charinfo.firstname .. ' ' .. bPlayer.PlayerData.charinfo.lastname local bSteam = GetPlayerName(buyerId) local bCitizenId = bPlayer.PlayerData.citizenid local bJob = bPlayer.PlayerData.job.label -- Model adını alma local vehName = QBCore.Shared.Vehicles[model] local fullVehName = vehName and (vehName.brand .. ' ' .. vehName.name) or model local payload = { content = nil, embeds = { { title = Config.Locales['vehicle_webhook_title'], description = string.format( Config.Locales['vehicle_webhook_description'], sSteam, sName, sCitizenId, sellerId, sJob, bName, bCitizenId, buyerId, bJob, fullVehName, plate, price ), image = { url = Config.ImageURL }, footer = { text = "kashi - Araç Transfer Log", icon_url = 'https://cdn.discordapp.com/attachments/1437937532301217812/1438637800978124964/Cooz-PngLogoT_oyun.png?' }, timestamp = os.date("!%Y-%m-%dT%H:%M:%SZ"), color = 3447003 } } } if Config.webhookAlertLimit and price > Config.webhookAlertLimit then payload.content = "@everyone" end local webhookUrl = Config.WebHookURL:gsub("%s+", "") PerformHttpRequest(webhookUrl, function(err, text, headers) if err ~= 204 then print("Webhook Error:", err) end end, 'POST', json.encode(payload), {['Content-Type'] = 'application/json'}) end)