-
Notifications
You must be signed in to change notification settings - Fork 13
/
server.lua
69 lines (63 loc) · 2.59 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
local QBCore = exports['qb-core']:GetCoreObject()
RegisterServerEvent('qb-methcar:start')
AddEventHandler('qb-methcar:start', function()
local _source = source
local Player = QBCore.Functions.GetPlayer(source)
local ItemAcetone = Player.Functions.GetItemByName("acetone")
local ItemLithium = Player.Functions.GetItemByName("lithium")
local ItemMethlab = Player.Functions.GetItemByName("methlab")
if ItemAcetone ~= nil and ItemLithium ~= nil and ItemMethlab ~= nil then
if ItemAcetone.amount >= 5 and ItemLithium.amount >= 2 and ItemMethlab.amount >= 1 then
TriggerClientEvent("qb-methcar:startprod", _source)
Player.Functions.RemoveItem("acetone", 5, false)
Player.Functions.RemoveItem("lithium", 2, false)
else
TriggerClientEvent('QBCore:Notify', source, "Du hast nicht alle Zutaten um zu Kochen!", 'error')
end
else
TriggerClientEvent('QBCore:Notify', source, "Dir fehlen essenzielle Zutaten!", 'error')
end
end)
RegisterServerEvent('qb-methcar:stopf')
AddEventHandler('qb-methcar:stopf', function(id)
local _source = source
local xPlayers = QBCore.Functions.GetPlayers()
local xPlayer = QBCore.Functions.GetPlayer(tonumber(source))
for i=1, #xPlayers, 1 do
TriggerClientEvent('qb-methcar:stopfreeze', xPlayers[i], id)
end
end)
RegisterServerEvent('qb-methcar:make')
AddEventHandler('qb-methcar:make', function(posx,posy,posz)
local _source = source
local xPlayer = QBCore.Functions.GetPlayer(tonumber(source))
if xPlayer.Functions.GetItemByName('methlab') ~= nil then
if xPlayer.Functions.GetItemByName('methlab').amount >= 1 then
local xPlayers = QBCore.Functions.GetPlayers()
for i=1, #xPlayers, 1 do
TriggerClientEvent('qb-methcar:smoke',xPlayers[i],posx,posy,posz, 'a')
end
else
TriggerClientEvent('qb-methcar:stop', _source)
end
else
TriggerClientEvent('QBCore:Notify', source, "Dir fehlt ein Labor!", 'error')
end
end)
RegisterServerEvent('qb-methcar:finish')
AddEventHandler('qb-methcar:finish', function(qualtiy)
local _source = source
local xPlayer = QBCore.Functions.GetPlayer(tonumber(source))
local rnd = math.random(-5, 5)
xPlayer.Functions.AddItem('Meth', math.floor(qualtiy / 2) + rnd)
end)
RegisterServerEvent('qb-methcar:blow')
AddEventHandler('qb-methcar:blow', function(posx, posy, posz)
local _source = source
local xPlayers = QBCore.Functions.GetPlayers()
local xPlayer = QBCore.Functions.GetPlayer(tonumber(source))
for i=1, #xPlayers, 1 do
TriggerClientEvent('qb-methcar:blowup', xPlayers[i],posx, posy, posz)
end
xPlayer.Functions.RemoveItem('methlab', 1)
end)