-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.lua
88 lines (77 loc) · 2.83 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
VorpCore = {}
local VorpInv = exports.vorp_inventory:vorp_inventoryApi()
-- local VORP_API = exports.vorp_core:vorpAPI()
TriggerEvent("getCore",function(core)
VorpCore = core
end)
RegisterServerEvent('juSa_carrier_job:checkJob')
AddEventHandler('juSa_carrier_job:checkJob', function()
local _source = source
local Character = VorpCore.getUser(_source).getUsedCharacter
local job = Character.job
local grade = Character.jobGrade
local isrestricted = false
local ispermitted = false
if #Config.jobRestriction > 0 then
for i, v in ipairs(Config.jobRestriction) do
if v.name == job then
if v.grade >= grade then
isrestricted = true
end
end
end
end
if #Config.jobPermission > 0 then
for i, v in ipairs(Config.jobPermission) do
if v.name == job then
if v.grade <= grade then
ispermitted = true
end
end
end
else
ispermitted = true
end
TriggerClientEvent("juSa_carrier_job:jobchecked", _source, isrestricted, ispermitted)
end)
RegisterServerEvent("juSa_carrier_job:givereward")
AddEventHandler("juSa_carrier_job:givereward", function()
local _source = source
local Character = VorpCore.getUser(_source).getUsedCharacter
local giveitem = false
local givemoney = false
selectReward = math.random(100) -- select if give money or give item
if selectReward <= Config.Chance then
giveitem = true
else
givemoney = true
end
if giveitem == true then -- giving item reward
local FinalLoot = LootToGive(_source)
local User = VorpCore.getUser(_source).getUsedCharacter
for k,v in pairs(Config.reward) do
if v.item == FinalLoot then
local amount = math.random(v.rewardmin, v.rewardmax)
VorpInv.addItem(_source, FinalLoot, amount)
LootsToGive = {}
TriggerClientEvent("vorp:TipRight", _source, "" ..Config.Language.reward.. " " ..amount.. "x " ..v.name.. "." , 4000)
end
end
elseif givemoney == true then --giving money reward
local moneyreward_10 = math.random(Config.moneyrewardmin, Config.moneyrewardmax)
moneyreward = moneyreward_10/10
Character.addCurrency(0, moneyreward)
TriggerClientEvent("vorp:TipRight", _source, "" ..Config.Language.reward.. " " ..moneyreward.. "$ ." , 4000)
end
end)
function LootToGive(_source)
local LootsToGive = {}
for k,v in pairs(Config.reward) do
table.insert(LootsToGive,v.item)
end
if LootsToGive[1] ~= nil then
local value = math.random(1,#LootsToGive)
local picked = LootsToGive[value]
return picked
end
end