SRL Archive - SRL Archives

Never mess around with nicknames again!


Abyssal

2007-05-14 17:55:58


function CreateNick(Name: string): string;
begin
Delete(Name, 1, 1);
while (Length(Name) > 3) do
begin
case Random(2) of
0: Delete(Name, 1, 1);
1: Delete(Name, Length(Name), 1);
end;
end;
Result:= Name;
end;

program NickCreator;

const
CharName = 'Babylonian'; //Full character name.

function CreateNick(Name: string): string;
begin
Delete(Name, 1, 1);
while (Length(Name) > 3) do
begin
case Random(2) of
0: Delete(Name, 1, 1);
1: Delete(Name, Length(Name), 1);
end;
end;
Result:= Name;
end;

begin
Writeln(CreateNick(CharName));
end.


Always creates a 3 letter nickname. To make it four, or five, then change the line 'while (Length(Name) > 3) do' to 4 instead of 3.

Also, here's a function that will take your player array and create all the nicknames for you!

procedure MakeNicknames(var ThePlayers: array of TUser);
var
i: Integer;
begin
Writeln('Creating nicknames...');
for i:= 0 to GetArrayLength(ThePlayers) - 1 do
begin
ThePlayers[i].Nick:= CreateNick(ThePlayers[i].Name);
Writeln(' -> Players[' + IntToStr(i) + '].Nick:= ' + ThePlayers[i].Nick);
end;
end;

Well, there they are. Hopefully we can eliminate the setup of nicknames, because I know some people don't even know what it's for.


~Abyssal

Wanted

2007-05-14 22:58:20

This poses problems… I use this procedure in my scripts. (it also sets the Location)

Loading Null Words is the main problem with your procedure also you can just add this 2 lines to your script

@Star and MadCow this is great for any script, why aren't these procedures already in SRL?

GenerateNickNames;

var
SkipItems: array[1..21] of string;




procedure LoadNullWords; //Thanks Star And Mad Cow - Credits goto them
begin
SkipItems[1] := 'the';
SkipItems[2] := 'but';
SkipItems[3] := 'yes';
SkipItems[4] := 'lol';
SkipItems[5] := 'brb';
SkipItems[6] := 'gtg';
SkipItems[7] := 'cya';
SkipItems[8] := 'how';
SkipItems[9] := 'hey';
SkipItems[10] := 'wat';
SkipItems[11] := 'umm';
SkipItems[12] := 'him';
SkipItems[13] := 'she';
SkipItems[14] := 'man';
SkipItems[15] := 'wow';
SkipItems[16] := 'god';
SkipItems[17] := 'nub';
SkipItems[18] := 'nop';
SkipItems[19] := 'did';
SkipItems[20] := 'you';
SkipItems[21] := 'ing';
end;

function CreateNick(Username: string): string; //Thanks Star and Madcow - Credits goto them
var
UserLength, NickStart, INick, A: Integer;
Nicks, Temp: string;
BadNick: Boolean;
begin
UserLength := Length(Username);
INick := 0;
LoadNullWords;
repeat
BadNick := False;
NickStart := 2 + INick;
Nicks := Nicks + Copy(Username, NickStart, 3);
for A := 1 to 3 do
begin
Temp := Copy(Nicks, A, 1);
if (Temp = ' ') or (Temp = '_') then
begin
INick := INick + 1;
Nicks := '';
BadNick := True;
end;
end;
for A := 1 to 21 do
begin
if (Nicks = SkipItems[A]) then
begin
INick := INick + 1;
Nicks := '';
BadNick := True;
end;
end;
until ((not (BadNick)) or (NickStart >= 15))
Result := Nicks;
end;

procedure GenerateNickNames; //Thanks to Star and Mad cow, Edited by Icefire908
begin
Writeln('');
Writeln('Creating Nicknames:');
Status('Creating Nicknames');
for X := 0 to HowManyPlayers - 1 do
begin
if (Players[X].Nick = '') then
begin
Players[X].Nick := CreateNick(Players[X].Name);
WriteLn(' Players[' + IntToStr(X) + '].Nick := ' + Players[X].Nick + ';');
Wait(1);
end;
end;
Writeln('');
Status('Setting Players Current Location:');
for X := 0 to HowManyPlayers - 1 do
Players[X].Loc := 'Not Yet Started Autoing';
Status('If you see this Message for Longer than 60 Seconds, Stop the Script and Restart Straight Away!');
end;

Abyssal

2007-05-15 08:09:45

If you set it to 4 or 5 letters that usually won't happen.

I was just messing around with it and I had no problems.