-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.lua
105 lines (91 loc) · 5.51 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
local QBCore = exports['qb-core']:GetCoreObject()
lib.callback.register('pl-checkplayermoney:server:checkbank', function(source, minimumBankAmount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local Identifier = QBCore.Functions.GetIdentifier(src, 'license')
local PlayerName = Player.PlayerData.charinfo.firstname ..' '.. Player.PlayerData.charinfo.lastname
if Player.PlayerData.job and Player.PlayerData.job.name == Config.AllowedJob then
local query = "SELECT citizenid, name, JSON_EXTRACT(money, '$.bank') AS bank_amount FROM players WHERE CAST(JSON_EXTRACT(money, '$.bank') AS DECIMAL) > " .. minimumBankAmount .. ";"
MySQL.Async.fetchAll(query, {}, function(result)
if result then
local playerData = {}
for _, row in ipairs(result) do
local playerId = row.citizenid
local playerName = row.name
local playerBankAmount = row.bank_amount
table.insert(playerData, {cid = playerId, name = playerName, bankAmount = playerBankAmount})
end
TriggerClientEvent('pl-checkplayermoney:SendPlayerBank', source, playerData)
else
TriggerClientEvent('pl-checkplayermoney:notification',src,'No Result Fetched from the database','error')
end
end)
else
print('**Name:** '..PlayerName..'\n**Identifier:** '..Identifier..' Player tried to check players money. Most Probably a Cheater')
end
end)
lib.callback.register('pl-checkplayermoney:server:checkcashandcrypto', function(source, minimumBankAmount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local Identifier = QBCore.Functions.GetIdentifier(src, 'license')
local PlayerName = Player.PlayerData.charinfo.firstname ..' '.. Player.PlayerData.charinfo.lastname
if Player.PlayerData.job and Player.PlayerData.job.name == Config.AllowedJob then
local query = "SELECT citizenid, name, JSON_EXTRACT(money, '$.bank') AS bank_amount, JSON_EXTRACT(money, '$.crypto') AS crypto_amount, JSON_EXTRACT(money, '$.cash') AS cash_amount FROM players WHERE CAST(JSON_EXTRACT(money, '$.bank') AS DECIMAL) > " .. minimumBankAmount .. ";"
MySQL.Async.fetchAll(query, {}, function(result)
if result then
local playerData = {}
for _, row in ipairs(result) do
local playerId = row.citizenid
local playerName = row.name
local playerBankAmount = row.bank_amount
local cryptoAmount = row.crypto_amount
local cashAmount = row.cash_amount
table.insert(playerData, {cid = playerId, name = playerName, bankAmount = playerBankAmount,crypto_amount= cryptoAmount,cash_amount=cashAmount})
end
TriggerClientEvent('pl-checkplayermoney:SendPlayerCashandCrypto', source, playerData)
else
TriggerClientEvent('pl-checkplayermoney:notification',src,'No Result Fetched from the database','error')
end
end)
else
print('**Name:** '..PlayerName..'\n**Identifier:** '..Identifier..' Player tried to check players money. Most Probably a Cheater')
end
end)
lib.callback.register('pl-checkplayermoney:server:checktoppeople', function(source, toppeople)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local Identifier = QBCore.Functions.GetIdentifier(src, 'license')
local PlayerName = Player.PlayerData.charinfo.firstname ..' '.. Player.PlayerData.charinfo.lastname
if Player.PlayerData.job and Player.PlayerData.job.name == Config.AllowedJob then
local query = "SELECT citizenid, name, JSON_EXTRACT(money, '$.bank') AS bank_amount, JSON_EXTRACT(money, '$.crypto') AS crypto_amount, JSON_EXTRACT(money, '$.cash') AS cash_amount FROM players ORDER BY CAST(JSON_EXTRACT(money, '$.bank') AS DECIMAL) DESC LIMIT " .. toppeople .. ";"
MySQL.Async.fetchAll(query, {}, function(result)
if result then
local playerData = {}
for _, row in ipairs(result) do
local playerId = row.citizenid
local playerName = row.name
local playerBankAmount = row.bank_amount
local cryptoAmount = row.crypto_amount
local cashAmount = row.cash_amount
table.insert(playerData, {cid = playerId, name = playerName, bankAmount = playerBankAmount, crypto_amount = cryptoAmount, cash_amount=cashAmount})
end
TriggerClientEvent('pl-checkplayermoney:SendPlayerCashandCrypto', source, playerData)
else
TriggerClientEvent('pl-checkplayermoney:notification',src,'No Result Fetched from the database','error')
end
end)
else
print('**Name:** '..PlayerName..'\n**Identifier:** '..Identifier..' Player tried to check players money. Most Probably a Cheater')
end
end)
RegisterCommand(Config.Command, function(source)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player and Player.PlayerData then
if Player.PlayerData.job and Player.PlayerData.job.name == Config.AllowedJob then
TriggerClientEvent('pl-checkplayermoney:openmenu', src)
else
TriggerClientEvent('pl-checkplayermoney:notification', src, 'You are not allowed to use this', 'error')
end
end
end)