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
EDIT: Put it in code tags because the scar tags were stacking the begins and ends
Post comments and suggestions,
Mad Cow ;)
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 ;)