SRL Archive - OSR Help

How to start a procedure if a player says something?


ploxcake

2012-11-12 10:11:33

My plan was to make a script where I make all my bots join a FC and if this guy (my main) named let's say "owner" said Something like "!status" or just anything, could that go into a procedure or something?

Just for example.
All bots have joined my fc
My main says "sayhi"
Then would it be possible for my accounts to stop whatever they're doing and say "hi" in the chat, then go back to what they were doing?

I've searched around but didn't found any answars :/

edit: Also, I don't wanna make a new thread for only this little question

Can you start multiplie runescape bots with autologin by just running on .simba file?
Cause I can't get it to work with more than one window :o


Thanks in advance

nokkasiili

2012-11-12 10:17:48

http://docs.villavu.com/srl-5/chat.html#getchatboxtext
Try using this

ploxcake

2012-11-12 10:25:14

From: nokkasiili
http://docs.villavu.com/srl-5/chat.html#getchatboxtext
Try using this


I'm on a very basic level, trying to learn.
I do not really understand how I get that to "do" whatever I want it to do :(

Sin

2012-11-12 10:25:38

Easy. On my phone so bare with me.
Basically search the chat box for the message(FindChatBoxText()), and when I results true, start a procedure.
It isn't too complicated and if you can wait an hour or two till I can get on my laptop.

ploxcake

2012-11-12 10:48:48

From: Shay
Easy. On my phone so bare with me.
Basically search the chat box for the message(FindChatBoxText()), and when I results true, start a procedure.
It isn't too complicated and if you can wait an hour or two till I can get on my laptop.


I can wait, I don't think its too hard to just do the command, but for it to be active all the time I think it's pretty hard

So I'll wait till the pro comes online :)

footballjds

2012-11-12 11:08:18

From: ploxcake
I can wait, I don't think its too hard to just do the command, but for it to be active all the time I think it's pretty hard

So I'll wait till the pro comes online :)


it can't be active all the time. and I really don't think that's what you want. Calling the procedure to check the chat box every couple seconds is PLENTY. Just shove it in a logical location within your main loop. If you post the script I or someone else would be glad to implement it. It'd take about 2 minutes :P

Ian

2012-11-12 11:22:56

Just remember to set all other chats to off so that it doesn't miss it between checks.

ploxcake

2012-11-12 11:42:40

From: footballjds
it can't be active all the time. and I really don't think that's what you want. Calling the procedure to check the chat box every couple seconds is PLENTY. Just shove it in a logical location within your main loop. If you post the script I or someone else would be glad to implement it. It'd take about 2 minutes :P


Not really wanna share my script for now :s

I can implent it myself, but I will need the procedure code for let's say "KilledYou" (or just anyone) says "sayhi" in the fc and make the bot say hi just once and return to what it was doing even if the message still is there, and I can fix it if I did something wrong

I'm pretty used to coding languages, I just need the procedure code and I can do the rest

Thanks in advance

And I'd still appericate a answar if you can run multiplie bots (let's say cowhide collector with auto login inbuilt) from just running one .simba file or do you need to run one simba window for each bot?

Thanks in advance, again :D

Ian

2012-11-12 12:17:24

You need one tab for each, but I like to use separate windows so that I can see different debugs.(right now they both print into the same box at the same time so it is hard to read.)

Roflme

2012-11-12 12:25:13


if FindChatBoxText(Text: string; Line: Integer; TextCol: Integer) then
// Procedure

In it's simplest form.

You could even add multiple lines so you would chat multiple messages before the procedure starts. :p





while FindChatBoxText(Text: string; Line: Integer; TextCol: Integer) do
//Procedure

You can use this too, or any of the many other forms.




The only problem is that if nothing else is said, it will continue to perform the procedure so long as the line of chat remains the same. So if you want the procedure to act when the first line says "go", as long as nobody else chats or no other messages fill the chat box, the procedures will continue to repeat.

ploxcake

2012-11-12 12:45:12

From: Roflme

if FindChatBoxText(Text: string; Line: Integer; TextCol: Integer) then
// Procedure



So like

if FindChatBoxText(Text: ('status')); then
// Procedure
?

If I do that "[Error] Unknown identifier 'Text' at line 61" comes up :/

Lalaji

2012-11-12 13:19:06

i would recommend looking at the remotecontrol file in SRL. is it rc.sex? not sure of the name. But you can add your main as the master, and use some of those already included functions.

Mark

2012-11-12 13:20:27

if FindChatBoxText(Text: string; Line: Integer; TextCol: Integer) then

this is it

You need to define what line you want to check then the color of the text like so

If FindChatBoxText('you string',line,Color) then talkback;

String is the word you want to keep checking
Line is the line you want to check for the word from (1-8) top to bottom.
The color is the color of the text you can specify your own or use the built in one's not sure if there still up to date don't use them myself.

On phone so abit sloppy

ploxcake

2012-11-12 13:53:16

edit: thanks all for helping!

the command 'If FindChatBoxText('!Status',8,239) then TypeSend ('/here');' worked out good for me :)

cheers

Hunaja

2012-11-12 14:02:46

I'd do


repeat
if FindChatBoxText('sayhello', 8, 0) { searches for sayhello at line 8 with colour 0 (black) }
then TypeSendEx('/Hello', true); {Types /Hello and presses enter}

Wait(1000+Random(500)); { We don't want to search for sayhello every millisecond, do we? So let's wait second~ before searching again }
until(World Ends);

Sin

2012-11-12 14:08:05



function MessageFound(s:String; c:Integer;):Boolean;
var
i:Integer;
begin
for i := 1 to 8 do
Result := FindChatBoxText(s,i,c);
end;

procedure DoWhatever;
begin
if MessageFound('string',color) then
Doshit;
end;

begin
repeat
Dowhatever;
until false;
end.

Replace 'string' and Color with your message/color.

Mark

2012-11-12 14:40:02

I made a script which this reminds me of I called it
BitchBot. As I used it as slave to bank all ores mined by my farm of power miners in varrock very simular to what you did with the clanchat except I sent commands for the bot to follow ie. If one of the miners said comehere it got the current sps location and then walked there and continued to wait for trade request then returned to the bank never finished got it 100% but it worked great I even used it to run bars from bank to the furnace to make cballs.

I did have and idea to host it on a vps but never got round to it.

Ian

2012-11-12 14:42:59

From: CRU1Z1N
I made a script which this reminds me of I called it
BitchBot. As I used it as slave to bank all ores mined by my farm of power miners in varrock very simular to what you did with the clanchat except I sent commands for the bot to follow ie. If one of the miners said comehere it got the current sps location and then walked there and continued to wait for trade request then returned to the bank never finished got it 100% but it worked great I even used it to run bars from bank to the furnace to make cballs.

I did have and idea to host it on a vps but never got round to it.


That's pretty epic, you could even have it report to you if a miner had gotten lost by checking to see how often it had new loads ready :D

footballjds

2012-11-12 15:13:35

From: CRU1Z1N
I made a script which this reminds me of I called it
BitchBot. As I used it as slave to bank all ores mined by my farm of power miners in varrock very simular to what you did with the clanchat except I sent commands for the bot to follow ie. If one of the miners said comehere it got the current sps location and then walked there and continued to wait for trade request then returned to the bank never finished got it 100% but it worked great I even used it to run bars from bank to the furnace to make cballs.

I did have and idea to host it on a vps but never got round to it.


I've wanted to do this, my idea was to release a public script that mined ore's and dropped them or traded them if a mule was available to receive them. It'd have been released in SRL+ for obvious ban evasion reasons but i never got around to it :/

Footy

2012-11-12 15:15:43

From: Shay


function MessageFound(s:String; c:Integer;):Boolean;
var
i:Integer;
begin
for i := 1 to 8 do
Result := FindChatBoxText(s,i,c);
end;

procedure DoWhatever;
begin
if MessageFound('string',color) then
Doshit;
end;

begin
repeat
Dowhatever;
until false;
end.

Replace 'string' and Color with your message/color.


Won't work. You need to break out of the loop if you find the chatbox chat, otherwise it will only count the 8'th line.

Hunaja

2012-11-12 15:27:37

From: Footy
Won't work. You need to break out of the loop if you find the chatbox chat, otherwise it will only count the 8'th line.

… and with breaking one 'string' will make it do Doshit eight times

Sin

2012-11-13 07:48:33

From: Footy
Won't work. You need to break out of the loop if you find the chatbox chat, otherwise it will only count the 8'th line.


Umm what?
It'll result true if it finds the message within the 8 lines of the chat box.
No need to break out of it since its already limited to 8.

riwu

2012-11-13 07:53:39

From: Shay
Umm what?
It'll result true if it finds the message within the 8 lines of the chat box.
No need to break out of it since its already limited to 8.

Footy is right. Even if at one of the line the result is set to true, if you continue the loop it may be set to false again. Break when result is true.

Also it is more convenient to just use IsChatBoxTextAnyLine ;)

Sin

2012-11-13 07:55:44

From: riwu
Footy is right. Even if at one of the line the result is set to true, if you continue the loop it may be set to false again. Break when result is true.


I'm still not following, I was using that function a while back and it didn't have any errors.
Was using it as a Dragon Dyce spammer in case anyone's interested lol.

E* Ah I gotcha, was thinking about something else. derppp.

riwu

2012-11-13 08:00:13

Okay let's see…

function MessageFound(s:String; c:Integer;):Boolean;
var
i:Integer;
begin
for i := 1 to 8 do
Result := FindChatBoxText(s,i,c);
end;
If let's say line 1-7 has the text, the result will be set to true.

BUT if line 8 does not have the text, FindChatBoxText will return false, and therefore Result:= False. So basically the result will only depend on line 8. It's as good as just doing:
FindChatBoxText(s, 8, c);

It worked for you probably because the text just happened to appear on line 8.