Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
refactor: Use oxmysql lib
Browse files Browse the repository at this point in the history
  • Loading branch information
antond15 committed Mar 8, 2022
1 parent 795b93f commit 111e8b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ Config.CooldownMessage = 'The job can be changed once every 15 seconds.\n%s seco
Config.Discord = {
-- Change to false to disable Discord logging. If set to false, you can ignore the lines below.
Enable = true,

-- '%s' is automatically replaced in orded by player name, first job and second job.
Message = '**%s** changed his job from **%s** to **%s**.',

-- Discord webhook link.
Webhook = '',

-- Log message name.
Name = 'ac_switchjob | LOG',

-- Log message image.
Image = 'https://i.imgur.com/PpJ0Ffh.png',

-- Log embed color, in DECIMAL format. You can use this tool: https://www.rapidtables.com/convert/number/hex-to-decimal.html
Color = 3092790
}
Expand Down
5 changes: 3 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ game 'gta5'

author 'ANTOND.#8507'
description 'Simple switchjob script.'
version '1.2.1'
version '1.2.2'

server_only 'yes'

server_scripts {
'@oxmysql/lib/MySQL.lua',
'@es_extended/imports.lua',
'config.lua',
'server.lua'
}
}
8 changes: 4 additions & 4 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ RegisterCommand(Config.CommandName, function(source)

if cooldown[xPlayer.source] == nil or (GetGameTimer() - cooldown[xPlayer.source]) * 0.001 >= Config.Cooldown then

exports.oxmysql:execute('SELECT secondjob, secondjob_grade FROM users WHERE identifier = ?', {
MySQL.query('SELECT secondjob, secondjob_grade FROM users WHERE identifier = ?', {
xPlayer.identifier
}, function(result)

if result[1] ~= nil and result[1].secondjob ~= nil and result[1].secondjob_grade ~= nil then
exports.oxmysql:update('UPDATE users SET secondjob = @secondjob, secondjob_grade = @secondjob_grade WHERE identifier = @identifier', {
MySQL.update('UPDATE users SET secondjob = @secondjob, secondjob_grade = @secondjob_grade WHERE identifier = @identifier', {
secondjob = xPlayer.job.name,
secondjob_grade = xPlayer.job.grade,
identifier = xPlayer.identifier,
Expand Down Expand Up @@ -51,5 +51,5 @@ end



exports.oxmysql:execute('ALTER TABLE users ADD COLUMN IF NOT EXISTS secondjob VARCHAR(50) NOT NULL DEFAULT "unemployed"')
exports.oxmysql:execute('ALTER TABLE users ADD COLUMN IF NOT EXISTS secondjob_grade INT(11) NOT NULL DEFAULT 0')
MySQL.update('ALTER TABLE users ADD COLUMN IF NOT EXISTS secondjob VARCHAR(50) NOT NULL DEFAULT "unemployed"')
MySQL.update('ALTER TABLE users ADD COLUMN IF NOT EXISTS secondjob_grade INT(11) NOT NULL DEFAULT 0')

0 comments on commit 111e8b9

Please sign in to comment.