This is what I ended up using, and I put it into my base_ctf.lua
The number 10 near the top is what you change to suit your needs for your server, say if you want a full game to be enabled at 18 players you'd change it to 18
Code:
function GetNumAllPlayers() return GetTeam(Team.kRed):GetNumPlayers() + GetTeam(Team.kBlue):GetNumPlayers() end
function baseflag:touch( touch_entity )
if self.name == 'Blue Flag' and GetNumAllPlayers() < 10 then return false end
local player = CastToPlayer( touch_entity )
-- pickup if they can
if self.notouch[player:GetId()] then return; end
if player:GetTeamId() ~= self.team then
-- let the teams know that the flag was picked up
SmartSound(player, "yourteam.flagstolen", "yourteam.flagstolen", "otherteam.flagstolen")
RandomFlagTouchSpeak( player )
SmartMessage(player, "#FF_YOUPICKUP", "#FF_TEAMPICKUP", "#FF_OTHERTEAMPICKUP", Color.kGreen, Color.kGreen, Color.kRed)
-- if the player is a spy, then force him to lose his disguise
player:SetDisguisable( false )
-- if the player is a spy, then force him to lose his cloak
player:SetCloakable( false )
-- note: this seems a bit backwards (Pickup verb fits Player better)
local flag = CastToInfoScript(entity)
flag:Pickup(player)
AddHudIcon( player, self.hudicon, flag:GetName(), self.hudx, self.hudy, self.hudwidth, self.hudheight, self.hudalign )
-- log action in stats
LogLuaEvent(player:GetId(), 0, "flag_touch", "flag_name", flag:GetName(), "player_origin", (string.format("%0.2f",player:GetOrigin().x) .. ", " .. string.format("%0.2f",player:GetOrigin().y) .. ", " .. string.format("%0.1f",player:GetOrigin().z) ), "player_health", "" .. player:GetHealth());
local team = nil
-- get team as a lowercase string
if player:GetTeamId() == Team.kBlue then team = "blue" end
if player:GetTeamId() == Team.kRed then team = "red" end
if player:GetTeamId() == Team.kGreen then team = "green" end
if player:GetTeamId() == Team.kYellow then team = "yellow" end
-- objective icon pointing to the cap
UpdateObjectiveIcon( player, GetEntityByName( team.."_cap" ) )
-- 100 points for initial touch on flag
if self.status == 0 then player:AddFortPoints(FORTPOINTS_PER_INITIALTOUCH, "#FF_FORTPOINTS_INITIALTOUCH") end
self.status = 1
self.carriedby = player:GetName()
self:refreshStatusIcons(flag:GetName())
end
end