Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: Bonecrusher on December 28, 2011, 06:46:58 am

Title: Players nicks
Post by: Bonecrusher on December 28, 2011, 06:46:58 am
I was wondering if it's possible to kick players with a lot of empty spaces in their nicks via scripting.  There is a group of players with spaces in their nicks and its really annoying as their nick is being displayed in the middle of my screen. I'd like to get rid of those players without banning them, basically i want them to delete empty spaces from their nicks.

example:
Nick: [a            ]
if there are more than x spaces kick
Title: Re: Players nicks
Post by: DorkeyDear on December 28, 2011, 08:25:37 am
Code: [Select]
const
  MinSpaces = 4;

procedure OnJoinTeam(const Id, Team: byte);
begin
  if (ContainsString(GetPlayerStat(Id, 'Name'), Replicate(' ', MinSpaces))) then
    KickPlayer(Id);
end;
Untested. Let us know if this at least compiles, and/or works as intended.
Title: Re: Players nicks
Post by: tk on December 28, 2011, 09:41:59 am
is there such func in crapcore as Replicate()?

The only thing you can do is to kick them.

Code: [Select]
procedure OnJoinTeam(Id, Team: byte);
var
  i, n: byte;
  name: string;
begin
   name := IDToName(Id);
   for i := 1 to Length(name) do begin
      if name[i] = ' ' then n := n + 1 else n := n div 2;
      if n = 5 then begin
        KickPlayer(ID);
        break;
      end;
   end;
end;
Untested
Title: Re: Players nicks
Post by: Bonecrusher on December 28, 2011, 10:26:22 am
thx a lot guys i will test it later and post results
Title: Re: Players nicks
Post by: Falcon` on December 28, 2011, 11:21:19 am
is there such func in crapcore as Replicate()?

There is. Along with StringOfChar() (one is an alias to another)
Title: Re: Players nicks
Post by: Bonecrusher on December 30, 2011, 07:15:37 am
Code: [Select]
const
  MinSpaces = 4;

procedure OnJoinTeam(const Id, Team: byte);
begin
  if (ContainsString(GetPlayerStat(Id, 'Name'), Replicate(' ', MinSpaces))) then
    KickPlayer(Id);
end;
Untested. Let us know if this at least compiles, and/or works as intended.


works like a charm, thx curt!