forked from 99kr/99kr-burglary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
burglary_server.lua
57 lines (46 loc) · 1.85 KB
/
burglary_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
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
local win1 = 60 -- lottery ticket
local win2 = 120
local win3 = 240
-- locales --
local winText = "You won ~g~$"
local ticketEmpty = "Your ticket was ~r~empty"
-------------
RegisterServerEvent('99kr-burglary:Add')
AddEventHandler('99kr-burglary:Add', function(item, qtty)
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
xPlayer.addInventoryItem(item, qtty)
end)
RegisterServerEvent('99kr-burglary:Remove')
AddEventHandler('99kr-burglary:Remove', function(item, qtty)
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
xPlayer.removeInventoryItem(item, qtty)
end)
ESX.RegisterUsableItem('lotteryticket', function(source)
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
local rndm = math.random(1,11)
xPlayer.removeInventoryItem('lotteryticket', 1)
if rndm == 1 then -- WIN 1
xPlayer.addMoney(win1)
TriggerClientEvent('99kr-burglary:Sound', src, "LOCAL_PLYR_CASH_COUNTER_COMPLETE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS")
TriggerClientEvent('esx:showNotification', src, winText .. win1)
end
if rndm == 2 then -- WIN 2
xPlayer.addMoney(win2)
TriggerClientEvent('99kr-burglary:Sound', src, "LOCAL_PLYR_CASH_COUNTER_COMPLETE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS")
TriggerClientEvent('esx:showNotification', src, winText .. win2)
end
if rndm == 3 then -- WIN 3
xPlayer.addMoney(win3)
TriggerClientEvent('99kr-burglary:Sound', src, "LOCAL_PLYR_CASH_COUNTER_COMPLETE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS")
TriggerClientEvent('esx:showNotification', src, winText .. win3)
end
if rndm >= 4 then
TriggerClientEvent('99kr-burglary:Sound', src, "NO", "HUD_FRONTEND_DEFAULT_SOUNDSET")
TriggerClientEvent('esx:showNotification', src, ticketEmpty)
end
end)