-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.lua
103 lines (88 loc) · 3.05 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
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
ESX = exports["es_extended"]:getSharedObject()
RegisterNetEvent('veeq_drugselling:sellmarycha', function()
local xPlayer = ESX.GetPlayerFromId(source)
local ilemarychyweq = xPlayer.getInventoryItem(Config.WeedItem).count
local x
if ilemarychyweq == 1 then
x = 1
elseif ilemarychyweq == 2 then
x = math.random(1,2)
elseif ilemarychyweq == 3 then
x = math.random(1,3)
elseif ilemarychyweq == 4 then
x = math.random(1,4)
elseif ilemarychyweq >= 5 then
x = math.random(1,5)
end
local cenamarychy = math.random(Config.WeedPriceMin, Config.WeedPriceMax) * x
xPlayer.removeInventoryItem(Config.WeedItem, x)
xPlayer.addInventoryItem('black_money', cenamarychy)
TriggerClientEvent('ox_lib:notify', source, {
title = _U("yousold") .. x .. "g " .. _U("for") .. cenamarychy .. _U("currency"),
position = "top",
type = "success",
icon = "fa-solid fa-cannabis",
})
end)
RegisterNetEvent('veeq_drugselling:sellmeta', function()
local xPlayer = ESX.GetPlayerFromId(source)
local ilemetyweq = xPlayer.getInventoryItem(Config.MethItem).count
local x
if ilemetyweq == 1 then
x = 1
elseif ilemetyweq == 2 then
x = math.random(1,2)
elseif ilemetyweq == 3 then
x = math.random(1,3)
elseif ilemetyweq == 4 then
x = math.random(1,4)
elseif ilemetyweq >= 5 then
x = math.random(1,5)
end
local cenamety = math.random(Config.MethPriceMin, Config.MethPriceMax) * x
xPlayer.removeInventoryItem(Config.MethItem, x)
xPlayer.addInventoryItem('black_money', cenamety)
TriggerClientEvent('ox_lib:notify', source, {
title = _U("yousold") .. x .. "g " .. _U("for") .. cenamety .. _U("currency"),
position = "top",
type = "success",
icon = "fa-solid fa-pills",
})
end)
RegisterNetEvent('veeq_drugselling:sellkoka', function()
local xPlayer = ESX.GetPlayerFromId(source)
local ilekokiyweq = xPlayer.getInventoryItem(Config.CokeItem).count
local x
if ilekokiyweq == 1 then
x = 1
elseif ilekokiyweq == 2 then
x = math.random(1,2)
elseif ilekokiyweq == 3 then
x = math.random(1,3)
elseif ilekokiyweq == 4 then
x = math.random(1,4)
elseif ilekokiyweq >= 5 then
x = math.random(1,5)
end
local cenakoki = math.random(Config.CokePriceMin, Config.CokePriceMax) * x
xPlayer.removeInventoryItem(Config.CokeItem, x)
xPlayer.addInventoryItem('black_money', cenakoki)
TriggerClientEvent('ox_lib:notify', source, {
title = _U("yousold") .. x .. "g " .. _U("for") .. cenakoki .. _U("currency"),
position = "top",
type = "success",
icon = "fa-solid fa-pills",
})
end)
RegisterNetEvent('checkC')
AddEventHandler('checkC', function()
local xPlayers = ESX.GetPlayers()
local cops = 0
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
cops = cops + 1
end
end
TriggerClientEvent("checkC", source, cops)
end)