forked from MrRebel568/mr-carbomb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
41 lines (35 loc) · 1.46 KB
/
Copy pathserver.lua
File metadata and controls
41 lines (35 loc) · 1.46 KB
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
local QBCore = exports[Config.Core]:GetCoreObject()
-- Event
QBCore.Functions.CreateUseableItem(Config.Item, function(source)
local src = source
TriggerClientEvent("mr-carbomb:CheckVehicle", src)
end)
QBCore.Functions.CreateUseableItem(Config.defuseditem, function(source)
local src = source
local Player = QBCore.Functions.GetPlayer(source)
if Config.JobDefused then
if Player.PlayerData.job.name == Config.PoliceJob then
TriggerClientEvent('mr-carbomb:defusedBomb', source)
else
TriggerClientEvent('QBCore:Notify', source, Config.Alerts['bomb_defusednot'], 'error')
end
else
TriggerClientEvent('mr-carbomb:defusedBomb', source)
end
end)
RegisterNetEvent('mr-carbomb:client:buybomb', function()
local source = source
local Player = QBCore.Functions.GetPlayer(tonumber(source))
local MRBombRebelPrice = Config.BombPrice
Player.Functions.AddItem(Config.Item, 1)
TriggerClientEvent(Config.InventoryTrigger, source, QBCore.Shared.Items[Config.Item], "add")
Player.Functions.RemoveMoney(Config.Payment, MRBombRebelPrice)
end)
RegisterServerEvent('mr-carbomb:RemoveBombFromInv')
AddEventHandler('mr-carbomb:RemoveBombFromInv', function()
local Player = QBCore.Functions.GetPlayer(source)
local item = Player.Functions.GetItemByName(Config.Item)
if item.amount > 0 then
Player.Functions.RemoveItem(Config.Item, 1)
end
end)