forked from MintKind/mint-houseRobbery
-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.lua
52 lines (46 loc) · 2.22 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
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent("robbery:loot")
AddEventHandler("robbery:loot", function()
local src = source
local winNumber = math.random( 0, 100)
if winNumber >= 30 then
print(winNumber)
addNormal(src)
elseif winNumber < 30 and winNumber > 2 then
print(winNumber)
addRare(src)
else
print(winNumber)
addVeryRare(src)
end
end)
RegisterNetEvent('robbery:removerequireditem', function(data)
local source = src
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.RemoveItem(Config.ItemRequired, 1)
end)
function addNormal(src)
--TriggerClientEvent('mythic_notify:client:SendAlert', src, { type = 'inform', text = 'Normal', })
local item = Config.Items.normalItems[math.random(1,#Config.Items.normalItems)]
TriggerClientEvent('QBCore:Notify', src, 'You Found ' .. QBCore.Shared.Items[item].label .. '!', 'success', 5000)
local Player = QBCore.Functions.GetPlayer(src)
Player.Functions.AddItem(item, 1)
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[item], "add")
end
function addRare(src)
--TriggerClientEvent('mythic_notify:client:SendAlert', src, { type = 'inform', text = 'Rare', })
local item = Config.Items.rareItems[math.random(1,#Config.Items.rareItems)]
TriggerClientEvent('QBCore:Notify', src, 'You Found ' .. QBCore.Shared.Items[item].label .. '!', 'success', 5000)
local Player = QBCore.Functions.GetPlayer(src)
Player.Functions.AddItem(item, 1)
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[item], "add")
end
function addVeryRare(src)
--TriggerClientEvent('mythic_notify:client:SendAlert', src, { type = 'inform', text = 'Very Rare', })
local item = Config.Items.veryRareItems[math.random(1,#Config.Items.veryRareItems)]
TriggerClientEvent('QBCore:Notify', src, 'You Found ' .. QBCore.Shared.Items[item].label .. '!', 'success', 5000)
local Player = QBCore.Functions.GetPlayer(src)
Player.Functions.AddItem(item, 1)
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[item], "add")
end