Skip to content

Commit

Permalink
Merge pull request #401 from mbiddle/main
Browse files Browse the repository at this point in the history
Fix Fivemerr bug and Tweets on Linux hosts bug
  • Loading branch information
GhzGarage authored Jan 24, 2025
2 parents 9f32c41 + dcd652f commit 6f205f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 38 deletions.
1 change: 0 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 16 additions & 37 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local Calls = {}
local Adverts = {}
local GeneratedPlates = {}
local WebHook = ''
local FivemerrApiToken = 'API_KEY_HERE'
local FivemerrApiToken = ''
local bannedCharacters = { '%', '$', ';' }
local TWData = {}

Expand All @@ -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] = {}
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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')
Expand Down

0 comments on commit 6f205f5

Please sign in to comment.