Author Topic: Force Partial Name to Team  (Read 2274 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Force Partial Name to Team
« on: June 03, 2007, 08:28:46 pm »
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:
Code: [Select]
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.)
« Last Edit: June 04, 2007, 09:20:21 am by DorkeyDear »

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: Force Partial Name to Team
« Reply #1 on: June 04, 2007, 04:04:19 am »
Yeah, perfect script :)
Thanks.

Edit:

Little fix:


Quote
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 ContainsString(LowerCase(IDtoName(i)),LowerCase(Copy(Text,9,Length(Text)))) = true then Command('/setteam' + InttoStr(Who) + ' ' + InttoStr(i));
      Command('/say ' + Name + ' forced all players with ''' + Copy(Text,9,Length(Text)) + ''' to team #' + InttoStr(Who) + '.');
    end;
  end;
end;
« Last Edit: June 04, 2007, 04:48:33 am by xmRipper »
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Force Partial Name to Team
« Reply #2 on: June 04, 2007, 08:59:24 am »
- Ok, I modified my script to make it not case sensitive.
- New feature! If your already on the team, it won't bother to set you and have that annoying message.
- New feature! If you do '/force# everybody', then everybody is set to that team. (Note: You just can't take only people with 'everybody' in their name, but it is doubtful that you would want to force at least 2 people at once that happen to have 'everybody' in their name. But in case there is... you have to user /setteam# #)
« Last Edit: June 04, 2007, 09:18:16 am by DorkeyDear »