Skip to content

Commit

Permalink
update(server/db): insert name fíeld
Browse files Browse the repository at this point in the history
  • Loading branch information
mikigoalie committed Nov 6, 2023
1 parent bc515f5 commit f4d1eb4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/modules/database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local db = {}
---@param {string} data.vehicleName - A name of the vehicle.

db.addVehicle = function(data)
return MySQL.insert.await('INSERT INTO owned_vehicles (`owner`, `plate`, `vehicle`, `stored`, `type`) VALUES (?, ?, ?, ?, ?)', {data.identifier, data.plate, data.properties, not hasFreeCoords, data.vehicleType})
return MySQL.insert.await('INSERT INTO owned_vehicles (`owner`, `plate`, `vehicle`, `stored`, `type`, `name`) VALUES (?, ?, ?, ?, ?, ?)', {data.identifier, data.plate, data.properties, not hasFreeCoords, data.vehicleType, data.vehicleName})
end

db.select = function(query, params)
Expand Down
17 changes: 17 additions & 0 deletions server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ local function initializedThread()
return
end


result = MySQL.query.await(('SHOW COLUMNS FROM `%s`'):format(Config.vehicleTable, {indent=true}))
local nameField = false

for i = 1, #result do
if result[i].Field == 'name' then
nameField = true
end
end

if not nameField then
dprint(('Inserting `nameField` in `%s`'):format(Config.vehicleTable))
MySQL.query(('ALTER TABLE `%s` ADD COLUMN `name` VARCHAR(40) DEFAULT `Unknown`'):format(Config.vehicleTable))
end



print('$$\\ $$$$$$\\ $$$$$$$\\ $$$$$$$\\ ')
print('$$ | $$ __$$\\$$ __$$\\$$ __$$\\ ')
print('$$ | $$ / \\__$$ | $$ $$ | $$ |')
Expand Down
11 changes: 6 additions & 5 deletions shared/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ Config = {}

--[[ Main section ]]--
Config.debug = true
Config.useFrontEndSounds = true -- Whether you want usage of sound fx
Config.cacheIndexes = true -- Menu select indexes will save upon closing menu
Config.menuPosition = 'right' -- OX Menu pos
Config.textDistance = 1.0 -- Text UI distance
Config.notifDuration = 10000 -- Default notif duration
Config.vehicleTable = "owned_vehicles"
Config.useFrontEndSounds = true -- Whether you want usage of sound fx
Config.cacheIndexes = true -- Menu select indexes will save upon closing menu
Config.menuPosition = 'right' -- OX Menu pos
Config.textDistance = 1.0 -- Text UI distance
Config.notifDuration = 10000 -- Default notif duration
Config.oxTarget = false
Config.logging = 'https://discord.com/api/webhooks/1168648895203639306/7HgonEmJVPWhPpmwjef869ajO6dH5eYQWG3PhbFo8on3o223w1aNlie7JzdPlJkT5xv5' -- oxlogger or 'YOUR_WEBHOOK'

Expand Down

0 comments on commit f4d1eb4

Please sign in to comment.