diff --git a/config.lua b/config.lua index 822607d..2d54b81 100644 --- a/config.lua +++ b/config.lua @@ -2,7 +2,6 @@ Config = Config or {} Config.BillingCommissions = { -- This is a percentage (0.10) == 10% mechanic = 0.10 } -Config.Linux = false -- True if linux Config.TweetDuration = 12 -- How many hours to load tweets (12 will load the past 12 hours of tweets) Config.RepeatTimeout = 2000 Config.CallRepeats = 10 diff --git a/server/main.lua b/server/main.lua index a9b02d7..7eb4e59 100644 --- a/server/main.lua +++ b/server/main.lua @@ -7,7 +7,7 @@ local Calls = {} local Adverts = {} local GeneratedPlates = {} local WebHook = '' -local FivemerrApiToken = 'API_KEY_HERE' +local FivemerrApiToken = '' local bannedCharacters = { '%', '$', ';' } local TWData = {} @@ -34,14 +34,6 @@ local function escape_sqli(source) return source:gsub("['\"]", replacements) end -local function round(num, numDecimalPlaces) - if numDecimalPlaces and numDecimalPlaces > 0 then - local mult = 10 ^ numDecimalPlaces - return math.floor(num * mult + 0.5) / mult - end - return math.floor(num + 0.5) -end - function QBPhone.AddMentionedTweet(citizenid, TweetData) if MentionedTweets[citizenid] == nil then MentionedTweets[citizenid] = {} @@ -298,7 +290,7 @@ QBCore.Functions.CreateCallback('qb-phone:server:PayInvoice', function(source, c if exists[1] and exists[1]["count"] == 1 then if SenderPly and Config.BillingCommissions[society] then - local commission = round(amount * Config.BillingCommissions[society]) + local commission = QBCore.Shared.Round(amount * Config.BillingCommissions[society]) SenderPly.Functions.AddMoney('bank', commission) invoiceMailData = { sender = 'Billing Department', @@ -613,7 +605,7 @@ end) QBCore.Functions.CreateCallback('qb-phone:server:UploadToFivemerr', function(source, cb) local src = source - if Config.Fivemerr == '' then + if Config.Fivemerr == true and FivemerrApiToken == '' then print("^1--- Fivemerr is enabled but no API token has been specified. ---^7") return cb(nil) end @@ -841,31 +833,18 @@ end) RegisterNetEvent('qb-phone:server:UpdateTweets', function(NewTweets, TweetData) local src = source - if Config.Linux then - MySQL.insert('INSERT INTO phone_tweets (citizenid, firstName, lastName, message, date, url, picture, tweetid) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', { - TweetData.citizenid, - TweetData.firstName, - TweetData.lastName, - TweetData.message, - TweetData.date, - TweetData.url:gsub('[%<>\"()\' $]', ''), - TweetData.picture:gsub('[%<>\"()\' $]', ''), - TweetData.tweetId - }) - TriggerClientEvent('qb-phone:client:UpdateTweets', -1, src, NewTweets, TweetData, false) - else - MySQL.insert('INSERT INTO phone_tweets (citizenid, firstName, lastName, message, date, url, picture, tweetid) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', { - TweetData.citizenid, - TweetData.firstName, - TweetData.lastName, - TweetData.message, - TweetData.time, - TweetData.url:gsub('[%<>\"()\' $]', ''), - TweetData.picture:gsub('[%<>\"()\' $]', ''), - TweetData.tweetId - }) - TriggerClientEvent('qb-phone:client:UpdateTweets', -1, src, NewTweets, TweetData, false) - end + + MySQL.insert('INSERT INTO phone_tweets (citizenid, firstName, lastName, message, date, url, picture, tweetid) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', { + TweetData.citizenid, + TweetData.firstName, + TweetData.lastName, + TweetData.message, + TweetData.time, + TweetData.url:gsub('[%<>\"()\' $]', ''), + TweetData.picture:gsub('[%<>\"()\' $]', ''), + TweetData.tweetId + }) + TriggerClientEvent('qb-phone:client:UpdateTweets', -1, src, NewTweets, TweetData, false) end) RegisterNetEvent('qb-phone:server:TransferMoney', function(iban, amount) @@ -888,7 +867,7 @@ RegisterNetEvent('qb-phone:server:TransferMoney', function(iban, amount) end else local moneyInfo = json.decode(result[1].money) - moneyInfo.bank = round((moneyInfo.bank + amount)) + moneyInfo.bank = QBCore.Shared.Round(moneyInfo.bank + amount) MySQL.update('UPDATE players SET money = ? WHERE citizenid = ?', { json.encode(moneyInfo), result[1].citizenid }) sender.Functions.RemoveMoney('bank', amount, 'phone-transfered')