Garry's Mod

Garry's Mod

Prophunters
Set a team limit
I'm always playing with 2 friends, so there are 2 props and 1 hunter. But next round there are 2 hunters and 1 prop. It's quite annoying. Is there something i can do to set a limit to 1 for the Hunter's team ?
Dernière modification de ju; 3 nov. 2018 à 8h26
< >
Affichage des commentaires 1 à 15 sur 21
Same problem
same
There is no quite an option rigth now.
You can try alter the
concommand.Add("car_jointeam", function (ply, com, args)
(line 5980)
and/or
function GM:CheckTeamBalance()
(line 6019)
witch are the functions that controle the join and balance of a team

However, know that i think it might broke the part of "new round" of the mod as the change in team will be something like X hunters and 1 props....
Try it and tell us
Hi, you can try this in sv_teams.lua




function GM:TeamsSetupPlayer(ply)
local cops = team.NumPlayers(2)
local robbers = team.NumPlayers(3)
if cops >= 1 then
ply:SetTeam(3)
else
ply:SetTeam(2)
end
end

concommand.Add("car_jointeam", function (ply, com, args)
local curteam = ply:Team()
local newteam = tonumber(args[1] or "") or 0
if newteam == 1 && curteam != 1 then

ply:SetTeam(newteam)
if ply:Alive() then
ply:Kill()
end
local ct = ChatText()
ct:Add(ply:Nick())
ct:Add(" changed team to ")
ct:Add(team.GetName(newteam), team.GetColor(newteam))
ct:SendAll()

elseif newteam >= 2 && newteam <= 3 && newteam != curteam then

local ct = ChatText()
ct:Add("Team full, you cannot join")
ct:Send(ply)

end

end)

function GM:CheckTeamBalance()
if !self.TeamBalanceCheck || self.TeamBalanceCheck < CurTime() then
self.TeamBalanceCheck = CurTime() + 3 * 60 // check every 3 minutes

local hunter = team.NumPlayers(2)
if hunter > 1 then // Il doit y avoir un seul hunter
self.TeamBalanceTimer = CurTime() + 30 // balance in 30 seconds
for k,ply in pairs(player.GetAll()) do
ply:ChatPrint("Auto team balance in 30 seconds")
end
end
end
if self.TeamBalanceTimer && self.TeamBalanceTimer < CurTime() then
self.TeamBalanceTimer = nil
self:BalanceTeams()
end
end

function GM:BalanceTeams(nokill)
local hunter = team.NumPlayers(2)
while hunter > 1 do
local players = team.GetPlayers(2)
local ply = players[math.random(#players)]
ply:SetTeam(3)
if !nokill && ply:Alive() then
ply:Kill()
end
local ct = ChatText()
ct:Add(ply:Nick())
ct:Add(" est devenue un ")
ct:Add(team.GetName(smallerTeam), team.GetColor(smallerTeam))
ct:SendAll()
hunter = hunter - 1
end
end

function GM:SwapTeams()
for k, ply in pairs(player.GetAll()) do
ply:SetTeam(3)
end
local players = team.GetPlayers(3)
local ply = players[math.random(#players)]
ply:SetTeam(2)
if !nokill && ply:Alive() then
ply:Kill()
end
local ct = ChatText()
ct:Add("Teams have been swapped", Color(50, 220, 150))
ct:SendAll()
end
Does it work?
yes it works I use it, besides it's me who did it.

it allows to have only 1 random hunter.

So if you are 5, it will be 1 hunter and 4 props
i can't find sv_teams.lua

where is it please?
In your server : prophunters\gamemode\sv_teams.lua
don't have it... can you add me pls?
Mimi 22 nov. 2018 à 14h19 
hi captain spirit, is there any way to use your code if i haven't rent a server ?
Captain Spirit a écrit :
Hi, you can try this in sv_teams.lua




function GM:TeamsSetupPlayer(ply)
local cops = team.NumPlayers(2)
local robbers = team.NumPlayers(3)
if cops >= 1 then
ply:SetTeam(3)
else
ply:SetTeam(2)
end
end

concommand.Add("car_jointeam", function (ply, com, args)
local curteam = ply:Team()
local newteam = tonumber(args[1] or "") or 0
if newteam == 1 && curteam != 1 then

ply:SetTeam(newteam)
if ply:Alive() then
ply:Kill()
end
local ct = ChatText()
ct:Add(ply:Nick())
ct:Add(" changed team to ")
ct:Add(team.GetName(newteam), team.GetColor(newteam))
ct:SendAll()

elseif newteam >= 2 && newteam <= 3 && newteam != curteam then

local ct = ChatText()
ct:Add("Team full, you cannot join")
ct:Send(ply)

end

end)

function GM:CheckTeamBalance()
if !self.TeamBalanceCheck || self.TeamBalanceCheck < CurTime() then
self.TeamBalanceCheck = CurTime() + 3 * 60 // check every 3 minutes

local hunter = team.NumPlayers(2)
if hunter > 1 then // Il doit y avoir un seul hunter
self.TeamBalanceTimer = CurTime() + 30 // balance in 30 seconds
for k,ply in pairs(player.GetAll()) do
ply:ChatPrint("Auto team balance in 30 seconds")
end
end
end
if self.TeamBalanceTimer && self.TeamBalanceTimer < CurTime() then
self.TeamBalanceTimer = nil
self:BalanceTeams()
end
end

function GM:BalanceTeams(nokill)
local hunter = team.NumPlayers(2)
while hunter > 1 do
local players = team.GetPlayers(2)
local ply = players[math.random(#players)]
ply:SetTeam(3)
if !nokill && ply:Alive() then
ply:Kill()
end
local ct = ChatText()
ct:Add(ply:Nick())
ct:Add(" est devenue un ")
ct:Add(team.GetName(smallerTeam), team.GetColor(smallerTeam))
ct:SendAll()
hunter = hunter - 1
end
end

function GM:SwapTeams()
for k, ply in pairs(player.GetAll()) do
ply:SetTeam(3)
end
local players = team.GetPlayers(3)
local ply = players[math.random(#players)]
ply:SetTeam(2)
if !nokill && ply:Alive() then
ply:Kill()
end
local ct = ChatText()
ct:Add("Teams have been swapped", Color(50, 220, 150))
ct:SendAll()
end

Where is the sv_teams.lua file when we don't own a server ? I've just downloaded the Prophunters gamemode to play casually with some friends but I don't have a 'Prohunters' folder in steammaps > gamemodes (only base, sandbox and terrortown actually). Thank you !
ju 12 déc. 2018 à 14h04 
Thank you guys ! I was recently unactive but I have to say it again thanks a lot
Manas 21 janv. 2019 à 11h06 
I can not find either sv_teams.lua too
Hakatron a écrit :
Captain Spirit a écrit :
Hi, you can try this in sv_teams.lua




function GM:TeamsSetupPlayer(ply)
local cops = team.NumPlayers(2)
local robbers = team.NumPlayers(3)
if cops >= 1 then
ply:SetTeam(3)
else
ply:SetTeam(2)
end
end

concommand.Add("car_jointeam", function (ply, com, args)
local curteam = ply:Team()
local newteam = tonumber(args[1] or "") or 0
if newteam == 1 && curteam != 1 then

ply:SetTeam(newteam)
if ply:Alive() then
ply:Kill()
end
local ct = ChatText()
ct:Add(ply:Nick())
ct:Add(" changed team to ")
ct:Add(team.GetName(newteam), team.GetColor(newteam))
ct:SendAll()

elseif newteam >= 2 && newteam <= 3 && newteam != curteam then

local ct = ChatText()
ct:Add("Team full, you cannot join")
ct:Send(ply)

end

end)

function GM:CheckTeamBalance()
if !self.TeamBalanceCheck || self.TeamBalanceCheck < CurTime() then
self.TeamBalanceCheck = CurTime() + 3 * 60 // check every 3 minutes

local hunter = team.NumPlayers(2)
if hunter > 1 then // Il doit y avoir un seul hunter
self.TeamBalanceTimer = CurTime() + 30 // balance in 30 seconds
for k,ply in pairs(player.GetAll()) do
ply:ChatPrint("Auto team balance in 30 seconds")
end
end
end
if self.TeamBalanceTimer && self.TeamBalanceTimer < CurTime() then
self.TeamBalanceTimer = nil
self:BalanceTeams()
end
end

function GM:BalanceTeams(nokill)
local hunter = team.NumPlayers(2)
while hunter > 1 do
local players = team.GetPlayers(2)
local ply = players[math.random(#players)]
ply:SetTeam(3)
if !nokill && ply:Alive() then
ply:Kill()
end
local ct = ChatText()
ct:Add(ply:Nick())
ct:Add(" est devenue un ")
ct:Add(team.GetName(smallerTeam), team.GetColor(smallerTeam))
ct:SendAll()
hunter = hunter - 1
end
end

function GM:SwapTeams()
for k, ply in pairs(player.GetAll()) do
ply:SetTeam(3)
end
local players = team.GetPlayers(3)
local ply = players[math.random(#players)]
ply:SetTeam(2)
if !nokill && ply:Alive() then
ply:Kill()
end
local ct = ChatText()
ct:Add("Teams have been swapped", Color(50, 220, 150))
ct:SendAll()
end

Where is the sv_teams.lua file when we don't own a server ? I've just downloaded the Prophunters gamemode to play casually with some friends but I don't have a 'Prohunters' folder in steammaps > gamemodes (only base, sandbox and terrortown actually). Thank you !

Found the file once I extracted the .gma file of the extention with "gmad.exe". But what's inside is the exact same thing as I have. Still, built it again, published it for my friends, and there is always equal number of player on each teams.. I don't understand why you have the best prop hunt mode, with no collision bug, nice taunt & all, but not this simplest function of limiting the number of hunters ?

How can I do this ?
< >
Affichage des commentaires 1 à 15 sur 21
Par page : 1530 50