Results 1 to 18 of 18

Thread: Reply To Player

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

    Default Reply To Player

    How do I code something in so my script will say a certain line when a select player(s) says something? I want my script to reply to a select few characters when they say a select line but not say anything when someone else says the same line.


    Ex. I want the script to reply to Player A and Player B only when they say "Hi" but if Player C says "Hi" I don't want it to respond.

  2. #2
    Join Date
    Nov 2008
    Location
    Norway, Alesund
    Posts
    924
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by Explicit View Post
    How do I code something in so my script will say a certain line when a select player(s) says something? I want my script to reply to a select few characters when they say a select line but not say anything when someone else says the same line.


    Ex. I want the script to reply to Player A and Player B only when they say "Hi" but if Player C says "Hi" I don't want it to respond.
    If you know what player name is check who write it and ignore it, if you have more then 1 username you should use array of usernames you want to ignore etc.

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

    Default

    Quote Originally Posted by Laimonas171 View Post
    If you know what player name is check who write it and ignore it, if you have more then 1 username you should use array of usernames you want to ignore etc.
    Well I just need it to do something if it see's select players talking. So instead of coding it to ignore people I would just want it to do an action if it picks up one of the select players said a keyword.

  4. #4
    Join Date
    Mar 2006
    Location
    Behind you
    Posts
    3,194
    Mentioned
    61 Post(s)
    Quoted
    63 Post(s)

    Default

    That's what he just said just do an array to check if the person talking is in the user array.

    You could also probably work this through PM as well. If your just doing a check on progress of a script then I'd advise this method.

    "Sometimes User's don't need the Answer spelled out with Code. Sometimes all they need is guidance and explanation of the logic to get where they are going."

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

    Default

    Quote Originally Posted by BraK View Post
    That's what he just said just do an array to check if the person talking is in the user array.

    You could also probably work this through PM as well. If your just doing a check on progress of a script then I'd advise this method.
    Oh sorry I'm very new to this so I don't exactly know what an array is, is there a tutorial I could read to help me? Or is this just adding multiple variables then when a variable turns up it runs that part of the script?

  6. #6
    Join Date
    Mar 2006
    Location
    Behind you
    Posts
    3,194
    Mentioned
    61 Post(s)
    Quoted
    63 Post(s)

    Default

    There are array tutorials check the Intermediate and advanced section. There is a good one around there.

    "Sometimes User's don't need the Answer spelled out with Code. Sometimes all they need is guidance and explanation of the logic to get where they are going."

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

    Default

    Quote Originally Posted by BraK View Post
    There are array tutorials check the Intermediate and advanced section. There is a good one around there.
    Thanks for the help but how would this help? The arrays are really confusing me

    Would I do something like:
    Simba Code:
    var
      Names: array[1..2] of string

    begin
      Names[1]:= 'Name1';
      Names[2]:= 'Name2';

    But how does this help

  8. #8
    Join Date
    Mar 2006
    Location
    Behind you
    Posts
    3,194
    Mentioned
    61 Post(s)
    Quoted
    63 Post(s)

    Default

    you could do a one liner.

    Simba Code:
    Function FindPChat : Boolean;
    var
      I : Integer;
      MyArr : TstringArray;

    Begin
      MyArr := ['First','second','third'];
      Result := False;

      For I := 0 to 2 do
        if Getchatusername(MyArr[I]) then
        begin
          Result := true;
          exit;
        end;
    end;

    The MyArr[0] refers to the first Item in the array. so it would be 'First'.

    Hope this helps.

    "Sometimes User's don't need the Answer spelled out with Code. Sometimes all they need is guidance and explanation of the logic to get where they are going."

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

    Default

    Quote Originally Posted by BraK View Post
    you could do a one liner.

    Simba Code:
    Function FindPChat : Boolean;
    var
      I : Integer;
      MyArr : TstringArray;

    Begin
      MyArr := ['First','second','third'];
      Result := False;

      For I := 0 to 2 do
        if Getchatusername(MyArr[I]) then
        begin
          Result := true;
          exit;
        end;
    end;

    The MyArr[0] refers to the first Item in the array. so it would be 'First'.

    Hope this helps.
    I'm crying on the inside

    So I would replace the first, second, third part with the usernames that I want the script to reply to, then after the Result := true; put in the code what I want the script to say? I need the script to reply the things said in the friends chat to, so does that mean I would also have to change the FindPChat to FindChatBoxText?

  10. #10
    Join Date
    Mar 2006
    Location
    Behind you
    Posts
    3,194
    Mentioned
    61 Post(s)
    Quoted
    63 Post(s)

    Default

    Those aren't actual Functions XD I just made them to express how to use the Arrays.

    "Sometimes User's don't need the Answer spelled out with Code. Sometimes all they need is guidance and explanation of the logic to get where they are going."

  11. #11
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    I think you'll want to use FindChatboxText: http://docs.villavu.com/srl-5/chat.html#findchatboxtext

  12. #12
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    Am I guessing right is in you want a script to catch anything that is said to you and repeat it in your friends chat for you to read ?

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

    Default

    Quote Originally Posted by CRU1Z1N View Post
    Am I guessing right is in you want a script to catch anything that is said to you and repeat it in your friends chat for you to read ?
    Not quite, the script is for my personal use and when me or any of my friends says a certain keyword I want it to say something in reply. But I don't want it to reply back if someone else says the keyword, only select people that I would program in.


    Thanks for the help guys but I still have no clue what I'm doing

  14. #14
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by Explicit View Post
    Not quite, the script is for my personal use and when me or any of my friends says a certain keyword I want it to say something in reply. But I don't want it to reply back if someone else says the keyword, only select people that I would program in.


    Thanks for the help guys but I still have no clue what I'm doing
    Add the people to a clan chat then just use FindChatboxText once you are in the clan chat. Turn everything else off.

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

    Default

    I don't want to have to do that though, I want it to be able to detect only my friends saying the keyword and ignore it when other people do.

  16. #16
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    You want to make some sort of dicing bot? When your "friend" or better said the owner of the CC says !dice then it rolls a dice between 1-100?

    You really need to look into arrays and FindChatBoxTextEx. Then compare the results from i = 8 downto 1 in the array. Or only roll when the text is at line 8 or 7. GetBlackChatMessage could also be used once you look into arrays it should be fairly simple to make.

    Well I'm in the train anyways and not much else to do so here you go
    Simba Code:
    program NameComparer;
    {$i SRL/SRL.simba}

    const
      HostName = 'Host Scumbag';
      DiceMessage = '!roll';

    function GetLastChatLines: Array[0..1] of String;
    var
      i: Integer;

    begin
      for i:=8 downto 7 do
        Result[i-7] := GetChatBoxText(i, clBlack);
    end;

    function NeedToRoll: boolean;
    var
      i: Integer;
      Texts: Array[0..1] of String;

    begin
      Texts := GetLastChatLines;
      for i:=0 to high(Texts) do
        if Pos(HostName, Texts[i]) > 0 then
          if Pos(DiceMessage, Texts[i]) > 0 then
          begin
            Result := True;
            break;
          end;
    end;

    begin
      while LoggedIn do
        if NeedToRoll then
        begin
          TypeSendEx(IntToStr(RandomRange(1, 100)), True);
          Wait(RandomRange(2000, 3000));
        end;
    end.

    Should work, note that someone could imitate the host.
    Eg. RS_Lover2001 could say Host Scumbag !roll to make it roll. To avoid this you can do some stuff like checking the length of the string and the positions. But other than that I guess this will work.

    If you weren't making a dicing bot then it's still a good example.

    Script source code available here: Github

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

    Default

    Quote Originally Posted by J J View Post
    You want to make some sort of dicing bot? When your "friend" or better said the owner of the CC says !dice then it rolls a dice between 1-100?

    You really need to look into arrays and FindChatBoxTextEx. Then compare the results from i = 8 downto 1 in the array. Or only roll when the text is at line 8 or 7. GetBlackChatMessage could also be used once you look into arrays it should be fairly simple to make.

    Well I'm in the train anyways and not much else to do so here you go
    Simba Code:
    program NameComparer;
    {$i SRL/SRL.simba}

    const
      HostName = 'Host Scumbag';
      DiceMessage = '!roll';

    function GetLastChatLines: Array[0..1] of String;
    var
      i: Integer;

    begin
      for i:=8 downto 7 do
        Result[i-7] := GetChatBoxText(i, clBlack);
    end;

    function NeedToRoll: boolean;
    var
      i: Integer;
      Texts: Array[0..1] of String;

    begin
      Texts := GetLastChatLines;
      for i:=0 to high(Texts) do
        if Pos(HostName, Texts[i]) > 0 then
          if Pos(DiceMessage, Texts[i]) > 0 then
          begin
            Result := True;
            break;
          end;
    end;

    begin
      while LoggedIn do
        if NeedToRoll then
        begin
          TypeSendEx(IntToStr(RandomRange(1, 100)), True);
          Wait(RandomRange(2000, 3000));
        end;
    end.

    Should work, note that someone could imitate the host.
    Eg. RS_Lover2001 could say Host Scumbag !roll to make it roll. To avoid this you can do some stuff like checking the length of the string and the positions. But other than that I guess this will work.

    If you weren't making a dicing bot then it's still a good example.
    Thats EXACTLY what I'm trying to do, but I need it for multiple hosts and I don't understand some of the code, or how I could edit it if I need to. I also need it to say "Player" rolled "the random number" so how could I do that?

    This is what I made to log the dice account in and it works exactly how I want it, I just need to implement having it detect when certain people say !Roll and then saying that players name along with the number rolled:
    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;
      S: String;

    begin
    repeat
    R := (Random(100) + 1)

     if FindChatBoxText('!Roll', 8, clFriend) then
      TypeSend('/(rollername) rolled a <' + IntToStr(R) + '> on a 100 percentile dice.');
      wait(1000);
     until(false)
    end;

    begin
      SRL_SixHourFix := True;
      SMART_FixSpeed := True;
      ClearDebug;
      SetupSRL;
      DeclarePlayers;
      LoginPlayer;
      DiceRoll;
      if not (LoggedIn) then
        LoginPlayer;
    end.
    Last edited by Explicit; 11-22-2012 at 04:54 PM.

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

    Default

    Still can't get this to work

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
  •