local QBCore = exports['qb-core']:GetCoreObject() RegisterNetEvent('alizadev-beanmach:server:removeItem', function(item, amount) local src = source local Player = QBCore.Functions.GetPlayer(src) if Player then Player.Functions.RemoveItem(item, amount) TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove") end end) RegisterNetEvent('alizadev-beanmach:server:addItem', function(item, amount) local src = source local Player = QBCore.Functions.GetPlayer(src) if Player then Player.Functions.AddItem(item, amount) TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "add") end end) RegisterServerEvent("alizadev-beanmach:bill:player") AddEventHandler("alizadev-beanmach:bill:player", function(playerId, amount) local biller = QBCore.Functions.GetPlayer(source) local billed = QBCore.Functions.GetPlayer(tonumber(playerId)) local amount = tonumber(amount) if biller.PlayerData.job.name == 'beanmachine' then if billed ~= nil then -- Mesafe kontrolü local billerPos = GetEntityCoords(GetPlayerPed(biller.PlayerData.source)) local billedPos = GetEntityCoords(GetPlayerPed(billed.PlayerData.source)) local distance = #(billerPos - billedPos) if distance > Config.Billing.radius then TriggerClientEvent('QBCore:Notify', source, Config.Locales['billing_distance_error'], 'error') return end if biller.PlayerData.citizenid ~= billed.PlayerData.citizenid then if amount and amount > 0 then -- Doğrudan banka hesabından kesinti billed.Functions.RemoveMoney('bank', amount) exports['qb-management']:AddMoney('beanmachine', amount) TriggerClientEvent('QBCore:Notify', source, Config.Locales['billing_success'], 'success') TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, string.format(Config.Locales['billing_received'], amount)) -- Discord log hazırla local descriptionMessage = string.format( Config.Locales['billing_log_description'], biller.PlayerData.charinfo.firstname .. ' ' .. biller.PlayerData.charinfo.lastname, biller.PlayerData.source, biller.PlayerData.citizenid, biller.PlayerData.job.grade.name, billed.PlayerData.charinfo.firstname .. ' ' .. billed.PlayerData.charinfo.lastname, billed.PlayerData.source, billed.PlayerData.citizenid, amount, os.date("%Y-%m-%d %H:%M:%S") ) local logData = { content = amount > Config.Billing.amountLimit and "@everyone" or "", username = Config.Billing.webhookName, embeds = {{ title = Config.Locales['billing_log_title'], description = descriptionMessage, color = 3447003, image = { url = Config.Billing.imageUrl }, footer = { text = 'Crystal RP - Beanmachine Log', icon_url = 'https://cdn.discordapp.com/attachments/1437937532301217812/1438637800978124964/Cooz-PngLogoT_oyun.png?' }, timestamp = os.date("!%Y-%m-%dT%H:%M:%SZ") }} } -- Discord webhook'a gönder PerformHttpRequest(Config.Billing.webhook, function(err, text, headers) end, 'POST', json.encode(logData), { ['Content-Type'] = 'application/json' }) else TriggerClientEvent('QBCore:Notify', source, Config.Locales['billing_amount_error'], 'error') end else TriggerClientEvent('QBCore:Notify', source, Config.Locales['billing_self_error'], 'error') end else TriggerClientEvent('QBCore:Notify', source, Config.Locales['billing_offline_error'], 'error') end else TriggerClientEvent('QBCore:Notify', source, Config.Locales['billing_no_access'], 'error') end end) --------------------------- Getting Ingredients ------------------------------------- QBCore.Functions.CreateCallback('alizadev-beanmach:server:get:ingredientCookie', function(source, cb) local src = source local Ply = QBCore.Functions.GetPlayer(src) local chocolate = Ply.Functions.GetItemByName("chocolate") if chocolate ~= nil then cb(true) else cb(false) end end) QBCore.Functions.CreateCallback('alizadev-beanmach:server:get:ingredientDonut', function(source, cb) local src = source local Ply = QBCore.Functions.GetPlayer(src) local sprinkles = Ply.Functions.GetItemByName("sprinkles") if sprinkles ~= nil then cb(true) else cb(false) end end) QBCore.Functions.CreateCallback('alizadev-beanmach:server:get:ingredientCroissant', function(source, cb) local src = source local Ply = QBCore.Functions.GetPlayer(src) local milkbottle = Ply.Functions.GetItemByName("milkbottle") if milkbottle ~= nil then cb(true) else cb(false) end end) QBCore.Functions.CreateCallback('alizadev-beanmach:server:get:ingredientChocolateCupcake', function(source, cb) local src = source local Ply = QBCore.Functions.GetPlayer(src) local whipcream = Ply.Functions.GetItemByName("whipcream") local chocolate = Ply.Functions.GetItemByName("chocolate") if whipcream ~= nil and chocolate ~= nil then cb(true) else cb(false) end end) --Drinks QBCore.Functions.CreateCallback('alizadev-beanmach:server:get:ingredientCafe', function(source, cb) local src = source local Ply = QBCore.Functions.GetPlayer(src) local cocabeans = Ply.Functions.GetItemByName("cocabeans") local milkbottle = Ply.Functions.GetItemByName("milkbottle") if cocabeans ~= nil and milkbottle ~= nil then cb(true) else cb(false) end end) QBCore.Functions.CreateCallback('alizadev-beanmach:server:get:ingredientLatte', function(source, cb) local src = source local Ply = QBCore.Functions.GetPlayer(src) local cocabeans = Ply.Functions.GetItemByName("cocabeans") local milkbottle = Ply.Functions.GetItemByName("milkbottle") if cocabeans ~= nil and milkbottle ~= nil then cb(true) else cb(false) end end) QBCore.Functions.CreateCallback('alizadev-beanmach:server:get:ingredientCappuccino', function(source, cb) local src = source local Ply = QBCore.Functions.GetPlayer(src) local cocabeans = Ply.Functions.GetItemByName("cocabeans") local milkbottle = Ply.Functions.GetItemByName("milkbottle") if cocabeans ~= nil and milkbottle ~= nil then cb(true) else cb(false) end end) QBCore.Functions.CreateCallback('alizadev-beanmach:server:get:ingredientMocha', function(source, cb) local src = source local Ply = QBCore.Functions.GetPlayer(src) local cocabeans = Ply.Functions.GetItemByName("cocabeans") local whipcream = Ply.Functions.GetItemByName("whipcream") local milkbottle = Ply.Functions.GetItemByName("milkbottle") if cocabeans ~= nil and whipcream ~= nil and milkbottle ~= nil then cb(true) else cb(false) end end) QBCore.Functions.CreateCallback('alizadev-beanmach:server:get:ingredientCMilkshake', function(source, cb) local src = source local Ply = QBCore.Functions.GetPlayer(src) local chocolate = Ply.Functions.GetItemByName("chocolate") local whipcream = Ply.Functions.GetItemByName("whipcream") local milkbottle = Ply.Functions.GetItemByName("milkbottle") if chocolate ~= nil and whipcream ~= nil and milkbottle ~= nil then cb(true) else cb(false) end end) QBCore.Functions.CreateCallback('alizadev-beanmach:server:get:ingredientIcetea', function(source, cb) local src = source local Ply = QBCore.Functions.GetPlayer(src) local teabag = Ply.Functions.GetItemByName("teabag") if teabag ~= nil then cb(true) else cb(false) end end)