Results 1 to 3 of 3

Thread: RsLikeUsername

  1. #1
    Join Date
    Jun 2007
    Location
    #SRL
    Posts
    200
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default RsLikeUsername

    I was kinda bored, and i got to thinking, "Hey, there's no way to tell if a username is too long, or if contains invalid characters (underscores, @,#,$, etc...), is there?!" so i made this, i makes any string just like a RS username would be, it'd be useful like:

    SCAR Code:
    procedure DeclarePlayers;
    begin
      Players[0].Name:= RsLikeUsername({Insert Username here!});
    //blah blah, the rest of the players code here
    end;

    Well, here it is:

    SCAR Code:
    program RsLikeUsername;

    function RsLikeUsername(S: string): string;
    var
    i: Integer;
    begin
      s:= Lowercase(s);
      s:= Replace(s,'_',' ');
      for i:= 33 to 47 do
        s:= Replace(s,Chr(i),'');
      for i:= 58 to 64 do
        s:= Replace(s,Chr(i),'');
      for i:= 91 to 96 do
        s:= Replace(s,Chr(i),'');
      for i:= 123 to 126 do
        s:= Replace(s,Chr(i),'');
      s:= Trim(s);
      s:= Capitalize(s);
      i:= 0;
      repeat
        s:= Replace(s,'  ',' ');
      until(Pos('  ',s)=0);
      if(Length(s)>=12) then
        Delete(s,13,Length(s)-12);
      Result:= s;
    end;

    begin
      Writeln(RsLikeUsername('!@@@@.  #__-_w__$#$%^&^%o___$r#%^   %$% &   *(__ _*&^%$#$     ___%k^%%{}  {{}{:"">?>s?":{:%^_&*  (  '));
    end.

    And the output is:
    SCAR Code:
    Successfully compiled
    W O R K S
    Successfully executed

    Wow, i made that like 50 lines shorter since i started it lol

    EDIT: uhh... what's the difference between "Replace" and "ReplaceRegex"? cause i used both, and they seem to be interchangeable...
    Quote Originally Posted by IRC
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 43
    <Wizzup> shit
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 3
    <Wizzup> 1
    <Wizzup> offblast

  2. #2
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Google Regex.. Its an complex system of string finding etc..
    Verrekte Koekwous

  3. #3
    Join Date
    Jun 2007
    Location
    #SRL
    Posts
    200
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    oooo wow, that's cool, you can use other modifers with Regex
    Quote Originally Posted by IRC
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 43
    <Wizzup> shit
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 3
    <Wizzup> 1
    <Wizzup> offblast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •