forked from JaredScar/DiscordDonatorPerks
-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.lua
114 lines (112 loc) · 3.41 KB
/
client.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
106
107
108
109
110
111
112
113
114
-------------------------------------
--- DiscordDonatorPerks by Badger ---
-------------------------------------
ESX = nil
Citizen.CreateThread(function ()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
AddEventHandler('playerSpawned', function()
if not alreadyTriggered then
TriggerServerEvent('PatreonDonatorPerks:CheckPerks');
alreadyTriggered = true;
end
end)
alreadyTriggered = false;
offers = {}
RegisterNetEvent('Perksy')
AddEventHandler('Perksy', function(offer)
print("AddOffer was triggered");
local temp = {}
for i = 1, #offers do
table.insert(temp, offers[i])
end
table.insert(temp, offer);
offers = temp;
print(#offers);
print("Temp: " .. #temp);
end)
RegisterNetEvent('PatreonDonatorPerks:Client:RemoveFromStack')
AddEventHandler('PatreonDonatorPerks:Client:RemoveFromStack', function()
-- Remove latest from top of stack
local temp = {}
for i = 2, #offers do
table.insert(temp, offers[i])
end
offers = temp;
end)
Citizen.CreateThread(function()
while true do
Wait(0);
local src = source;
if #offers > 0 then
-- They have offers
local label = offers[1][1];
if label == 'Money' then
local nameLab = offers[1][2];
local amt = offers[1][3];
Draw2DText(.5, .5, '~w~You have a ~g~' .. nameLab .. ' ~w~donator perk ', 1.0);
Draw2DText(.5, .55, '~y~Press ~b~ARROW_UP ~y~to accept or ~b~ARROW_DOWN ~y~to reject on this character...', 1.0);
end
if label == 'Job' then
local nameLab = offers[1][2];
local jobName = offers[1][3];
local jobGrade = offers[1][4];
Draw2DText(.5, .5, '~w~You have a donator perk for ~p~' .. nameLab
.. '~w~ of level grade ~p~' .. jobGrade, 1.0);
Draw2DText(.5, .55, '~y~Press ~b~ARROW_UP ~y~to accept or ~b~ARROW_DOWN ~y~to reject on this character...', 1.0);
end
end
end
end)
Citizen.CreateThread(function()
while true do
Wait(0);
if #offers > 0 then
local label = offers[1][1];
if (IsControlJustPressed(0, 172)) then -- They pressed ARROW_UP
if label == 'Money' then
local nameLab = offers[1][2];
local amt = offers[1][3];
TriggerServerEvent('PatreonDonatorPerks:GiveMoney', amt);
Wait(500);
end
if label == 'Job' then
local nameLab = offers[1][2];
local jobName = offers[1][3];
local jobGrade = offers[1][4];
TriggerServerEvent('PatreonDonatorPerks:GiveJob', jobName, jobGrade);
Wait(500);
end
TriggerEvent('PatreonDonatorPerks:Client:RemoveFromStack');
end
if (IsControlJustPressed(0, 173)) then -- They pressed ARROW_DOWN
if label == 'Job' then
local jobName = offers[1][3];
local jobGrade = offers[1][4];
TriggerServerEvent('PatreonDonatorPerks:DenyJob', jobName, jobGrade);
end
TriggerEvent('PatreonDonatorPerks:Client:RemoveFromStack');
Wait(500);
end
end
end
end)
function Draw2DText(x, y, text, scale)
-- Draw text on screen
SetTextFont(4)
SetTextProportional(7)
SetTextScale(scale, scale)
SetTextColour(255, 255, 255, 255)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextDropShadow()
SetTextEdge(4, 0, 0, 0, 255)
SetTextOutline()
SetTextJustification(0)
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x, y)
end
print("We get to bottom of client.lua");