Results 1 to 9 of 9

Thread: Need Help With First Script!

  1. #1
    Join Date
    Dec 2011
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Need Help With First Script!

    Hey guys I know I'm new here but I'm really interested in learning to script. I read through the newbie tutorials and watched YoHoJo's videos and I can say I have an ehhh "basic" understanding of what I'm doing. :P

    What I need help with is how to script an Auto Responder type program that would basically act like a dice bag in account form. I thought this would be a cool idea as it is my first script and I don't think it would be to over the top to code.


    Just an overview of what I'm trying to accomplish, I want to run a script which would open up SMART, log into the lobby, stay there in a friends chat and when a select person says something like "Roll" the script would see it and say a random number between lets say 1 and 10.

    Any help would be much appreciated but please don't code this for me. I want to learn how to do this myself so I can make my own more complicated scripts in the future

    Here's what I have so far (I have the r variable there just as a placeholder for a random number):
    Simba Code:
    program DiceBot;
    {$DEFINE SMART}
    {$I SRL/SRL.Simba}

    procedure DiceRoll;
    var
      r: Integer;
    begin
    if FindChatBoxText('!Roll', 8, clFriend) then
      TypeSend('Rolling the dice!');
      repeat
      DiceRoll;
      until(false);
    end;

    begin
      DiceRoll;
    end.
    Last edited by Explicit; 11-19-2012 at 06:16 PM.

  2. #2
    Join Date
    Oct 2012
    Location
    Porto, Portugal
    Posts
    218
    Mentioned
    0 Post(s)
    Quoted
    42 Post(s)

    Post

    first of all to login to rs you should have a declare players procedure. then in the bottom of the script where you have
    Simba Code:
    begin
       DiceRoll;
    end.

    you will have
    Simba Code:
    begin
    DeclarePlayers;
    LoginPlayer;
    DiceRoll;
    end.



    the declare players procedure looks like this:
    Simba Code:
    procedure DeclarePlayers;
    begin
    HowManyPlayers := 1;
    NumberOfPlayers(HowManyPlayers);
    CurrentPlayer := 0;

    Players[0].Name := ''
    Players[0].Pass := ''
    Players[0].Nick := ''
    Players[0].Pin  := ''
    Players[0].Active := True
    end;



    try it out and see if u can login to rs. u have to fill the '' with ur rs username and pass
    Last edited by Sax; 11-19-2012 at 07:03 PM.

  3. #3
    Join Date
    Dec 2011
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    OK thanks! So now I have
    Simba Code:
    program DiceBot;
    {$DEFINE SMART}
    {$I SRL/SRL.Simba}

    procedure DeclarePlayers;
    begin
    HowManyPlayers := 1;
    NumberOfPlayers(HowManyPlayers);
    CurrentPlayer := 0;

    Players[0].Name := 'Test'
    Players[0].Pass := 'Test'
    Players[0].Nick := ''
    Players[0].Pin  := ''
    Players[0].Active := True
    end;
    procedure DiceRoll;
    var
      r: Integer;
    begin
    if FindChatBoxText('!Roll', 8, clFriend) then
      TypeSend('Rolling the dice!');
      repeat
      DiceRoll;
      until(false);
    end;

    begin
      DeclarePlayers;
      LoginPlayer;
      DiceRoll;
    end.

  4. #4
    Join Date
    Oct 2012
    Location
    Porto, Portugal
    Posts
    218
    Mentioned
    0 Post(s)
    Quoted
    42 Post(s)

    Default

    what exactly you want to do here.
    repeat
    DiceRoll;
    until (false)
    DiceRoll is the name of the procedure. You cant call a procedure inside the procedure itself.

  5. #5
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    yes u can call a procedure inside itself, its called recursion, but in this situation its not needed, he should put the loop outside the procedure

  6. #6
    Join Date
    Oct 2012
    Location
    Porto, Portugal
    Posts
    218
    Mentioned
    0 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by KingKong View Post
    yes u can call a procedure inside itself, its called recursion, but in this situation its not needed, he should put the loop outside the procedure
    ooh didnt know that. well, u should replace
    Simba Code:
    repeat
    DiceRoll;
    until (false);

    for what u want the script to do when it receives orders to dice. I'll not post here because you said u wanted to learn but if you want I can try to make it.

    Hint: you should use Random(10) + 1 because Random(10) generates a nr from 0 to 9 so if u add 1 it will give u numbers from 1 to 10.

    Also you should check the procedures/functions in the include that can type in rs.

  7. #7
    Join Date
    Dec 2011
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Nirvana View Post
    ooh didnt know that. well, u should replace
    Simba Code:
    repeat
    DiceRoll;
    until (false);

    for what u want the script to do when it receives orders to dice. I'll not post here because you said u wanted to learn but if you want I can try to make it.

    Hint: you should use Random(10) + 1 because Random(10) generates a nr from 0 to 9 so if u add 1 it will give u numbers from 1 to 10.

    Also you should check the procedures/functions in the include that can type in rs.
    Alright thanks for the help guys. I'm still trying to get this but its kinda hard if you make the script then don't give it to me unless you explain each line of code so I know exactly what you did and why it works

    This is what I have now:
    Simba Code:
    program DiceBot;
    {$DEFINE SMART}
    {$I SRL/SRL.Simba}

    procedure DeclarePlayers;
    begin
    HowManyPlayers := 1;
    NumberOfPlayers(HowManyPlayers);
    CurrentPlayer := 0;

    Players[0].Name := 'Test'
    Players[0].Pass := 'Test'
    Players[0].Nick := ''
    Players[0].Pin  := ''
    Players[0].Active := True
    end;


    var
      R: Integer;

    procedure DiceRoll;
    begin
    R := Random(100) + 1
    if FindChatBoxText('!Roll', 8, clFriend) then
      TypeSend('Rolling the dice!');
      Wait(500);
      TypeSend('The number rolled was' + IntToStr(R) + '.');
    end;

    begin
      DeclarePlayers;
      LoginPlayer;
      DiceRoll;
    end.
    Last edited by Explicit; 11-19-2012 at 08:47 PM.

  8. #8
    Join Date
    Oct 2012
    Location
    Porto, Portugal
    Posts
    218
    Mentioned
    0 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by Nirvana View Post
    the var should go after procedure and before begin like this:

    Simba Code:
    program DiceBot;
    {$DEFINE SMART}
    {$I SRL/SRL.Simba}

    procedure DeclarePlayers;
    begin
    HowManyPlayers := 1;
    NumberOfPlayers(HowManyPlayers);
    CurrentPlayer := 0;

    Players[0].Name := 'Test'
    Players[0].Pass := 'Test'
    Players[0].Nick := ''
    Players[0].Pin  := ''
    Players[0].Active := True
    end;



    procedure DiceRoll;


    var
      R: Integer;

    begin
    R := Random(100) + 1
    if FindChatBoxText('!Roll', 8, clFriend) then
    begin
      TypeSend('Rolling the dice!');
      Wait(500);
      TypeSend('The number rolled was' + IntToStr(R) + '.');
    end;

    begin
      DeclarePlayers;
      LoginPlayer;
      DiceRoll;
    end.

    did you tried running it already?
    I think it should work now.
    Last edited by Sax; 11-19-2012 at 10:54 PM.

  9. #9
    Join Date
    Dec 2011
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Nirvana View Post
    did you tried running it already?
    I think it should work now.
    It opens up SMART and logs in fine, but it keeps repeating just the "number rolled was" part over and over again without even looking for an chat dialog of !Roll
    Last edited by Explicit; 11-20-2012 at 01:57 PM.

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
  •