Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Fivemerr bug and Tweets on Linux hosts bug #401

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading