function SelectGamemode()
local chance = math.random(1,3)
local FilePath = "REgmod/GameMode/GameMode.txt"
local Gamemode = file.Read(FilePath)
if Gamemode == "Survivor" then
SetGlobalString( "Game", "Survivor" )
elseif Gamemode == "Vip" then
SetGlobalString( "Game", "VIP" )
elseif Gamemode == "Mercenaries" then
SetGlobalString( "Game", "Mercenaries" )
elseif Gamemode == "Escape" then
SetGlobalString( "Game", "Escape" )
else
if chance == 1 then
SetGlobalString( "Game", "VIP" )
else
SetGlobalString( "Game", "Survivor" )
end
end
end
function ChooseVip()
SetGlobalEntity( "Thevip", "" )
local hunks = team.GetPlayers(TEAM_HUNK)
local VIP = team.GetPlayers(TEAM_HUNK)[math.random(1,#hunks)]
SetGlobalEntity( "Thevip", VIP )
end
function GameCheck()
if GetGlobalString("Mode") == "End" then return end
if GetGlobalString("Game") == "VIP" then
if GetGlobalEntity("Thevip",player.GetByID(1)):Team() != TEAM_HUNK then
EndGame()
return
end
elseif GetGlobalString("Game") == "Survivor" then
if team.NumPlayers(TEAM_HUNK) <= 0 then
EndGame()
return
end
elseif GetGlobalString("Game") == "Escape" then
if team.NumPlayers(TEAM_HUNK) <= 0 then
EndGame()
return
end
elseif GetGlobalString("Game") == "Mercenaries" then
if team.NumPlayers(TEAM_HUNK) <= 0 then
timer.Destroy("Countdowntimer")
EndGame()
return
end
end
end
function GameModeStart()
if GetGlobalString("Game") == "VIP" then
ChooseVip()
SetGlobalInt("countdown", 300 + (table.Count(team.GetPlayers(TEAM_HUNK)) * 60) )
timer.Create("CountdownMercenaries",1,0, function() SetGlobalInt("GameTime", GetGlobalInt("GameTime") + 1) SetGlobalInt("countdown", GetGlobalInt("countdown") - 1) if GetGlobalInt("countdown") <= 0 then timer.Destroy("CountdownMercenaries") EndGame() end end)
elseif GetGlobalString("Game") == "Mercenaries" then
Zombies = {
"snpc_zombie",
"snpc_zombie_crimzon",
"snpc_zombie_crimzon",
"snpc_zombie_crimzon",
"snpc_zombie_crimzon",
"snpc_zombie_crimzon",
"snpc_zombie_crimzon",
"snpc_zombie_crimzon",
}
SetGlobalInt("countdown", 120)
timer.Create("CountdownMercenaries",1,0, function() SetGlobalInt("GameTime", GetGlobalInt("GameTime") + 1) SetGlobalInt("countdown", GetGlobalInt("countdown") - 1) if GetGlobalInt("countdown") <= 0 then timer.Destroy("CountdownMercenaries") EndGame() end end)
elseif GetGlobalString("Game") == "Survivor" then
for k,v in pairs(player.GetAll()) do
local modifier = math.random(30,100)
SetGlobalInt("DeadZombieKillNumber", GetGlobalInt("DeadZombieKillNumber") + modifier)
end
timer.Create("TimeSurvivedTimer",1,0, function() SetGlobalInt("GameTime", GetGlobalInt("GameTime") + 1) for k,v in pairs(team.GetPlayers(TEAM_HUNK)) do v:SetNWInt("Time",v:GetNWInt("Time") + 1 ) if GetGlobalInt("DeadZombies") >= GetGlobalInt("DeadZombieKillNumber") && GetGlobalInt("Game") != "End" then timer.Destroy("TimeSurvivedTimer") EndGame() end end end)
elseif GetGlobalString("Game") == "Escape" then
timer.Create("TimeSurvivedTimer",1,0, function() SetGlobalInt("GameTime", GetGlobalInt("GameTime") + 1) for k,v in pairs(team.GetPlayers(TEAM_HUNK)) do v:SetNWInt("Time",v:GetNWInt("Time") + 1 ) end end)
end
SetGlobalInt("DeadZombies",0)
end
hook.Add("OnNPCKilled","ASD",function()
SetGlobalInt("DeadZombies",GetGlobalInt("DeadZombies") + 1)
end)
function GameModeEnd()
local leader = player.GetAll()[1]
if GetGlobalString("Game") == "VIP" then
if GetGlobalEntity( "Thevip", player.GetByID(1) ):Team() == TEAM_HUNK then
local reward = (GetGlobalInt("DeadZombies") * table.Count(player.GetAll())) / 2
PrintMessage( HUD_PRINTTALK, "The Vip has survived! All players won $"..reward.." . Fine Work!" )
for k,v in pairs(player.GetAll()) do
v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+ reward))
end
else
PrintMessage( HUD_PRINTTALK, "The Vip has died, nobody is rewarded a special bonus." )
end
for k,v in pairs(player.GetAll()) do
if v:Team() == TEAM_HUNK then
v:SetNWBool("Infected", false)
v:SetNWInt("InfectedPercent", 0)
if v.CanEarn then
local money = v:GetNWInt("Time")/60*v:GetNWInt("killcount")
if money >= 3000 then
v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+3000))
v.CanEarn = false
else
v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+(v:GetNWInt("Time")/60)*v:GetNWInt("killcount")))
v.CanEarn = false
end
end
end
end
timer.Destroy("Countdowntimer")
elseif GetGlobalString("Game") == "Mercenaries" then
for k,v in pairs(player.GetAll()) do
if v:GetNWInt("killcount") >= leader:GetNWInt("killcount") && v != leader then
leader = v
end
if v:Team() == TEAM_HUNK then
v:SetNWBool("Infected", false)
v:SetNWInt("InfectedPercent", 0)
if v.CanEarn then
local money = v:GetNWInt("Time")/60*v:GetNWInt("killcount")
if money >= 3000 then
v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+3000))
v.CanEarn = false
else
v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+(v:GetNWInt("Time")/60)*v:GetNWInt("killcount")))
v.CanEarn = false
end
end
end
end
PrintMessage( HUD_PRINTTALK, leader:Nick().." won "..table.Count(player.GetAll())*150 .." for getting the most kills. Well done!" )
leader:SetNWInt("Money", leader:GetNWInt("Money") + (math.Round(table.Count(player.GetAll())*150)))
elseif GetGlobalString("Game") == "Survivor" then
if GetGlobalInt("DeadZombies") >= GetGlobalInt("DeadZombieKillNumber") then
if table.Count(team.GetPlayers(TEAM_HUNK)) > 0 then
local reward = table.Count(team.GetPlayers(TEAM_HUNK)) * 100
PrintMessage( HUD_PRINTTALK, "Surviving players won $"..reward.." for staying alive. Well done!" )
for k,v in pairs(player.GetAll()) do
if v:Team() == TEAM_HUNK then
v:SetNWBool("Infected", false)
v:SetNWInt("InfectedPercent", 0)
if v.CanEarn then
local money = v:GetNWInt("Time")/60*v:GetNWInt("killcount")
if money >= 3000 then
v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+3000))
v.CanEarn = false
else
v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+((v:GetNWInt("Time")/60)*v:GetNWInt("killcount"))+ reward))
v.CanEarn = false
end
end
end
end
end
end
elseif GetGlobalString("Game") == "Escape" then
if table.Count(team.GetPlayers(TEAM_HUNK)) > 0 then
local reward = RewardTable[game.GetMap()]
PrintMessage( HUD_PRINTTALK, "You Have Escaped! Surviving players won $"..reward.." for staying alive. Well done!" )
for k,v in pairs(player.GetAll()) do
if v:Team() == TEAM_HUNK then
v:SetNWBool("Infected", false)
v:SetNWInt("InfectedPercent", 0)
if v.CanEarn then
local money = v:GetNWInt("Time")/60*v:GetNWInt("killcount")
if money >= 3000 then
v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+3000))
v.CanEarn = false
else
v:SetNWInt("Money",math.Round(v:GetNWInt("Money")+((v:GetNWInt("Time")/60)*v:GetNWInt("killcount"))+ reward))
v.CanEarn = false
end
end
end
end
end
end
end