-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.lua
108 lines (101 loc) · 4.18 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
104
105
106
107
108
VorpInv = exports.vorp_inventory:vorp_inventoryApi()
local VorpCore = {}
TriggerEvent("getCore",function(core)
VorpCore = core
end)
function GetPlayers()
local players = {}
for i = 0, 256 do
if NetworkIsPlayerActive(i) then
table.insert(players, GetPlayerServerId(i))
end
end
return players
end
VorpInv.RegisterUsableItem("robbingkit", function(data)
local WorldTime = exports.weathersync:getTime()
local maxchance = 210
local minchance = 1
local breakroll = math.random(minchance,maxchance)
local breakroll2 = math.random(minchance,maxchance)
if WorldTime.hour == 22 or WorldTime.hour == 23 or WorldTime.hour == 0 or WorldTime.hour == 1 or WorldTime.hour == 2 or WorldTime.hour == 3 or WorldTime.hour == 4 or WorldTime.hour == 5 then
if Config.DisableBreaking == false then
local breakchance = breakroll + breakroll2
if Config.Debug == true then print(breakroll.." + "..breakroll2) end
if breakchance >= 365 then
VorpInv.subItem(data.source, "robbingkit", 1)
TriggerClientEvent("vorp:TipRight", data.source, Config.LostKit, 3000)
TriggerClientEvent('GraveRobbing:TriggerRobbery', data.source)
if Config.Debug == true then print("Kit Broken: Rolled "..breakchance.."/"..maxchance) end
else
TriggerClientEvent('GraveRobbing:TriggerRobbery', data.source)
if Config.Debug == true then print("Kit did not break, Rolled: "..breakchance.."/"..maxchance) end
end
else
TriggerClientEvent('GraveRobbing:TriggerRobbery', data.source)
if Config.Debug == true then print("Kit cannot be broken. Config Disable Breaking is TRUE") end
end
else
TriggerClientEvent("vorp:TipBottom", data.source, Config.Daytime, 5000)
if Config.Debug == true then print("Attempted daytime Graverobbing") end
end
end)
function keysx(table)
local keys = 0
for k,v in pairs(table) do
keys = keys + 1
end
return keys
end
RegisterServerEvent('wcrp:graverobbingreward')
AddEventHandler('wcrp:graverobbingreward', function()
local _source = source
local Character = VorpCore.getUser(_source).getUsedCharacter
local chance = math.random(1,10)
local reward = {}
for k,v in pairs(Config.Items) do
if v.chance >= chance then
table.insert(reward,v)
end
end
local chance2 = math.random(1,keysx(reward))
local count = math.random(1,reward[chance2].amount)
TriggerEvent("vorpCore:canCarryItems", tonumber(_source), count, function(canCarry)
TriggerEvent("vorpCore:canCarryItem", tonumber(_source), reward[chance2].name,count, function(canCarry2)
if canCarry and canCarry2 then
VorpInv.addItem(_source, reward[chance2].name, count)
TriggerClientEvent("vorp:TipRight", _source, "You found "..count.." "..reward[chance2].label, 3000)
if Config.Debug == true then print("Obtained Drop "..reward[chance2].label.." Rolled: "..chance2) end
else
TriggerClientEvent("vorp:TipRight", _source, "You cannot carry any more "..reward[chance2].label, 3000)
if Config.Debug == true then print("Obtained Drop "..reward[chance2].label.." Rolled: "..chance2) end
end
end)
end)
end)
RegisterServerEvent('wcrp:graverobbingreward2')
AddEventHandler('wcrp:graverobbingreward2', function()
local _source = source
local Character = VorpCore.getUser(_source).getUsedCharacter
local chance = math.random(1,10)
local reward = {}
for k,v in pairs(Config.Items2) do
if v.chance >= chance then
table.insert(reward,v)
end
end
local chance2 = math.random(1,keysx(reward))
local count = math.random(1,reward[chance2].amount)
TriggerEvent("vorpCore:canCarryItems", tonumber(_source), count, function(canCarry)
TriggerEvent("vorpCore:canCarryItem", tonumber(_source), reward[chance2].name,count, function(canCarry2)
if canCarry and canCarry2 then
VorpInv.addItem(_source, reward[chance2].name, count)
TriggerClientEvent("vorp:TipRight", _source, "You found "..count.." "..reward[chance2].label, 3000)
if Config.Debug == true then print("Obtained Junk Drop "..reward[chance2].label.." Rolled: "..chance2) end
else
TriggerClientEvent("vorp:TipRight", _source, "You can't carry any more "..reward[chance2].label, 3000)
if Config.Debug == true then print("Not enough pocket space for "..reward[chance2].label.." Rolled: "..chance2) end
end
end)
end)
end)