SRL Archive - SRL Archives

Auto Nickname Getter


Mad Cow

2006-10-28 17:42:11

Well I have been bored lately and have had trouble how I can make SRL more efficient. So I decided to make a nickname finder. I don't know how useful it is but incase some noob forgets to set it it will set it for them.

If the nick is already declared then it will skip it.

Well enjoy guys
// * function FixUsername(Username : String) : String;      // * by Mad Cow
// * function GetNick(Username : String) : String; // * by Mad Cow
// * procedure LoadNullWords; // * by Mad Cow

program GetNick;
{.include SRL/SRL.scar}

var
I : Integer;
SkipItems : array[1..20] of String;

const
AmmountPlayers = 4;//How many players?

procedure DeclarePlayers;
begin
NumberOfPlayers(AmmountPlayers);

Players[0].Name := 'YeS tHe MaNN';//skips 'the', 'yes' and 'man'
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;

Players[1].Name := 'orange';
Players[1].Pass := '';
Players[1].Nick := '';
Players[1].Active := True;

Players[2].Name := 'my name is john';
Players[2].Pass := '';
Players[2].Nick := '';
Players[2].Active := True;

Players[3].Name := 'so u noob';
Players[3].Pass := '';
Players[3].Nick := '';
Players[3].Active := True;

for I := 0 to HowManyPlayers - 1 do
begin
Players[I].Active := True;
end;
end;

{*******************************************************************************
function FixUsername(Username : String) : String;
By: Mad Cow
Description: Fixes up the Username
*******************************************************************************}
function FixUsername(Username : String) : String;
var
Count, CCount : Integer;
TUsername, Alph, AAlph : String;
begin
Alph := 'abcdefghijklmnopqrstuvwxyz';
AAlph := Uppercase(Alph);
TUsername := Uppercase(Username);
StrSet(StrGet(TUsername, 1), 1, Username);
for Count := 1 to Length(Username) do
begin
for CCount := 1 to 26 do
if(StrGet(Username, Count) = Copy(AAlph, CCount, 1)) then
StrSet(StrGet(Alph, CCount), Count, Username);
if(StrGet(Username, Count) = ' ') or (StrGet(Username, Count) = '_')then
StrSet(StrGet(TUsername, Count + 1), Count + 1, Username);
end;
Result := Username;
end;

{*******************************************************************************
procedure LoadNullWords;
By: Mad Cow
Description: Loads words to skip in GetNick
*******************************************************************************}
procedure LoadNullWords;
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';
end;

{*******************************************************************************
function GetNick(Username : String) : String;
By: Mad Cow
Description: Get's the player nick skipping common words
*******************************************************************************}
function GetNick(Username : String) : String;
var
UserLength, NickStart, INick, A : Integer;
Nick, Temp : String;
BadNick : Boolean;
begin
Username := FixUsername(Username);
UserLength := Length(Username);
INick := 0;
LoadNullWords;
repeat
BadNick := False;
NickStart := 2 + INick;
Nick := Nick + Copy(Username, NickStart, 3);
for A := 1 to 3 do
begin
Temp := Copy(Nick, A, 1);
if(Temp = ' ') or (Temp = '_')then
begin
INick := INick + 1;
Nick := '';
BadNick := True;
end;
end;
for A := 1 to 20 do
begin
if(Nick = SkipItems[A]) then
begin
INick := INick + 1;
Nick := '';
BadNick := True;
end;
end;
until((not(BadNick)) or (NickStart >= 15))
Result := Nick;
end;

begin
SetupSRL;
DeclarePlayers;
ClearDebug;

for I := 0 to AmmountPlayers - 1 do
begin
if(Players[I].Nick = '') then
begin
Players[I].Nick := GetNick(Players[I].Name);
WriteLn('Player[' + IntToStr(I) + '].Nick := ' + Players[I].Nick + ';');
end;
end;

NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
end.

EDIT: Put it in code tags because the scar tags were stacking the begins and ends

Post comments and suggestions,
Mad Cow ;)

Boreas

2006-10-28 22:23:29

Good idea, should cut down on the amount of noobs posting questions answered a million times.

Mad Cow

2006-10-29 01:06:02

Thanks for the comment. Any suggestions people?

Mad Cow

lardmaster

2006-10-29 12:21:59

it should be simpler than that,


Uname:=uppercase(players[currentplayer].name)
i:=1
while (i<lenth(name)-3) and bad do begin
players[currentplayer].nick:=copy(Uname,i,3);
bad:=false;
for j:=1 to 20 do if players[currentplayer].nick=skipitems[j] then bad:=true;
i:=i+1
end
if bad then begin
writln('your username sux, get a new account');
{{exit program}}
end

Flyboy

2006-10-29 15:18:18

good idea with the skipped words

YoHoJo

2006-10-29 17:32:03

very nice.
thats one less line of setup on player form w00t!

WhiteShadow

2006-10-31 21:43:31

Fawki will spazzz. ;D

He likes manual pick, for the best accuracy.

Mad Cow

2006-11-01 02:13:45

From: WhiteShadow
Fawki will spazzz. ;D

He likes manual pick, for the best accuracy.


Maybe:
if(Players[CurrentPlayer].Nick = '') then
GetNick… etc.

So then the user has a choice and if they forget to set it, it will set it for them ;-)

Mad Cow

Wanted

2007-07-07 19:07:58

Ok, this is some MAJOR grave digging, but this is a really awesome snippet by MadCow that I still use,

Thanks MadCow!

Sumilion

2007-07-07 19:14:20

You could also use

CheckUserNicks;

Santa_Clause

2007-07-07 19:29:11

Lmao…and we tell the non-members not to gravedig

Bobarkinator

2007-07-07 21:23:25

this is probably the biggest grave dig I have ever seen lol. Still a good snippet