Author Topic: Namelength restriction  (Read 1868 times)

0 Members and 1 Guest are viewing this topic.

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Namelength restriction
« on: August 20, 2007, 08:05:30 am »
Script Name: Namelength restriction script 1.0
Script Description: Kicks players when they join with a too long nick name.
Original Author(s): Avarax
Core Version: 2.6.2 (.zip file matches scriptingcoreV2 file structure.)



To set the script up, just extract it to your server folder and activate scripting in the server.ini. You can set the maximum name length in characters either by changing the NameRestriction.ini in the main server folder or by using the following admin command:

Code: [Select]
/maxnamelength Xwhile X is the new maximum length.

Default max length is 20.


DOWNLOAD[/size]



Code: [Select]
var MaxLength: byte;

procedure ActivateServer();
begin
  MaxLength:=strtoint(ReadINI('NameRestriction.ini','Settings','Maximum_Name_Length','20'));
end;

function OnCommand(ID: Byte; Text: string): boolean;
begin
  If copy(text,1,15) = '/maxnamelength ' then begin
    MaxLength:=strtoint(GetPiece(text,' ',1));
    If ID = 255 then
      WriteLn('Maximum name length succesfully set to ' + inttostr(MaxLength))
    else
      WriteConsole(ID,'Maximum name length succesfully set to ' + inttostr(MaxLength),$90C2A0);
  end;
  result:=false;
end;

procedure OnJoinTeam(ID, Team: byte);
begin
  WriteConsole(ID,'This server runs the Namelength Restriction script by Avarax.',$90C2A0);
  WriteConsole(ID,'Maximum name length: ' + inttostr(MaxLength) + ' characters...',$90C2A0);
  If Length(GetPlayerStat(ID,'Name')) > MaxLength then begin
    WriteConsole(ID,'...your name is too long, please change it.',$90C2A0);
    DrawText(ID,'Your name is too long, please change it.',500,$90C2A0,0.075,20,320);
    KickPlayer(ID);
  end
  else
    WriteConsole(ID,'...name approved, have fun!',$90C2A0);
end;
« Last Edit: August 20, 2007, 08:12:48 am by Avarax »
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline SirJamesaford

  • Flagrunner
  • ****
  • Posts: 763
  • SirJamesaford is still in the early Beta stage.
Re: Namelength restriction
« Reply #1 on: August 20, 2007, 08:08:11 am »
OMG Are you going to put this in your hexer servers?  If so THANK YOU!
And if the dam breaks open many years too soon
And if there is no room upon the hill
And if your head explodes with dark forebodings too
Ill see you on the dark side of the moon

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Namelength restriction
« Reply #2 on: August 20, 2007, 08:30:53 am »
Would be better if you didnt write anything to the console. Especially the 'by avarax' stuff. Theres way too much console spam going on, this just adds to it