· 7 years ago · Oct 08, 2018, 07:32 PM
1local con = dbConnect("sqlite", ":/registry.db")
2dbExec(con, "CREATE TABLE IF NOT EXISTS supporters ('accountName')")
3
4supporters = {}
5
6function supportersToTable(query)
7 local result = dbPoll(query, 0)
8 for i, data in pairs(result) do
9 if (data) then
10 supporters[data['accountName']] = true
11 end
12 end
13end
14dbQuery(supportersToTable, con, "SELECT * FROM supporters")
15
16function addSupporter(player, commandName, ...)
17 if (exports.CITanticheat:spamCheck(player, "Supporter add")) then return end
18 if (not (exports.CITadmin:getPlayerAdminLevel(player) == 5)) then return end
19 local accountName = table.concat({...}, " ")
20 if (not accountName) then
21 outputChatBox("Unsuccessful: syntax is '/addsupporter accountname'", player)
22 return
23 end
24 local account = getAccount(accountName)
25 if (not account) then
26 outputChatBox("Unsuccessful: account does not exsist", player)
27 return
28 end
29 if (supporters[accountName]) then
30 outputChatBox("Unsuccessful: account already added as supporter", player)
31 return
32 end
33 dbExec(con, "INSERT INTO supporters VALUES (?)", accountName)
34 supporters[accountName] = true
35 outputChatBox("Successfully added player with account name "..accountName.." as supporter", player)
36 local target = getAccountPlayer(account)
37 if (target) then
38 triggerClientEvent(target, "onSupporterLogin", target)
39 end
40end
41addCommandHandler("addsupporter", addSupporter)