Script Name: Force Partial Name to Team
Script Description: The exact same thing as /setteam# # except that its /force and the 2nd # is actually part of somebody's name (may include spaces). Everybody who has that as part of their name will be forced to the inputed team. Great for managing whole clans on a server.
Original Author: Curt (DorkeyDear)
Core Version: (Tested with) 2.6.1
Code:function OnCommand(ID: Byte; Text: string): boolean;
var
i: byte;
Who: shortint;
Name: string;
begin
Result := false;
if ID = 255 then Name := 'Server' else Name := IDtoName(ID);
if Copy(Text,1,6) = '/force' then begin
try
Who := StrtoInt(Text[7]);
except
Who := -1;
end;
if (Who <> -1) and (Who >= 0) and (Who <= 5) then begin
for i := 1 to 32 do if ((LowerCase(Copy(Text,9,Length(Text))) = 'everybody') or (ContainsString(LowerCase(IDtoName(i)),LowerCase(Copy(Text,9,Length(Text))))) = true) and (GetPlayerStat(i,'Team') <> Who) then Command('/setteam' + InttoStr(Who) + ' ' + InttoStr(i));
if LowerCase(Copy(Text,9,Length(Text))) = 'everybody' then Command('/say ' + Name + ' forced everybody to team #' + InttoStr(Who) + '.') else Command('/say ' + Name + ' forced all players with ''' + Copy(Text,9,Length(Text)) + ''' to team #' + InttoStr(Who) + '.');
end;
end;
end;
(A note: 'Who' is not a very good name for the variable, but I used it for another part of the OnCommand event that is on the server I created this on. You may change that if you wish.)
(Another note: If you never knew, if you are playing on a CTF server and a player is forced to team 0, then their shirt color remains to their team color. I would assume that also applies on all other team game styles.)