-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.lua
66 lines (62 loc) · 2.42 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
VorpCore = {}
local VorpInv = exports.vorp_inventory:vorp_inventoryApi()
TriggerEvent("getCore",function(core)
VorpCore = core
end)
RegisterServerEvent("juSa_teleport:itemcheck")
AddEventHandler("juSa_teleport:itemcheck", function(items)
local _source = source
local hasItem = true
for i,v in ipairs(items) do
local count = VorpInv.getItemCount(_source, v.dbname)
if count < v.amount then -- if not enough items
hasItem = false
TriggerClientEvent("vorp:TipRight", _source, Config.Language.noitem..v.label, 5000)
break
end
end
if hasItem then -- if player has all items
local result = true
TriggerClientEvent("juSa_teleport:itemchecked", _source, result)
else
local result = false
TriggerClientEvent("juSa_teleport:itemchecked", _source, result)
end
end)
RegisterServerEvent("juSa_teleport:jobcheck")
AddEventHandler("juSa_teleport:jobcheck", function(jobs)
local _source = source
local Character = VorpCore.getUser(_source).getUsedCharacter
local hasJob = false
local hasRequiredGrade = false
local result = nil
for i, v in ipairs(jobs) do --check list of jobs
if v.name == Character.job then --checks for job
hasJob = true
if v.grade <= Character.jobGrade then
hasRequiredGrade = true
break --stops when player has a correct job and grade
end
end
end
if hasJob and hasRequiredGrade then
result = true
TriggerClientEvent("juSa_teleport:jobchecked", _source, result)
elseif hasJob and not hasRequiredGrade then
result = false
TriggerClientEvent("vorp:TipRight", _source, Config.Language.lowgrade, 5000)
TriggerClientEvent("juSa_teleport:jobchecked", _source, result)
else
result = false
TriggerClientEvent("vorp:TipRight", _source, Config.Language.wrongjob, 5000)
TriggerClientEvent("juSa_teleport:jobchecked", _source, result)
end
end)
RegisterServerEvent("juSa_teleport:takeitems")
AddEventHandler("juSa_teleport:takeitems", function(dbname, label, amount)
local _source = source
for i = 1, amount do
exports.vorp_inventory:subItem(_source, dbname, amount)
end
TriggerClientEvent("vorp:TipRight", _source, Config.Language.removeditem..amount.." x "..label, 5000)
end)