Jobs = { ['unemployed'] = { ['label'] = 'Unemployed', ['business'] = false, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = false, ['locations'] = {} }, ['ambulance'] = { ['label'] = 'Mount Zonah', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-447.16, -353.64, 24.22), vector3(-471.09, -364.96, 24.22), vector3(-425.34, -343.32, 24.22), vector3(-447.32, -318.69, 78.16), vector3(1822.88, 3666.58, 34.27), vector3(-265.32, 6330.29, 32.41)} }, -- ['bennys'] = { ['label'] = 'Bennys', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vec3(-227.51, -1327.42, 30.89)} }, ['doj'] = { ['label'] = 'Department of Justice', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(241.25, -1100.43, 36.12)} }, ['flywheels'] = { ['label'] = 'Carbon N\' Chrome', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-1417.24, -446.16, 35.9)} }, ['fmb'] = { ['label'] = 'Fat Mikes Bar', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vec3(-433.28, 273.68, 83.42)} }, ['garbage'] = { ['label'] = 'Garbage Collection', ['business'] = false, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = false, ['locations'] = {} }, ['gopostal'] = { ['label'] = 'Go Postal', ['business'] = false, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = false, ['locations'] = {} }, ['jimsburger'] = { ['label'] = 'Hobo Jim\'s Burger Shack', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(108.4, -1079.22, 29.18)} }, ['jt3nv7'] = { ['label'] = 'Auto Exotic', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(912.82, -967.81, 39.49)} }, ['lostmc'] = { ['label'] = 'LostMC', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vec3(998.68, -124.25, 74.06)} }, ['lumberjack'] = { ['label'] = 'Lumberjack', ['business'] = false, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = false, ['locations'] = {} }, ['miner'] = { ['label'] = 'Miner', ['business'] = false, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = false, ['locations'] = {} }, ['construction'] = { ['label'] = 'Construction', ['business'] = false, ['dbId'] = 0, ['grades'] = { [1] = { label = 'Employee', moneys = 50, owner = 0 } }, ['hasGarage'] = false, ['locations'] = {} }, ['banker'] = { ['label'] = 'Banker', ['business'] = false, ['dbId'] = 0, ['grades'] = { [1] = { label = 'Employee', moneys = 50, owner = 0 } }, ['hasGarage'] = false, ['locations'] = {} }, ['pdm'] = { ['label'] = 'Luxury Autos', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-33.53, -1102.09, 26.42)} }, ['pizzaboy'] = { ['label'] = 'Pizza Boy', ['business'] = false, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = false, ['locations'] = {} }, ['realestate'] = { ['label'] = 'Dynasty 8', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-104.87, -610.17, 36.07), vector3(-155.45, -593.59, 32.41)} }, ['taco'] = { ['label'] = 'Taco', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vec3(11.53, -1599.48, 29.30)} }, ['taxi'] = { ['label'] = 'Taxi', ['business'] = false, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(913.73, -166.46, 74.32)} }, ['trucker'] = { ['label'] = 'Trucker', ['business'] = false, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = false, ['locations'] = {} }, ['vanilla'] = { ['label'] = 'Vanilla Unicorn', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(129.9, -1284.36, 29.26)} }, ['pa'] = { ['label'] = 'Public Affairs', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(444.55, -999.47, 25.91), vector3(1868.1, 3686.14, 33.78), vector3(1736.69, 2578.54, 61.68), vector3(1644.01, 2603.21, 45.56), vector3(1835.35, 2506.01, 47.56), vector3(1833.44, 2541.96, 45.88)} }, ['weazelnews'] = { ['label'] = 'Weazel News', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-616.0, -924.15, 23.08), vector3(-557.74, -931.71, 23.85)} }, ['potato'] = { ['label'] = 'TopHat Potatoes', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-90.49, 1886.89, 197.32)} }, ['cdmortuary'] = { ['label'] = 'Cloudy Days Mortuary', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(262.54, -1378.58, 39.52)} }, ['gatsnstraps'] = { ['label'] = 'Chi Chi\'s L&L', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = false, ['locations'] = {} }, -- Police ['lspd'] = { ['label'] = 'LSPD', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(444.55, -999.47, 25.91), vector3(1868.1, 3686.14, 33.78), vector3(478.085, -1022.866, 28.03562), vector3(1736.69, 2578.54, 61.68), vector3(1644.01, 2603.21, 45.56), vector3(1835.35, 2506.01, 47.56), vector3(1833.44, 2541.96, 45.88)} }, ['bcso'] = { ['label'] = 'BCSO', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(444.55, -999.47, 25.91), vector3(1868.1, 3686.14, 33.78), vector3(478.085, -1022.866, 28.03562), vector3(1736.69, 2578.54, 61.68), vector3(1644.01, 2603.21, 45.56), vector3(1835.35, 2506.01, 47.56), vector3(1833.44, 2541.96, 45.88)} }, ['sahp'] = { ['label'] = 'SASP', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(444.55, -999.47, 25.91), vector3(1868.1, 3686.14, 33.78), vector3(478.085, -1022.866, 28.03562), vector3(1736.69, 2578.54, 61.68), vector3(1644.01, 2603.21, 45.56), vector3(1835.35, 2506.01, 47.56), vector3(1833.44, 2541.96, 45.88)} }, ['sasp'] = { ['label'] = 'SASP', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(444.55, -999.47, 25.91), vector3(1868.1, 3686.14, 33.78), vector3(478.085, -1022.866, 28.03562), vector3(1736.69, 2578.54, 61.68), vector3(1644.01, 2603.21, 45.56), vector3(1835.35, 2506.01, 47.56), vector3(1833.44, 2541.96, 45.88)} }, ['doc'] = { ['label'] = 'DOC', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(444.55, -999.47, 25.91), vector3(1868.1, 3686.14, 33.78), vector3(478.085, -1022.866, 28.03562), vector3(1736.69, 2578.54, 61.68), vector3(1644.01, 2603.21, 45.56), vector3(1835.35, 2506.01, 47.56), vector3(1833.44, 2541.96, 45.88)} }, ['sapr'] = { ['label'] = 'SAPR', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(444.55, -999.47, 25.91), vector3(1868.1, 3686.14, 33.78), vector3(478.085, -1022.866, 28.03562), vector3(1736.69, 2578.54, 61.68), vector3(1644.01, 2603.21, 45.56), vector3(1835.35, 2506.01, 47.56), vector3(1833.44, 2541.96, 45.88)} }, -- Businesses ['driftclub'] = { ['label'] = 'Drift Club', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true }, ['legacyrecords'] = { ['label'] = 'Legacy Records', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-1387.54, -608.95, 30.31), vector3(195.4, -11.53, 69.89)} }, ['luxurytransportation'] = { ['label'] = 'Luxury Transportation', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(913.73, -166.46, 74.32), vector3(934.55, -1.9, 78.75)} }, ['pegasusairlines'] = { ['label'] = 'Pegasus Airlines', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-1655.78, -3149.68, 13.98)} }, ['cmmc'] = { ['label'] = 'Cork Memorial Medical Center', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(1822.88, 3666.58, 34.27)} }, ['casino'] = { ['label'] = 'Diamond Casino', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(934.55, -1.9, 78.75)} }, ['committee'] = { ['label'] = 'State Committee', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = false, ['locations'] = {} }, ['legacym'] = { ['label'] = 'Legacy', ['business'] = true, ['dbId'] = 0, ['grades'] = { [1] = { label = 'Cool Singer', moneys = 250, owner = 0 } }, ['hasGarage'] = true, ['locations'] = {vector3(444.55, -999.47, 25.91), vector3(1868.1, 3686.14, 33.78)} }, -- Thorhall's Holistic Center ['thc'] = { ['label'] = 'Thorhall\'s Holistic Center', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(377.748, -828.7451, 29.3025)} }, ['f1'] = { ['label'] = 'F1', ['business'] = true, ['dbId'] = 0, ['grades'] = { [1] = { label = 'Employee', moneys = 0, owner = 0 } }, ['hasGarage'] = false, ['locations'] = {} }, -- SooChi Resturaunt ['soochi'] = { ['label'] = 'SooChi', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-1839.9, -1214.47, 13.0)} }, -- Level Up Lounge ['levelup'] = { ['label'] = 'Level Up Lounge', ['business'] = true, ['dbId'] = 0, ['grades'] = { [1] = {owner = 1} }, ['hasGarage'] = true, ['locations'] = {vector3(334.64, -914.1, 29.25)} }, -- Bikes R Us ['bikesrus'] = { ['label'] = 'Bikes R Us', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-64.72324, 70.01147, 71.87317)} }, -- Drift School ['driftschool'] = { ['label'] = 'Drift School', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(977.06, -2358.83, 21.21)} }, -- Sideways University ['sidewaysu'] = { ['label'] = 'Sideways University', ['business'] = true, ['dbId'] = 0, ['grades'] = {}, ['hasGarage'] = true, ['locations'] = {vector3(-65.34, -2526.28, 5.99)} }, } --[[ INSERT INTO `echorp`.`jobgrades` (`job`, `grade`, `label`, `money`) VALUES ('bikesrus', '1', 'Employee', '0'); INSERT INTO `echorp`.`jobgrades` (`job`, `grade`, `label`, `money`) VALUES ('bikesrus', '2', 'Placeholder', '0'); INSERT INTO `echorp`.`jobgrades` (`job`, `grade`, `label`, `money`) VALUES ('bikesrus', '3', 'Placeholder', '0'); INSERT INTO `echorp`.`jobgrades` (`job`, `grade`, `label`, `money`) VALUES ('bikesrus', '4', 'Placeholder', '0'); INSERT INTO `echorp`.`jobgrades` (`job`, `grade`, `label`, `money`, `owner`) VALUES ('bikesrus', '5', 'CEO', '0', '1'); ]] CreateThread(function() if IsDuplicityVersion() then exports.oxmysql:fetch('SELECT `id`, `name` FROM `businesses`', {}, function(data) local function BusinessInSQL(name) for i=1, #data do if data[i]['name'] == name then return data[i]['id'] end end return -1 end for k,v in pairs(Jobs) do if v.business then local BusinessStatus = BusinessInSQL(k) if type(BusinessStatus) == 'number' and BusinessStatus > 0 then v.dbId = BusinessStatus elseif BusinessStatus == -1 then exports.oxmysql:insert("INSERT INTO businesses (`name`) VALUES (:name)", { name = k }, function(insertId) if insertId then v.dbId = insertId print("[Jobs] Created Business: "..v['label'].." ("..v['dbId']..")") end end) end exports.oxmysql:fetch('SELECT * FROM `jobgrades` WHERE job=:job LIMIT 1', { job = k }, function(result) if #result == 0 then exports.oxmysql:insert("INSERT INTO jobgrades (`job`, `grade`, `label`, `owner`) VALUES (:job, :grade, :label, :owner)", { job = k, grade = 1, label = 'Owner', owner = 1 }, function(insertId) if insertId then v.dbId = insertId print("[Jobs] Created Owner Rank: "..v['label'].." ("..v['dbId']..")") end end) end end) end end end) Wait(250) exports.oxmysql:fetch('SELECT `id`, `job`, `grade`, `label`, `money`, `owner` FROM `jobgrades`', {}, function(result) for i=1, #result do if result[i] then local data = result[i] if Jobs[data['job']] then Jobs[data['job']]['grades'][tonumber(data['grade'])] = { databaseid = data['id'], label = data['label'], moneys = tonumber(data['money']), owner = data['owner'] } end end end end) AddEventHandler('echorp:adjustowner', function(job, grade, level, src) local gradeInfo = Jobs[job]['grades'][grade] exports.oxmysql:execute('UPDATE `jobgrades` SET owner=:owner WHERE id=:id', {owner = tonumber(level), id = gradeInfo['databaseid']}, function(result) if result then Jobs[job]['grades'][grade]['owner'] = tonumber(level) local ownerLevel = "" if level == 1 then ownerLevel = "Full Access" elseif level == 2 then ownerLevel = "User Management" elseif level == 3 then ownerLevel = "Society Management" end if level ~= 0 then TriggerClientEvent('mythic_notify:client:SendAlert', src, { type = 'inform', text = 'Access for '..Jobs[job]['grades'][grade]['label']..' rank set to '..ownerLevel, length = 5000 }) else TriggerClientEvent('mythic_notify:client:SendAlert', src, { type = 'inform', text = 'All management access removed from '..Jobs[job]['grades'][grade]['label']..'.', length = 5000 }) end end end) end) AddEventHandler('echorp:adjustsalary', function(job, grade, salary, src) local gradeInfo = Jobs[job]['grades'][grade] exports.oxmysql:execute('UPDATE `jobgrades` SET money=:money WHERE id=:id', {money = salary, id = gradeInfo['databaseid']}, function(result) if result then Jobs[job]['grades'][grade]['moneys'] = salary TriggerClientEvent('mythic_notify:client:SendAlert', src, { type = 'inform', text = 'Salary is now $'..salary, length = 5000 }) end end) end) AddEventHandler('echorp:adjustname', function(job, grade, newname, src) local gradeInfo = Jobs[job]['grades'][grade] exports.oxmysql:execute('UPDATE `jobgrades` SET label=:label WHERE id=:id', {label = newname, id = gradeInfo['databaseid']}, function(result) if result then Jobs[job]['grades'][grade]['label'] = newname TriggerClientEvent('mythic_notify:client:SendAlert', src, { type = 'inform', text = 'Rank name update to '..newname, length = 5000 }) end end) end) AddEventHandler('echorp:updatejobgrades', function(job) Jobs[job]['grades'] = {} Wait(500) exports.oxmysql:fetch('SELECT `id`, `job`, `grade`, `label`, `money`, `owner` FROM `jobgrades` WHERE job=:job', {job = job}, function(result) for i=1, #result do if result[i] then local data = result[i] if Jobs[data['job']] then Jobs[data['job']]['grades'][tonumber(data['grade'])] = { databaseid = data['id'], label = data['label'], moneys = tonumber(data['money']), owner = data['owner'] } end end end end) end) end end) AddEventHandler('echorp:getJobInfo', function(sentJob, cb) cb(Jobs[sentJob]) end) function GetJobInfo(sentJob) return Jobs[sentJob] end exports('GetJobInfo', GetJobInfo) -- exports['echorp']:GetJobInfo(job)