Author Topic: Players nicks  (Read 1847 times)

0 Members and 1 Guest are viewing this topic.

Offline Bonecrusher

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1397
  • High above
    • Zabijaka.pl
Players nicks
« 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

Im chill like that

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Players nicks
« Reply #1 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.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Players nicks
« Reply #2 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
« Last Edit: December 28, 2011, 09:45:34 am by tk »

Offline Bonecrusher

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1397
  • High above
    • Zabijaka.pl
Re: Players nicks
« Reply #3 on: December 28, 2011, 10:26:22 am »
thx a lot guys i will test it later and post results

Im chill like that

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: Players nicks
« Reply #4 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)
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline Bonecrusher

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1397
  • High above
    • Zabijaka.pl
Re: Players nicks
« Reply #5 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!

Im chill like that