fillData,fillMyData,fillArr,cacheData,cacheUser,Props,fuelTypeArr = {},{},{},{},{},{},{} local first = false if Config.AutoDatabaseCreator then Citizen.CreateThread(function() while CoreReady == false do Citizen.Wait(0) end if CoreName == "qb-core" or CoreName == "qbx_core" then MySQL.query.await([[ALTER TABLE `players` ADD `frkn_fuelstation_control` INT(11) NOT NULL DEFAULT 0;]], {}, function(rowsChanged)end) else MySQL.query.await([[ALTER TABLE `users` ADD `frkn_fuelstation_control` INT(11) NOT NULL DEFAULT 0;]], {}, function(rowsChanged)end) end MySQL.query.await([[CREATE TABLE IF NOT EXISTS `frkn_fuel` ( `id` int(11) NOT NULL AUTO_INCREMENT, `owner` varchar(50) DEFAULT NULL, `fuel_name` varchar(50) NOT NULL, `desc` longtext NOT NULL, `img` longtext NOT NULL, `price` varchar(50) DEFAULT NULL, `ownership` int(11) DEFAULT 0, `rate` varchar(50) DEFAULT NULL, `owner_name` varchar(50) DEFAULT 'Furkan', `employees` longtext DEFAULT '[]', `gas_prop` longtext DEFAULT '[]', `gas_netID` int(11) DEFAULT 0, `gas_price` longtext DEFAULT '0', `gas_tanker` longtext DEFAULT '0', `gas_data` longtext DEFAULT '0', `gas_level` longtext DEFAULT '{"level":1,"xp":0}', `gas_safe_money` int(11) DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=194 DEFAULT CHARSET=utf8mb4;]], {}, function(rowsChanged) end) insertData = [[ (1, 'Maze Arena', 'Gas Station 1', 'We\'re here to ensure your journeys are safe and comfortable. Offering your vehicles the high-quality fuel they need at the most competitive prices. Customer satisfaction and vehicle performance are our priorities. Just take the wheel and leave the rest to us', '../images/stationimg1.png', '15060', 0, '1.5', 'There\'s no owner here', '[]', '[]', 85, '{"electric":15,"premium":12,"basic":58,"nitro":8}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (2, 'Maze Arena', 'Gas Station 2', 'Every journey has a story, and a quality fuel is essential to tell that story best. Our station not only provides your vehicles with the ideal fuel but also welcomes you in a modern and comfortable atmosphere. We\'re here to make your journey even more enjoyable', '../images/stationimg1.png', '34560', 0, '2.5', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (3, 'Maze Arena', 'Gas Station 3', 'Meeting your fuel needs is just a step away. Our station offers a variety of fuel types and quality fuel options, along with specialized care for your vehicles. When you stop by, you\'re not only filling up with fuel but also enjoying top-notch service', '../images/stationimg1.png', '25250', 0, '2.2', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (4, 'Maze Arena', 'Gas Station 4', ' you\'re looking to make your journeys more economical and efficient, we\'re waiting for you at our station. With suitable fuel options for your vehicles and specially designed fuel tanks, you can enhance your performance and save on fuel. Safe travels', '../images/stationimg1.png', '34555', 0, '2.8', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (5, 'Maze Arena', 'Gas Station 5', 'Every journey is an experience, and a quality fuel enhances that experience. Our station provides your vehicles with the best fuel while offering you a comfortable rest stop. We\'re here to make your journeys safer and more enjoyable', '../images/stationimg1.png', '45620', 0, '3.5', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (6, 'Maze Arena', 'Gas Station 6', 'For longer and more enjoyable journeys, our station awaits. We provide the energy your vehicles need with our quality fuel options and modern facilities. Join us to make your journeys more comfortable and efficient', '../images/stationimg1.png', '21950', 0, '2.5', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (7, 'Maze Arena', 'Gas Station 7', 'We\'re here with you at every stage of your journey. Alongside offering the most suitable fuel for your vehicles, our station provides you with a comfortable resting area. With our top-notch service, we\'re making your journeys smoother and more enjoyable.', '../images/stationimg1.png', '28020', 0, '2.4', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (8, 'Maze Arena', 'Gas Station 8', 'Providing the energy your vehicles need is our job. At our station, we offer different fuel types and quality options tailored to your vehicles. Just visit our station, and leave the rest to us', '../images/stationimg1.png', '45975', 0, '3.7', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (9, 'Maze Arena', 'Gas Station 9', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '65750', 1, '4.6', 'There\'s no owner here', '[]', '[]', 76, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (10, 'Maze Arena', 'Gas Station 10', 'We\'re here to make your journeys special and enjoyable. Our station offers various fuel types and high-quality fuel to provide the best care for your vehicles. Let\'s meet at our station to make your journeys more comfortable and safer.', '../images/stationimg1.png', '84250', 0, '5', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (11, 'Maze Arena', 'Gas Station 11', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '65420', 0, '4.7', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (12, 'Maze Arena', 'Gas Station 12', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '75400', 0, '4.8', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (13, 'Maze Arena', 'Gas Station 13', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '32500', 0, '3.6', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (14, 'Maze Arena', 'Gas Station 14', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '78500', 0, '4.9', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (15, 'Maze Arena', 'Gas Station 15', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '34000', 0, '3.4', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (16, 'Maze Arena', 'Gas Station 16', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '67000', 0, '4.7', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (17, 'Maze Arena', 'Gas Station 17', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '76500', 0, '4.9', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (18, 'Maze Arena', 'Gas Station 18', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '98500', 0, '5', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (19, 'Maze Arena', 'Gas Station 19', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '45000', 0, '4.2', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (20, 'Maze Arena', 'Gas Station 20', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '23550', 0, '2.1', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (21, 'Maze Arena', 'Gas Station 21\r\n', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '41255', 0, '3.2', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (22, 'Maze Arena', 'Gas Station 22', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '45500', 0, '3.3', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (23, 'Maze Arena', 'Gas Station 23', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '65500', 0, '3.7', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (24, 'Maze Arena', 'Gas Station 24', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '45000', 0, '3.4', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (25, 'Maze Arena', 'Gas Station 25', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '23500', 0, '2.8', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (26, 'Maze Arena', 'Gas Station 26', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '47000', 0, '3.5', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0), (27, 'Maze Arena', 'Gas Station 27', 'Your vehicles\' peak performance is our goal. Our station has specially designed fuel options and a modern facility to provide the care your vehicles need. Just set out on your journey and leave the rest to us.', '../images/stationimg1.png', '53500', 0, '3.9', 'There\'s no owner here', '[]', '[]', 85, '{"premium":12,"nitro":8,"basic":5,"electric":15}', '{"premium":100,"nitro":"100","basic":100,"electric":100}', '0', '{"level":1,"xp":0}', 0); ]] MySQL.query.await([[INSERT INTO `frkn_fuel` (`id`, `owner`, `fuel_name`, `desc`, `img`, `price`, `ownership`, `rate`, `owner_name`, `employees`, `gas_prop`, `gas_netID`, `gas_price`, `gas_tanker`, `gas_data`, `gas_level`, `gas_safe_money`) VALUES ]]..insertData, {}, function(rowsChanged) end) end) end RegisterNetEvent('frkn-fuelstation:fillEvent') AddEventHandler('frkn-fuelstation:fillEvent',function() local src = source update(src,fillData,fillMyData,fillArr,"gas_tanker") end) RegisterNetEvent('frkn-fuelstation:oneDelete') AddEventHandler('frkn-fuelstation:oneDelete',function() if json.encode(Props) ~= "[]" then for k, v in pairs(Props) do DeleteEntity(NetworkGetEntityFromNetworkId(k)) end end end) RegisterNetEvent('frkn-fuelstation:allPropsDelete') AddEventHandler('frkn-fuelstation:allPropsDelete',function() if json.encode(Props) ~= "[]" then for k, v in pairs(Props) do DeleteEntity(NetworkGetEntityFromNetworkId(k)) end end end) RegisterNetEvent('frkn-fuelstation:firstSpawnProp') AddEventHandler('frkn-fuelstation:firstSpawnProp',function() Wait(1000) for k, v in pairs(cacheData) do if v.gas_prop ~= "[]" then local propData = json.decode(v.gas_prop) Wait(500) if propData and propData.pos then obj = CreateObject(propData.hash, propData.pos.x, propData.pos.y, propData.pos.z, true, true, true) SetEntityHeading(obj, propData.pos.w) Wait(1200) local tankerNetId = NetworkGetNetworkIdFromEntity(obj) TriggerEvent('frkn-fuelstation:updateNetID', tankerNetId, v.id,"id") TriggerEvent('frkn-fuelstation:clientPropUpdate', v.gas_prop,tankerNetId,propData.pos,propData.hash) Wait(1000) data = { netId = tankerNetId, pos = propData.pos, hash = propData.hash } Props[tankerNetId] = data cacheData[v.id].gas_netID = tankerNetId FreezeEntityPosition(obj,true) end end end end) RegisterNetEvent('frkn-fuelstation:clientProp', function(status) if not first then first = true else return end TriggerEvent('frkn-fuelstation:firstSpawnProp') end) RegisterNetEvent('frkn-fuelstation:updateNetID', function(newID, id,variable) local query = "UPDATE `frkn_fuel` SET gas_netID = '" .. newID .. "' WHERE `" .. variable .. "` = '" .. id .. "'" MySQL.Async.execute(query) end) RegisterNetEvent('frkn-fuelstation:selectProp') AddEventHandler('frkn-fuelstation:selectProp',function(data) set = json.decode(cacheData[data.id].gas_prop) propUpdate(data,set) end) RegisterNetEvent('frkn-fuelstation:setCoord') AddEventHandler('frkn-fuelstation:setCoord',function(data) propUpdate(data,data) end) RegisterNetEvent('frkn-fuelstation:setProp') AddEventHandler('frkn-fuelstation:setProp',function(data) if data.pos == "exit" then else propUpdate(data,data) end end) RegisterNetEvent('frkn-fuelstation:fire') AddEventHandler('frkn-fuelstation:fire', function(data) myEmployees = json.decode(cacheData[data.id].employees) myEmployees = control(myEmployees) for i, employee in ipairs(myEmployees) do if employee.identifier == data.identifier then table.remove(myEmployees, i) break end end Citizen.Wait(100) miniUpdate(data,"employees",json.encode(myEmployees)) end) RegisterNetEvent('frkn-fuelstation:hire') AddEventHandler('frkn-fuelstation:hire', function(data) local myEmployees = json.decode(cacheData[data.id].employees) myEmployees = control(myEmployees) local exists = false for _, employee in ipairs(myEmployees) do if employee.identifier == data.identifier then exists = true break end end if not exists then local newEmployee = { ["name"] = data.name, ["identifier"] = data.identifier, } table.insert(myEmployees, newEmployee) Citizen.Wait(100) miniUpdate(data, "employees", json.encode(myEmployees)) else print("Employee with the same identifier already exists.") end end) RegisterNetEvent('frkn-fuelstation:dataPostClient') AddEventHandler('frkn-fuelstation:dataPostClient',function() TriggerClientEvent('frkn-fuelstation:setClient',-1,cacheData) end) RegisterNetEvent('frkn-fuelstation:getData') AddEventHandler('frkn-fuelstation:getData', function() MySQL.Async.fetchAll('SELECT * FROM frkn_fuel', {}, function(result) for k, v in pairs(result) do data = { id = v.id, owner = v.owner, fuel_name = v.fuel_name, desc = v.desc, img = v.img, owner_name = v.owner_name, owner_number = v.owner_number, ownership = v.ownership, price = v.price, rate = v.rate, employees = v.employees, gas_price = v.gas_price, gas_tanker = v.gas_tanker, gas_data = v.gas_data, gas_level = v.gas_level, gas_safe_money = v.gas_safe_money, gas_prop = v.gas_prop, gas_netID = v.gas_netID } table.insert(cacheData, data) end end) end) AddEventHandler('onResourceStop', function(resourceName) if (GetCurrentResourceName() ~= resourceName) then return end for k, v in pairs(Props) do DeleteEntity(NetworkGetEntityFromNetworkId(k)) Props = {} end end) AddEventHandler('onResourceStart', function(resourceName) if (GetCurrentResourceName() == resourceName) then for k, v in pairs(cacheData) do DeleteEntity(NetworkGetEntityFromNetworkId(v.gas_netID)) end TriggerEvent('frkn-fuelstation:getData') return end end) --nitro RegisterNetEvent("frkn-custom:syncNitro") AddEventHandler("frkn-custom:syncNitro",function(boostEnabled, purgeEnabled, lastVehicle) local source = source for _, player in ipairs(GetPlayers()) do if player ~= tostring(source) then TriggerClientEvent("frkn-custom:sync", player, source, boostEnabled, purgeEnabled, lastVehicle) end end end) RegisterNetEvent('frkn-fuelstation:removeItem') AddEventHandler('frkn-fuelstation:removeItem', function(item) local src = source RemoveItem(src, item, 1) end) -- ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛ -- ⬛ FUNCTION ⬛ -- ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛ function update(src,data,format,arr,dataType) query = "" if format == nil or format == "[]" or format == "0" or format == 0 then arr[data.type] = tonumber(data.update) cacheData[data.id][dataType] = format query = "UPDATE `frkn_fuel` SET " .. dataType .. " = '" ..json.encode(arr) .. "' WHERE id = '" .. data.id .. "'" else local cachedData = cacheData[data.id][dataType] local parsedData = json.decode(cachedData) parsedData[data.type] = tonumber(data.update) cacheData[data.id][dataType] = json.encode(parsedData) query = "UPDATE `frkn_fuel` SET " .. dataType .. " = '" ..json.encode(parsedData).. "' WHERE id = '" .. data.id .. "'" end Citizen.Wait(100) MySQL.Async.execute(query) TriggerClientEvent('frkn-fuelstation:oneDataUpdate', -1, cacheData[data.id][dataType],data.id,dataType) end function propUpdate(data,set) DeleteEntity(NetworkGetEntityFromNetworkId(cacheData[data.id].gas_netID)) Wait(1000) obj = CreateObjectNoOffset(data.hash, set.pos.x, set.pos.y, set.pos.z, true, true, true) SetEntityHeading(obj, set.pos.w) Wait(1200) local tankerNetId = NetworkGetNetworkIdFromEntity(obj) TriggerEvent('frkn-fuelstation:updateNetID', tankerNetId, data.id,"id") newData = { netId = tankerNetId, pos = set.pos, hash = data.hash } updateData = { pos = set.pos, hash = data.hash } TriggerEvent('frkn-fuelstation:clientPropUpdate', updateData, tankerNetId,set.pos,data.hash) Props[tankerNetId] = newData cacheData[data.id].gas_netID = tankerNetId Wait(500) miniUpdate(data,"gas_prop",json.encode(updateData)) FreezeEntityPosition(obj,true) end function miniUpdate(data, dataType, parsedData) cacheData[data.id][dataType] = parsedData local query = "UPDATE `frkn_fuel` SET " .. dataType .. " = '" ..parsedData .. "' WHERE id = '" .. data.id .. "'" MySQL.Async.execute(query) TriggerClientEvent('frkn-fuelstation:oneDataUpdate', -1, cacheData[data.id][dataType], data.id, dataType) end function control(data) if data == "0" or data == 0 or data == nil or data == "[]" then return {} else return data end end function ownerEmployeeControl(identifier,id) owner = cacheData[id].owner employees = json.decode(cacheData[id].employees) if identifier == owner then return false else return true end for i, employee in ipairs(employees) do if employee.identifier == identifier then else return true end end end function fuelTypeData(existingPlates) local found = false local targetPlate = plate local newType = "" local newData = {} for _, plateData in pairs(fuelTypeArr) do if plateData.plate == targetPlate then plateData.type = plateData.type found = true break end end if not found then for k , v in pairs(existingPlates) do newData = { type = v.type, plate = v.plate } end table.insert(fuelTypeArr, newData) end end function setNitro(data) TriggerClientEvent('frkn-fuelstation:clientSetNitro',-1,data) end function priceControl(src, price) local xPlayer = GetPlayer(src) if Config.PriceType == "bank" then if tonumber(price) > GetPlayerMoney(src,'bank') then return "error" else RemoveMoney(src,'bank', tonumber(price), "Fuel") return "success" end else if tonumber(price) > GetPlayerMoney(src,'cash') then return "error" else RemoveMoney(src,'cash', tonumber(price), "Fuel") return "success" end end end -- ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛ -- ⬛ CALLBACK ⬛ -- ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛ CreateCallback('frkn-fuelstation:buyFuel', function(source, cb, id, price) local src = source local xPlayer = GetPlayer(src) local cid = GetPlayerCid(src) local userName = GetPlayerName(src) local res = {} if CoreName == "qb-core" or CoreName == "qbx_core" then res = MySQL.Sync.fetchAll("SELECT * FROM `players` WHERE citizenid = '" .. cid .. "' ") else res = MySQL.Sync.fetchAll("SELECT * FROM `users` WHERE identifier = '" .. cid .. "' ") end if res[1].frkn_fuelstation_control == 1 then cb(Config.NotifyMenu["station"]["already"]) return else if priceControl(src, price) == "success" then cacheData[id].ownership = 1 cacheData[id].owner_name = userName cacheData[id].owner = cid if CoreName == "qb-core" or CoreName == "qbx_core" then MySQL.Async.execute("UPDATE `players` SET frkn_fuelstation_control = @frkn_fuelstation_control WHERE `citizenid` = '" .. cid .. "' ", {['@frkn_fuelstation_control'] = 1}, function(xPlayerResult) end) else MySQL.Async.execute("UPDATE `users` SET frkn_fuelstation_control = @frkn_fuelstation_control WHERE `identifier` = '" .. cid .. "' ", {['@frkn_fuelstation_control'] = 1}, function(xPlayerResult) end) end local query = "UPDATE `frkn_fuel` SET ownership = '1', owner_name = '" .. userName .. "', owner = '" .. cid .. "' WHERE id = '" .. id .. "'" MySQL.Async.execute(query) TriggerClientEvent('frkn-fuelstation:allDataUpdate', -1, cacheData) cb(Config.NotifyMenu["station"]["success"]) return else cb(Config.NotifyMenu["station"]["error"]) return end end end) CreateCallback('frkn-fuelstation:sellFuel', function(source, cb, id,userId) local src = source local xPlayer = GetPlayer(src) local targetPlayer = GetPlayer(userId) local mycid = GetPlayerCid(src) local myName = GetPlayerName(src) local targetCid = GetPlayerCid(userId) local targetName = GetPlayerName(userId) if cacheData[id].owner == mycid then cacheData[id].ownership = 1 cacheData[id].owner_name = targetName cacheData[id].owner = targetCid if CoreName == "qb-core" or CoreName == "qbx_core" then MySQL.Async.execute("UPDATE `players` SET frkn_fuelstation_control = @frkn_fuelstation_control WHERE `citizenid` = '" .. mycid .. "' ", {['@frkn_fuelstation_control'] = 0}, function(xPlayerResult) end) MySQL.Async.execute("UPDATE `players` SET frkn_fuelstation_control = @frkn_fuelstation_control WHERE `citizenid` = '" .. targetCid .. "' ", {['@frkn_fuelstation_control'] = 1}, function(targetResult) end) else MySQL.Async.execute("UPDATE `users` SET frkn_fuelstation_control = @frkn_fuelstation_control WHERE `identifier` = '" .. mycid .. "' ", {['@frkn_fuelstation_control'] = 0}, function(xPlayerResult) end) MySQL.Async.execute("UPDATE `users` SET frkn_fuelstation_control = @frkn_fuelstation_control WHERE `identifier` = '" .. targetCid .. "' ", {['@frkn_fuelstation_control'] = 1}, function(targetResult) end) end local query = "UPDATE `frkn_fuel` SET ownership = '1', owner_name = '" .. targetName .. "', owner = '" .. targetCid .. "' WHERE owner = '" .. mycid .. "'" MySQL.Async.execute(query) TriggerClientEvent('frkn-fuelstation:allDataUpdate', -1, cacheData) end end) CreateCallback('frkn-fuelstation:fill',function(source,cb,data) local src = source myData = json.decode(cacheData[data.id].gas_tanker) arr = { ["basic"] = 100, ["electric"] = 100, ["premium"] = 100, ["nitro"] = 100 } lvl = json.decode(cacheData[data.id].gas_level) if myData[data.type] + data.update > Config.MyStation["level"][lvl.level] then cb(Config.NotifyMenu["fill"]["full"]) else data.update = myData[data.type] + data.update data.update = math.floor(data.update) fillData = data fillMyData = myData fillArr = arr -- update(src,data,myData,arr,"gas_tanker") cb(Config.NotifyMenu["fill"][priceControl(src,data.price)]) end end) plate = "" CreateCallback('frkn-fuelstation:buyGas',function(source,cb,data,multiplication) local src = source local xPlayer = GetPlayer(src) local gasTankerData = json.decode(cacheData[data.id].gas_tanker) if tonumber(gasTankerData[data.type]) >= tonumber(data.liter) then gasTankerData[data.type] = gasTankerData[data.type] - tonumber(data.liter) cacheData[data.id].gas_tanker = json.encode(gasTankerData) myData = json.decode(cacheData[data.id].gas_data) myData = control(myData) plate = data.plate local a = {} sendFunction = { ["type"] = data.type, ["plate"] = data.plate } table.insert( a,sendFunction ) local modifiedString = getDiscordImg(src):gsub("%.webp%?size=4096$", "") arr = { ["user"] = GetPlayerName(src), ["type"] = data.type, ["liter"] = data.liter, ["price"] = data.price, ["plate"] = data.plate, ["car"] = data.car, ["img"] = modifiedString } level = json.decode(cacheData[data.id].gas_level) levelData = level["level"] if level == "[]" then levelData = 1 end xp = { ["xp"] = level["xp"] + math.floor(data.liter/2), ["level"] = levelData } table.insert(myData, arr) if level["xp"] + math.floor(data.liter/2) >= Config.MyStation["levelXp"][levelData] then levelData = levelData + 1 xp = { ["xp"] = level["xp"] + math.floor(data.liter/2), ["level"] = levelData } end if data.type == "nitro" then cb(Config.NotifyMenu["gas"][priceControl(src,data.price)]) newPrice = cacheData[data.id].gas_safe_money + data.price local query = "UPDATE `frkn_fuel` SET gas_safe_money = '"..newPrice.."' WHERE id = '" .. data.id .. "'" MySQL.Async.execute(query) cacheData[data.id].gas_safe_money = newPrice TriggerClientEvent('frkn-fuelstation:oneDataUpdate', -1, cacheData[data.id]["gas_safe_money"], data.id, "gas_safe_money") setNitro(data) else if multiplication == 2 then fuelTypeData(a) cb(Config.NotifyMenu["gas"][priceControl(src,data.price)]) else local number = data.price local percentage = Config.MyStation["tax"] local result = number * percentage / 100 local subtracted = number - result newPrice = cacheData[data.id].gas_safe_money + subtracted cacheData[data.id].gas_safe_money = newPrice print("newPrice",newPrice) print("cacheData[data.id].gas_safe_money",cacheData[data.id].gas_safe_money) --BU KOD ACILACAK -- local bug = ownerEmployeeControl(xPlayer.PlayerData.citizenid,data.id) -- if not bug then -- else local query = "UPDATE `frkn_fuel` SET gas_safe_money = '"..newPrice.."' WHERE id = '" .. data.id .. "'" MySQL.Async.execute(query) TriggerClientEvent('frkn-fuelstation:oneDataUpdate', -1, newPrice, data.id, "gas_safe_money") miniUpdate(data,"gas_data",json.encode(myData)) miniUpdate(data,"gas_level",json.encode(xp)) -- end fuelTypeData(a) miniUpdate(data,"gas_tanker",json.encode(gasTankerData)) cb(Config.NotifyMenu["gas"][priceControl(src,data.price)]) end end end end) CreateCallback('frkn-fuelstation:carTypeCheck', function(source, cb, plate, dataType) if next(fuelTypeArr) then local plateFound = false for _, plateData in pairs(fuelTypeArr) do if plateData.plate == plate then cb(plateData.type) plateFound = true break end end if not plateFound then cb(dataType) end else cb(dataType) end end) CreateCallback('frkn-fuelstation:withdraw', function(source, cb, data) local src = source local xPlayer = GetPlayer(src) local safeMoney = cacheData[data.id].gas_safe_money print(safeMoney) if tonumber(data.count) > tonumber(safeMoney) then cb(Config.NotifyMenu["withdraw"]["error"]) else safeMoney = safeMoney - tonumber(data.count) AddMoney(src, 'cash', tonumber(data.count), "Fuel") miniUpdate(data, "gas_safe_money", safeMoney) cacheData[data.id].gas_safe_money = safeMoney print("withdraw cache" , cacheData[data.id].gas_safe_money) TriggerClientEvent('frkn-fuelstation:oneDataUpdate', -1, cacheData[data.id]["gas_safe_money"], data.id, "gas_safe_money") cb(Config.NotifyMenu["withdraw"]["success"], safeMoney) end end) CreateCallback('frkn-fuelstation:setLevel',function(source,cb,data) local src = source myData = cacheData[data.id].gas_level myData = data.update miniUpdate(data,"gas_level",myData) cb(Config.NotifyMenu["level"][priceControl(src,data.price)]) end) CreateCallback('frkn-fuelstation:changePrice',function(source,cb,data) local src = source myData = json.decode(cacheData[data.id].gas_price) arr = { ["basic"] = Config.MyStation["defaultGasPrice"]["basic"], ["electric"] = Config.MyStation["defaultGasPrice"]["electric"], ["premium"] = Config.MyStation["defaultGasPrice"]["premium"], ["nitro"] = Config.MyStation["defaultGasPrice"]["nitro"] } arr[data.type] = tonumber(data.update) update(src,data,myData,arr,"gas_price") cb(Config.NotifyMenu["price"]["success"]) end) CreateCallback('frkn-fuelstation:changeName',function(source, cb, data) local src = source local xPlayer = GetPlayer(src) fuelName = cacheData[data.id].fuel_name fuelName = data.name miniUpdate(data,"fuel_name",fuelName) cb(Config.NotifyMenu["name"][priceControl(src,Config.MyStation["changNamePrice"])]) end) CreateCallback('frkn-fuelstation:getUsers', function(source, cb) local Players = {} local playerIdentifiers = GetAllPlayers() local function fetchDiscordProfiles(playerIndex) if playerIndex > #playerIdentifiers then return cb(Players) end local v = playerIdentifiers[playerIndex] local identifiers = GetPlayerIdentifiers(v) if identifiers == nil then return fetchDiscordProfiles(playerIndex + 1) end local discordProfile = getDiscordImg(v) local xPlayer = GetPlayer(v) local cid = GetPlayerCid(v) local name = GetPlayerName(v) local discord = discordProfile Players[#Players+1] = { identifier = cid, name = name, discord = discord } Citizen.Wait(100) fetchDiscordProfiles(playerIndex + 1) end fetchDiscordProfiles(1) end) CreateCallback('frkn-fuelstation:jerryMetadata',function(source,cb,data) local src = source local xPlayer = GetPlayer(src) if data == "electric" then local item = GetItemCount(src,Config.Jerry["chargeItem"]) if item then if item >= 1 then cb(GetItemMetadata(src,Config.Jerry["chargeItem"])) else cb(false) end else cb(false) end else local item = GetItemCount(src,Config.Jerry["jerryItem"]) if item then if item >= 1 then local meta = GetItemMetadata(src,Config.Jerry["jerryItem"]) cb(GetItemMetadata(src,Config.Jerry["jerryItem"])) else cb(false) end else cb(false) end end end) CreateCallback('frkn-fuelstation:buyJerry', function(source,cb,data) local src = source local datatype = data.dataType if datatype == "basic" or datatype == "premium" then if priceControl(src,Config.Jerry[datatype]) == "success" then AddItem(source, Config.Jerry["jerryItem"], 1, {["type"] = datatype}) cb(Config.NotifyMenu["jerry"]["success"]) return else cb(Config.NotifyMenu["jerry"]["error"]) return end else if priceControl(src,Config.Jerry[datatype]) == "success" then AddItem(source, Config.Jerry["chargeItem"], 1, {["type"] = "electric"}) cb(Config.NotifyMenu["charge"]["success"]) return else cb(Config.NotifyMenu["charge"]["error"]) return end end end) function getDiscordImg(src) local identifiers = GetPlayerIdentifiers(src) if identifiers == nil then return "../images/defaultpp.webp" end local myIdentifier = nil for _, identifier in pairs(identifiers) do if string.find(identifier, "license:") then myIdentifier = identifier end end while myIdentifier == nil do Citizen.Wait(0) end local myDiscord = nil for _, identifier in pairs(identifiers) do if string.find(identifier, "discord:") then myDiscord = string.gsub(identifier, "discord:", "") end end local discordProfileAvatar = "../images/defaultpp.webp" while myDiscord == nil do Citizen.Wait(5000) if myDiscord == nil then break end end local endpoint = ("users/%s"):format(myDiscord) local member = DiscordRequest("GET", endpoint, {}) local memberData = json.decode(member.data) if memberData ~= nil then discordProfileAvatar = "https://cdn.discordapp.com/avatars/" .. myDiscord .. "/" .. memberData.avatar end return discordProfileAvatar end function DiscordRequest(method, endpoint, jsondata, reason) local FormattedToken = "Bot " .. Config.BokToken local data = nil PerformHttpRequest("https://discord.com/api/"..endpoint, function(errorCode, resultData, resultHeaders) data = {data=resultData, code=errorCode, headers=resultHeaders} end, method, #jsondata > 0 and jsondata or "", {["Content-Type"] = "application/json", ["Authorization"] = FormattedToken, ['X-Audit-Log-Reason'] = reason}) while data == nil do Citizen.Wait(0) end return data end CreateCallback('frkn-fuelstation:getdiscord', function(source, cb) local src = source local discordProfile = getDiscordImg(src) cb(discordProfile) end) --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS --discord.gg/fiveleaksontop FIVE LEAKS