Skip to content

Commit 6f205f5

Browse files
authored
Merge pull request #401 from mbiddle/main
Fix Fivemerr bug and Tweets on Linux hosts bug
2 parents 9f32c41 + dcd652f commit 6f205f5

File tree

2 files changed

+16
-38
lines changed

2 files changed

+16
-38
lines changed

config.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Config = Config or {}
22
Config.BillingCommissions = { -- This is a percentage (0.10) == 10%
33
mechanic = 0.10
44
}
5-
Config.Linux = false -- True if linux
65
Config.TweetDuration = 12 -- How many hours to load tweets (12 will load the past 12 hours of tweets)
76
Config.RepeatTimeout = 2000
87
Config.CallRepeats = 10

server/main.lua

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local Calls = {}
77
local Adverts = {}
88
local GeneratedPlates = {}
99
local WebHook = ''
10-
local FivemerrApiToken = 'API_KEY_HERE'
10+
local FivemerrApiToken = ''
1111
local bannedCharacters = { '%', '$', ';' }
1212
local TWData = {}
1313

@@ -34,14 +34,6 @@ local function escape_sqli(source)
3434
return source:gsub("['\"]", replacements)
3535
end
3636

37-
local function round(num, numDecimalPlaces)
38-
if numDecimalPlaces and numDecimalPlaces > 0 then
39-
local mult = 10 ^ numDecimalPlaces
40-
return math.floor(num * mult + 0.5) / mult
41-
end
42-
return math.floor(num + 0.5)
43-
end
44-
4537
function QBPhone.AddMentionedTweet(citizenid, TweetData)
4638
if MentionedTweets[citizenid] == nil then
4739
MentionedTweets[citizenid] = {}
@@ -298,7 +290,7 @@ QBCore.Functions.CreateCallback('qb-phone:server:PayInvoice', function(source, c
298290

299291
if exists[1] and exists[1]["count"] == 1 then
300292
if SenderPly and Config.BillingCommissions[society] then
301-
local commission = round(amount * Config.BillingCommissions[society])
293+
local commission = QBCore.Shared.Round(amount * Config.BillingCommissions[society])
302294
SenderPly.Functions.AddMoney('bank', commission)
303295
invoiceMailData = {
304296
sender = 'Billing Department',
@@ -613,7 +605,7 @@ end)
613605
QBCore.Functions.CreateCallback('qb-phone:server:UploadToFivemerr', function(source, cb)
614606
local src = source
615607

616-
if Config.Fivemerr == '' then
608+
if Config.Fivemerr == true and FivemerrApiToken == '' then
617609
print("^1--- Fivemerr is enabled but no API token has been specified. ---^7")
618610
return cb(nil)
619611
end
@@ -841,31 +833,18 @@ end)
841833

842834
RegisterNetEvent('qb-phone:server:UpdateTweets', function(NewTweets, TweetData)
843835
local src = source
844-
if Config.Linux then
845-
MySQL.insert('INSERT INTO phone_tweets (citizenid, firstName, lastName, message, date, url, picture, tweetid) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
846-
TweetData.citizenid,
847-
TweetData.firstName,
848-
TweetData.lastName,
849-
TweetData.message,
850-
TweetData.date,
851-
TweetData.url:gsub('[%<>\"()\' $]', ''),
852-
TweetData.picture:gsub('[%<>\"()\' $]', ''),
853-
TweetData.tweetId
854-
})
855-
TriggerClientEvent('qb-phone:client:UpdateTweets', -1, src, NewTweets, TweetData, false)
856-
else
857-
MySQL.insert('INSERT INTO phone_tweets (citizenid, firstName, lastName, message, date, url, picture, tweetid) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
858-
TweetData.citizenid,
859-
TweetData.firstName,
860-
TweetData.lastName,
861-
TweetData.message,
862-
TweetData.time,
863-
TweetData.url:gsub('[%<>\"()\' $]', ''),
864-
TweetData.picture:gsub('[%<>\"()\' $]', ''),
865-
TweetData.tweetId
866-
})
867-
TriggerClientEvent('qb-phone:client:UpdateTweets', -1, src, NewTweets, TweetData, false)
868-
end
836+
837+
MySQL.insert('INSERT INTO phone_tweets (citizenid, firstName, lastName, message, date, url, picture, tweetid) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
838+
TweetData.citizenid,
839+
TweetData.firstName,
840+
TweetData.lastName,
841+
TweetData.message,
842+
TweetData.time,
843+
TweetData.url:gsub('[%<>\"()\' $]', ''),
844+
TweetData.picture:gsub('[%<>\"()\' $]', ''),
845+
TweetData.tweetId
846+
})
847+
TriggerClientEvent('qb-phone:client:UpdateTweets', -1, src, NewTweets, TweetData, false)
869848
end)
870849

871850
RegisterNetEvent('qb-phone:server:TransferMoney', function(iban, amount)
@@ -888,7 +867,7 @@ RegisterNetEvent('qb-phone:server:TransferMoney', function(iban, amount)
888867
end
889868
else
890869
local moneyInfo = json.decode(result[1].money)
891-
moneyInfo.bank = round((moneyInfo.bank + amount))
870+
moneyInfo.bank = QBCore.Shared.Round(moneyInfo.bank + amount)
892871
MySQL.update('UPDATE players SET money = ? WHERE citizenid = ?',
893872
{ json.encode(moneyInfo), result[1].citizenid })
894873
sender.Functions.RemoveMoney('bank', amount, 'phone-transfered')

0 commit comments

Comments
 (0)