-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.lua
322 lines (290 loc) · 10.5 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
local Keys = {
["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}
---esx
local ESX = nil
local PlayerData = {}
local fname = nil
-- Servern callback
RegisterNetEvent('jsfour-legitimation:open')
AddEventHandler('jsfour-legitimation:open', function(playerData)
cardOpen = true
SendNUIMessage({
action = "open",
array = playerData
})
end)
-- ESX
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
PlayerData.job = job
end)
AddEventHandler('esx:onPlayerDeath', function(data)
isDead = true
end)
AddEventHandler('playerSpawned', function(spawn)
isDead = false
end)
-- TRIGGER FÖR TELEFONEN.
RegisterNetEvent('esx_aktier:starten')
AddEventHandler('esx_aktier:starten', function()
ESX.TriggerServerCallback('esx_aktier:kollatid', function(cb)
if cb == false then
return
else
openMenu()
end
end)
end)
--- meny för börsen.
function openMenu()
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'f3_menu',
{
title = 'ColoursNet Börsen',
align = 'bottom-right',
elements = {
{label = 'Syntheria Bank AB', value = 'id-card'},
{label = 'Äpple Och Päron', value = 'citizen'},
{label = 'Flytta Pengarna från Aktiekonto till Banken', value = 'flyttapengar'},
}
},
function(data, menu)
-- FLYTTA PENGAR FRÅN AKTIEKONTO TILL BANKEN
if data.current.value == 'flyttapengar' then
TriggerServerEvent('esx_aktier:flyttapengar')
-- SYNTHERIA BANK AB
elseif data.current.value == 'id-card' then
fname = 'syntheria'
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'id_card_menu',
{
title = 'Syntheria Bank AB',
align = 'bottom-right',
elements = {
{label = 'Köp Aktier', value = 'kopaktier'},
{label = 'Sälj Aktier', value = 'saljaktier'},
{label = 'Kolla sina aktier', value = 'kollaaktier'},
}
},
function(data2, menu2)
-- Köp Aktier
if data2.current.value == 'kopaktier' then
local elements = {}
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
title = 'Hur många Aktier vill du köpa?'
}, function (data2, menu2)
local count = tonumber(data2.value)
if count == nil then
TriggerEvent('esx:showNotification', 'Du kan inte köpa 0st aktier.')
else
TriggerServerEvent('esx_aktier:kopaktier', count, fname)
menu2.close()
menu.close()
end
end, function (data2, menu2)
menu2.close()
menu.close()
end)
-- Sälj Aktier
elseif data2.current.value == 'saljaktier' then
local elements = {}
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
title = 'Hur många Aktier vill du sälja?'
}, function (data2, menu2)
local count = tonumber(data2.value)
if count == nil then
TriggerEvent('esx:showNotification', 'Du kan inte sälja 0st aktier.')
else
menu2.close()
menu.close()
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
title = 'Vilket pris vill du sälja de för?'
}, function (data2, menu2)
local count1 = tonumber(data2.value)
if count1 == nil then
TriggerEvent('esx:showNotification', 'Du kan inte sälja dina aktier för 0kr.')
else
TriggerServerEvent('esx_aktier:saljaktier',count ,count1 ,fname)
menu2.close()
end
end, function (data2, menu2)
menu2.close()
end)
end
end, function (data2, menu2)
menu2.close()
menu.close()
end)
elseif data2.current.value == 'kollaaktier' then
TriggerServerEvent('esx_aktier:kollaaktier', fname)
end
end, function(data2, menu2)
menu2.close()
end)
-- PÄRON OCH ÄPPLE AB
elseif data.current.value == 'citizen' then
fname = 'paron'
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'id_card_menu',
{
title = 'Päron och Äpple AB',
align = 'bottom-right',
elements = {
{label = 'Köp Aktier', value = '1kopaktier'},
{label = 'Sälj Aktier', value = '1saljaktier'},
{label = 'Kolla sina aktier', value = '1kollaaktier'},
}
},
function(data2, menu2)
-- Köp Aktier
if data2.current.value == '1kopaktier' then
local elements = {}
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
title = 'Hur många Aktier vill du köpa?'
}, function (data2, menu2)
local count = tonumber(data2.value)
if count == nil then
TriggerEvent('esx:showNotification', 'Du kan inte köpa 0st aktier.')
else
TriggerServerEvent('esx_aktier:kopaktier', count, fname)
menu2.close()
menu.close()
end
end, function (data2, menu2)
menu2.close()
menu.close()
end)
-- Sälj Aktier
elseif data2.current.value == '1saljaktier' then
local elements = {}
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
title = 'Hur många Aktier vill du sälja?'
}, function (data2, menu2)
local count = tonumber(data2.value)
if count == nil then
TriggerEvent('esx:showNotification', 'Du kan inte sälja 0st aktier.')
else
menu2.close()
menu.close()
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
title = 'Vilket pris vill du sälja de för?'
}, function (data2, menu2)
local count1 = tonumber(data2.value)
if count1 == nil then
TriggerEvent('esx:showNotification', 'Du kan inte sälja dina aktier för 0kr.')
else
TriggerServerEvent('esx_aktier:saljaktier',count ,count1 ,fname)
menu2.close()
end
end, function (data2, menu2)
menu2.close()
end)
end
end, function (data2, menu2)
menu2.close()
menu.close()
end)
-- Kolla sin Aktier
elseif data2.current.value == '1kollaaktier' then
TriggerServerEvent('esx_aktier:kollaaktier', fname)
end
end, function(data2, menu2)
menu2.close()
end)
elseif data.current.value == 'material' then
end
end,
function(data, menu)
menu.close()
end
)
end
RegisterNetEvent('esx_aktier:bekreftelse')
AddEventHandler('esx_aktier:bekreftelse', function(mangd, pris)
local elements = {}
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
title = 'Vill du köpa: ' .. mangd .. '/st Aktier för totalbelopp: ' .. pris .. 'kr' .. ', Tryck Bekräfta för att godkänna.'
}, function (data2, menu2)
TriggerServerEvent('esx_aktier:slutfor',fname)
menu2.close()
--menu.close()
end, function (data2, menu2)
menu2.close()
menu.close()
end)
end)
-- notification
function sendNotification(message, messageType, messageTimeout)
TriggerEvent("mythic_notify:client:SendAlert", {
text = message,
type = messageType,
queue = "qalle",
timeout = messageTimeout,
layout = "bottomCenter"
})
end
-- Key events
Citizen.CreateThread(function()
while true do
Wait(0)
if IsControlPressed(0, Keys['F7']) then
ESX.TriggerServerCallback('esx_aktier:kollatid', function(cb)
if cb == false then
return
else
openMenu()
end
end)
end
end
end)
function saljmeny()
local elements = {}
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
title = _U('amount')
}, function (data2, menu2)
local count = tonumber(data2.value)
if count == nil then
TriggerEvent('esx:showNotification', 'Du försöker sälja ingenting')
else
TriggerEvent('esx:showNotification', 'Du säljer')
menu2.close()
menu.close()
OpenGetStocksMenu()
end
end, function (data2, menu2)
menu2.close()
end)
end
function drawTxt(x,y ,width,height,scale, text, r,g,b,a)
SetTextFont(4)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(2, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x - width/2, y - height/2 + 0.005)
end
function drawRct(x,y,width,height,r,g,b,a)
DrawRect(x + width/2, y + height/2, width, height, r, g, b, a)
end