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
|
local meta = FindMetaTable("Player")
local Time = 10
if (SERVER) then
util.AddNetworkString("RoundStart")
function GM:StartCountDown()
self.CountDown = CurTime()+Time+1
//items to clean up in between rounds
cleanup = {
"ws_arrow",
"ws_campfire",
"ws_grave",
"ws_rune",
}
for k,v in pairs(cleanup) do
for i,j in pairs(ents.FindByClass(v)) do
j:Remove()
end
end
--Generate a completly new rain of props :D
self:GeneratePropRain()
net.Start("RoundStart")
net.WriteUInt(Time,8)
net.Broadcast()
end
function meta:UpdateRoundTimer()
if (!self.CountDown or self.CountDown<CurTime()) then return end
net.Start("RoundStart")
net.WriteUInt(math.floor(self.CountDown-CurTime()),8)
net.Send(self)
end
hasprinted = false
hook.Add("Tick","CountDowner",function()
if (GAMEMODE.GameOn) then
if (#player.GetAll() < 2) then
--TODO: Less than 2 players in the server
GAMEMODE.CountDown = nil
GAMEMODE.GameOn = false
return
elseif (#player.GetAllHumans() < 2) then
GAMEMODE.CountDown = nil
GAMEMODE.GameOn = false
for k,v in pairs(player.GetAllHumans()) do
v:AddAccountItem(table.Random(GetItemsByClass("account")).Name,1)
end
timer.Simple(Time,function() for k,v in pairs(player.GetAllHumans()) do v:Kill() end end)
GAMEMODE:StartCountDown()
return
end
else
if(!hasprinted) then
for k,v in pairs(player.GetAll()) do
v:ChatPrint("Winter survival requires 2 players or more to play")
v:ChatPrint("Invite a friend!")
end
hasprinted = true
end
end
if (GAMEMODE.GameOn or !GAMEMODE.CountDown) then return end
if (GAMEMODE.CountDown < CurTime()) then
--print("Test2")
if (#player.GetAll() < 2) then
GAMEMODE.CountDown = CurTime()+Time+1
return
end
for k,v in pairs(player.GetAll()) do
if (v:IsPigeon()) then
if (IsValid(v.Pigeon)) then v.Pigeon:Remove() end
v:SetHuman(true)
v:KillSilent()
timer.Simple(1,function() if (IsValid(v) and !v:Alive()) then v:Spawn() end end)
end
end
GAMEMODE.GameOn = true
end
end)
else
net.Receive("RoundStart",function() GAMEMODE.CountDown = CurTime()+net.ReadUInt(8) end)
end
function GetCountDown()
return GAMEMODE.CountDown
end
|