forked from Project-Sloth/ps-drugprocessing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweed.lua
56 lines (49 loc) · 2.27 KB
/
weed.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
local QBCore = exports['qb-core']:GetCoreObject()
RegisterServerEvent('ps-drugprocessing:pickedUpCannabis', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player.Functions.AddItem("cannabis", 1) then
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["cannabis"], "add")
TriggerClientEvent('QBCore:Notify', src, Lang:t("success.cannabis"), "success")
end
end)
RegisterServerEvent('ps-drugprocessing:processCannabis', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player.Functions.RemoveItem('cannabis', 1) then
if Player.Functions.AddItem('marijuana', 1) then
TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['cannabis'], "remove")
TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['marijuana'], "add")
TriggerClientEvent('QBCore:Notify', src, Lang:t("success.marijuana"), "success")
else
Player.Functions.AddItem('cannabis', 1)
end
else
TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_cannabis"), "error")
end
end)
RegisterServerEvent('ps-drugprocessing:rollJoint', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player.Functions.RemoveItem('marijuana', 1) then
if Player.Functions.RemoveItem('rolling_paper', 1) then
if Player.Functions.AddItem('joint', 1) then
TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['marijuana'], "remove")
TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['rolling_paper'], "remove")
TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items['joint'], "add")
TriggerClientEvent('QBCore:Notify', src, Lang:t("success.joint"), "success")
else
Player.Functions.AddItem('marijuana', 1)
Player.Functions.AddItem('rolling_paper', 1)
end
else
Player.Functions.AddItem('marijuana', 1)
end
else
TriggerClientEvent('QBCore:Notify', src, Lang:t("error.no_marijuhana"), "error")
end
end)
QBCore.Functions.CreateUseableItem("rolling_paper", function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
TriggerClientEvent('ps-drugprocessing:client:rollJoint', source, 'marijuana', item)
end)