Results 1 to 7 of 7

Thread: Random

  1. #1
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Random

    Is there a way for scar to use the random function to create random usernames or just random letters. This isn't for runescape by the way. Just a question. For example if you use the random(26) and each number 1-26 corresponds to a letter and then does that for a 10 letter word. Then types that word with a typekeys(x) function. If someone knows how to do this it would be a great help.

  2. #2
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    i made this awhile back

    SCAR Code:
    function RandStr(Length: integer): string;
    var
      TSA: TStringArray;
      I: integer;
    begin
      TSA := ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
                  'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
                  'y', 'z', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                  'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
                  'V', 'W', 'X', 'Y', 'Z'];

      for I := 1 to Length do
        Result := Result + TSA[Random(High(TSA) + 1)];
    end;
    Last edited by Dgby714; 05-08-2010 at 04:18 AM.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  3. #3
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    function randStr(len: Integer): String;
    var
      ind, i: Integer;
      chars: String;
    begin
      chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
      for i := 1 to len do
        if (random(0) = 1) then
          result := result + uppercase(chars[random(len) + 1]);
        else
          result := result + chars[random(len) + 1];
    end;
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  4. #4
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    SCAR Code:
    function randStr(len: Integer): String;
    var
      ind, i: Integer;
      chars: String;
    begin
      chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
      for i := 1 to len do
        if (random(0) = 1) then
          result := result + uppercase(chars[random(len) + 1]);
        else
          result := result + chars[random(len) + 1];
    end;
    I think you broke yours =/ if len > Length(char) then it will error should be

    SCAR Code:
    function RandStr(Len: Integer): string;
    var
      I: Integer;
      Chars: string;
    begin
      Chars := 'abcdefghijklmnopqrstuvwxyz0123456789';
      for i := 1 to Len do
        if (Random(2) = 1) then
          Result := Result + uppercase(Chars[Random(Length(Chars)) + 1])
        else
          Result := Result + Chars[Random(Length(Chars)) + 1];
    end;
    Last edited by Dgby714; 05-08-2010 at 04:15 AM.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  5. #5
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    This should work:

    SCAR Code:
    function RandStr(Len: Integer): string;
    var
      I, cLen: Integer;
      Chars: string;
    begin
      Chars := 'abcdefghijklmnopqrstuvwxyz0123456789';
      cLen := length(chars);  
      for i := 1 to Len do
        if (Random(2) = 1) then
          Result := Result + uppercase(Chars[Random(cLen) + 1])
        else
          Result := Result + Chars[Random(cLen) + 1];
    end;
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  6. #6
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    This should work:

    SCAR Code:
    function RandStr(Len: Integer): string;
    var
      I, cLen: Integer;
      Chars: string;
    begin
      Chars := 'abcdefghijklmnopqrstuvwxyz0123456789';
      cLen := length(chars);  
      for i := 1 to Len do
        if (Random(2) = 1) then
          Result := Result + uppercase(Chars[Random(cLen) + 1])
        else
          Result := Result + Chars[Random(cLen) + 1];
    end;
    Yeah i posted yours again edited to work =)

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  7. #7
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks Guys, I will make sure to give said person credit for whichever one I decide to use. The script will only be used by me and like two other friends and wont be on SRL so thanks.

    Disregard what it used to say here I got it to work... I'm using Nava2's function after he fixed it.

    Thanks,

    Death
    Last edited by Death12652; 05-08-2010 at 08:35 AM.

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
  •