View Full Version : Reply To Player
Explicit
11-21-2012, 06:03 PM
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.
Laimonas171
11-21-2012, 06:09 PM
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.
Explicit
11-21-2012, 06:15 PM
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.
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.
Explicit
11-21-2012, 06:27 PM
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 :duh: 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?
There are array tutorials check the Intermediate and advanced section. There is a good one around there.
Explicit
11-21-2012, 07:10 PM
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 :confused:
Would I do something like:
var
Names: array[1..2] of string
begin
Names[1]:= 'Name1';
Names[2]:= 'Name2';
But how does this help :(
you could do a one liner.
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.
Explicit
11-21-2012, 07:37 PM
you could do a one liner.
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 :wacko:
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?
Those aren't actual Functions XD I just made them to express how to use the Arrays.
I think you'll want to use FindChatboxText: http://docs.villavu.com/srl-5/chat.html#findchatboxtext
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 ?
Explicit
11-21-2012, 11:08 PM
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 :confused:
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 :confused:
Add the people to a clan chat then just use FindChatboxText once you are in the clan chat. Turn everything else off.
Explicit
11-22-2012, 02:16 PM
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.
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
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.
Explicit
11-22-2012, 04:46 PM
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
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:
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.
Explicit
11-23-2012, 07:07 PM
Still can't get this to work :(
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.