-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.lua
77 lines (67 loc) · 2.45 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
local QBCore = exports['qb-core']:GetCoreObject()
local playerItems = {}
RegisterNetEvent('sky:getfire', function()
local Player = QBCore.Functions.GetPlayer(source)
local item = 'WEAPON_FIREEXTINGUISHER'
local count = 1
if not playerItems[source] then
playerItems[source] = {}
end
if Name(item) then
TriggerClientEvent('ox_lib:notify', source, {
title = Translation[Config.Locale]['error1'],
description = Translation[Config.Locale]['error2'],
type = 'error'
})
else
playerItems[source][item] = true
TriggerClientEvent('giveex', source)
Citizen.Wait(Config.Delay)
Player.Functions.AddItem(item, count)
end
end)
RegisterNetEvent('change', function()
local _source = source
local Player = QBCore.Functions.GetPlayer(_source)
local item = 'WEAPON_FIREEXTINGUISHER'
local count = 1
if Player.Functions.GetItemByName(item) then
Player.Functions.RemoveItem(item, Player.Functions.GetItemByName(item).count)
TriggerClientEvent('getnewex', source)
Citizen.Wait(Config.Delay)
Player.Functions.AddItem(item, count)
TriggerClientEvent('ox_lib:notify', _source, {
title = Translation[Config.Locale]['inform1'],
description = Translation[Config.Locale]['success3'],
type = 'inform'
})
else
TriggerClientEvent('ox_lib:notify', _source, {
title = Translation[Config.Locale]['inform1'],
description = Translation[Config.Locale]['inform2'],
type = 'inform'
})
end
end)
RegisterNetEvent('sky:remove', function()
local _source = source
local Player = QBCore.Functions.GetPlayer(_source)
local item = 'WEAPON_FIREEXTINGUISHER'
local count = 1
if Player.Functions.GetItemByName(item) then
TriggerClientEvent('remex', source)
Citizen.Wait(Config.Delay)
Player.Functions.RemoveItem(item, Player.Functions.GetItemByName(item).count)
TriggerClientEvent('ox_lib:notify', _source, {
title = Translation[Config.Locale]['inform1'],
description = Translation[Config.Locale]['remfire1'],
type = 'inform'
})
else
TriggerClientEvent('ox_lib:notify', _source, {
title = Translation[Config.Locale]['inform1'],
description = Translation[Config.Locale]['inform2'],
type = 'inform'
})
end
end)