Squads in Fretta

I’m trying to make a basic squad-type DM gamemode in Fretta, however I have no way of testing this as I need a bunch of people and apparently I can’t create bots (always errors in console “Failed to create a bot.”). Should this work?

Here’s the basic idea (init.lua):

[lua]local squads = {red = {}, blu = {}}
function CreateSquads(sqd,tm)
for i = 1, math.max(math.floor(team.NumPlayers™/GM.MinInSquad),1) do
sqd.i = {}
for n = 1, GM.MaxInSquad do
local ply = table.Random(team.GetPlayers(1))
while table.HasValue(sqd.i,ply) do ply = table.Random(team.GetPlayers(1)) end
sqd.i.n = ply
end
local pts = {-1,nil}
for _,v in ipairs(sqd.i) do
if v:GetPoints() > pts[1] then
pts[1] = v:GetPoints()
pts[2] = v
end
end
for _,v in ipairs(sqd.i) do if v == pts[2] then SetLeader() else v:RemoveLeader() end end
end
end

function GM:OnRoundStart()
CreateSquads(squads.red,1)
CreateSquads(squads.blu,2)
for _,p in ipairs(player.GetAll()) do
p:ChatPrint(“And the teams are…”)
for k,sqd in ipairs(squads) do
p:ChatPrint("----------Team “…k…”----------")
for a,b in ipairs(sqd) do
p:ChatPrint("----Squad “…a…”----")
for c,d in ipairs(b) do
p:ChatPrint("Player “…c…”: "…d:Name())
end
end
end
end
end[/lua]

player.lua, if it helps:

[lua]local meta = FindMetaTable(“player”)
if !meta then return end

function meta:SetSquad(name)
self._Squad = name
end

function meta:GetSquad()
return self._Squad or nil
end

function meta:GivePoints(int)
self._Points = self._Points + int
end

function meta:GetPoints()
return self._Points
end

function meta:SetLeader()
self._Lead = true
end

function meta:RemoveLeader()
self._Lead = false
end

function meta:IsLeader()
return self._Lead or false
end
[/lua]

Ok, to create bots go into gmod. Then click create multiplayer. Then click the options tab. Select your gamemode from the dropdown menu. Then go back to the first tab and select your map. Then start it. Then in console type “bot” the desired amount of times.

Then you can constantly test instead of this :smiley:

Thanks. I’ll test it out.

Is there no way to do it in singleplayer?

Not in singleplayer, ive tried :stuck_out_tongue:

Just do ‘Create Multiplayer’ and set a password…

When I test code and I need bots I just check the lan box so no strangers can join it.

Will if your ports are not forwarded and you a hooked up to a router no one will be able to join anyways.