SRL Archive - RS3 Outdated / Broken Scripts

An Example of Remote Control


nght spud

2007-05-24 15:57:33

This is only my second script so please gimme ideas how to improve it.
Ok this is a script I just wrote, and it basically is an example of how Remote control can be used. It contains six functions I wrote myself.
  • One function is to see if you got a message to, or from, and returns 'to' or 'from'.
  • The second function finds out who you messaged / messaged you.
  • The third function looks across the whole PM for a certain word works even if there is text before, or after the word. Returns true if the word is found.
  • The fourth function Looks at what is said, and returns what is said between the words you declared(easier to understand if you look at script.
  • The fith function looks up someones level in the highscores.
  • The sixth function looks up someones combat level, by finding their lvl from highscores.

At the momment, all it does is
  • Add to your friendslist anyone who PM's you.
  • If the master PM's 'logout' to you, then you log out.
  • If someone PM's 'hi' to you, then you reply 'hey'.
  • If someone PM's 'Say:' to you, with the words 'Say:' and 'Fin:' in the sentence, you say the words between 'say:' and 'fin:'
  • If someone PM's "What is 'username','level'?" (note , and ? must be said) it replies with that usernames lvl.
  • If someone PM's"What 'username' combat" it replies with that usernames combat lvl.
You can add more things if you know how to script.


This is just an example of how you can use remote control, so feel free to change it, or edit it in anyway just gimme credit. It can also have security, so that it only listens to certain commands from a certain player, whose name is declared by the constant mastername.

{By Nght Spud
Its basically a demonstration of what can be done with remote control.
This script adds anyone that messages you to its friends.
If someone messages the caracter logout, the character should log out
Feel free to copy anything from this script just gimme credit please.
It could be used as anything from a autoreplier, too a command reciever
to change what the script does.
Have fun adding new commands}
program Remotecontrol;
{.include SRL/SRL.scar}
{.include SRL/SRL\Misc\Friends.scar}
var text,fid,tof,username:string;
k,l:integer;
const
mastername='------'; //put mastername here
{
function: CombatCalc(username:String):String;
By: Nght Spud
Description: Finds a users combat level by looking at the
runescape highscores}
function CombatCalc(username:String):String;
var A,B,C,Base,D,E,F,G,MeleeClass,RangeClass,MageClass,M,CMB:Extended;
Attack,Strength,Defence,Mage,Range,Prayer,Hitpoints,k:integer;
Page,t1,t2,t3:String ;
begin

Page:=(GetPage('http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1='+username) );

t1:=(between('Attack','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Attack:=(strtoint(t3)) else Attack:=1

t1:=(between('Strength','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Strength:=(strtoint(t3)) else Strength:=1

t1:=(between('Defence','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Defence:=(strtoint(t3)) else Defence:=1

t1:=(between('Magic','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Mage:=(strtoint(t3)) else Mage:=1

t1:=(between('Range','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Range:=(strtoint(t3)) else Range:=1

t1:=(between('Prayer','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Prayer:=(strtoint(t3)) else Prayer:=1

t1:=(between('Hitpoints','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Hitpoints:=(strtoint(t3)) else Hitpoints:=10
A:= (Defence*100)
B:= (Hitpoints*100)
k:=Prayer+1;
if ((Prayer/2)+0.5=k/2)then C:=((Prayer-1)*50)else C:=Prayer*50;
Base:=((a+b+c)/400)
D:=Attack*130
E:=Strength*130
k:=Range+1;
if ((Range/2)+0.5=k/2)then F:=((Range*195)-65)else F:=Range*195;
k:=Mage+1;
if ((Mage/2)+0.5=k/2)then G:=((Mage*195)-65)else G:=Mage*195;
MeleeClass:=((D+E)/400)
RangeClass:=(F/400)
MageClass:=(G/400)
M:=MaxE(MeleeClass,RangeClass)
M:=MaxE(M,MageClass)
CMB:=M+Base
Result:=(floattostr(CMB))
end;
{
function: ToOrFrom: String;
By: Nght Spud
Description: Finds out if you messaged someone, or they messaged you.
Returns with 'to' or 'from'.}
function ToOrFrom: String;
begin
if (IsTextAtEx(20, 415,'To',0, SmallChars, False,
False, 0, 1, 0))
then result:='to';
if (IsTextAtEx(20, 415,'From',0, SmallChars, False,
False, 0, 1, 0))
then result:='from';
end;
{
function: GetBlackChatName: String;
By: Nght Spud
Description: Gets the name of who your talking to.
Returns with their name}
function GetBlackChatName: String;
var messagefrom:string;
begin
if (IsTextAtEx(20, 415,'To',0, SmallChars, False,
False, 0, 1, 0))
then messagefrom:='to';
if (IsTextAtEx(20, 415,'From',0, SmallChars, False,
False, 0, 1, 0))
then messagefrom:='from';
if (messagefrom='from') then
Result := Trim(GetTextAtEx(50, 415, 0, SmallChars, False,
False, 0, 1, 0, 80, False, tr_AlphaNumericChars));
if (messagefrom='to') then
Result := Trim(GetTextAtEx(35, 415, 0, SmallChars, False,
False, 0, 1, 0, 80, False, tr_AlphaNumericChars));
end;
{
function: IsWordSaid(Text:string):boolean;
By: Nght Spud
Description: Looks across the whole PM for a certain word
works even if there is text before, or after
the word. Returns true if word is found.}
function IsWordSaid(Text:string):boolean;
var x,y:integer;
begin
if (IsTextInAreaEx(20, 415,470, 430,x,y,Text,0,SmallChars, False,
False,0,1,128)=true)then result:=true
else result:=false;
end;
{
function: RcSayCommand(Start,Finish:string):String ;
By: Nght Spud
Description: Looks at what is said, and returns what is
said between the words you declared.
i.e. RcSayCommand('Say:','Fin:')would return
the words between Say: and Fin:}
function RcSayCommand(Start,Finish:string):String ;
var text:string;
begin
Text:=Trim(GetTextAtEx(20, 415, 0, SmallChars, False,
False, 0, 1, 128, 80, False, tr_AllChars));
Result:=Between(Start,Finish, Text);
end;
{
function: GetLvlCommand(Command:string):String ;
By: Nght Spud
Description: Finds a users level by looking at the runescape
highscores}
function GetLvlCommand(Command:string):String ;
var a,b,c,text,Level,Name:string;
begin
Text:=Trim(GetTextAtEx(20, 415, 0, SmallChars, False,False, 0, 1, 128, 80, False, tr_AllChars))
Name:=(between(Command+' ',',',Text));
Writeln(Name)
Level:=(between(',','?',text))
Writeln(Level)
a:=(GetPage('http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1='+Name) )
b:=(between(Level,'</tr>',a))
c:=((between('</td>'+Chr(10)+'<td align="right">','</td>',b)))
Result:=(between(c+'</td>'+Chr(10)+'<td align="right">','</td>',b))
end;
procedure readndwrite;
begin
wait(500);
tof:=ToOrFrom;
fid:= GetBlackChatName;
text:= RCReadCommand;
writeln(tof+' '+fid+' : '+text)
if (tof='from')
then begin
if (not(FriendIsOnline(k,l,fid)))
then AddFriend(fid)
end;
if (IsWordSaid('Logout')// this is where the logout command is recieved
and (fid=mastername)) // how to add security.
then begin
logout;
writeln('got msg logout, logging out');
end;

if IsWordSaid('Hi') // this is where the hi command is recieved
then begin
MessageFriendEx(fid,'Hey') //how it can be used to autorespond
writeln('got msg hi,replied')
end;

if IsWordSaid('Say:') // this is where the Say: command is recieved
then begin
TypeSend(RcSayCommand('Say:','Fin:')) //Says whats in between the two words
writeln('got msg Say,Said it')
end;
if IsWordSaid('What is')
then begin
MessageFriendEx(fid,(GetLvlCommand('What is')));
writeln('got msg What is, told them lvl')
end;
if IsWordSaid('combat')
then begin
Text:=Trim(GetTextAtEx(20, 415, 0, SmallChars, False,False, 0, 1, 128, 80, False, tr_AllChars))
username:=(Trim(between('What ',' combat',text)));
writeln('username is '+username);
MessageFriendEx(fid,(CombatCalc(username)));
writeln('got msg combat, told them lvl')
end;
end;
begin
activateclient;
MouseSpeed:=10
wait(5000);
SetChat('off',1);
SetChat('off',3);
repeat
MouseSpeed:=(10+random(5))
readndwrite;
if(FlagDistance<10)then MouseBox(MMX1, MMY1, MMX2, MMY2, 1);
until (false);
end.

Thank you, and please post what you think of it.

seaking

2007-05-24 23:15:15

Isn't this basically RC… which is already programmed into SRL…

nght spud

2007-05-25 05:34:30

This is remote control, and there is some remote control built into SRL, but there is only a limited number of commands that can be given using the SRL commands. This is basically how to add more commands, and I this doesnt require Bitmaps and things.

1-DUB

2007-05-29 11:33:54

nice

alach11

2007-05-29 11:37:46

Good functions o.O

nght spud

2007-05-29 20:48:25

thanks for comments, I added more functions and commands, its now useful for looking up other users.

Timothegreat

2007-05-30 12:59:51

cool so this is an antiban type thingy nice ;)

nght spud

2007-05-30 16:01:23

It can be anti ban in that it allows bots to basically talk to each other, but it can also be used for changing what a user is doing, or giving a user a command, like my highscore lookup commands

WT-Fakawi

2007-05-30 17:32:37

nght spud: Great stuff. Really nice work, reads like a charm. But, alas the runescape stats page only displays the HighScores. You could also try fillling the Player.Level[21] array with a call to GetAllLevels.

What I have always wanted is a Speak command inside RC. So you can stand next to your autoer and actually have a conversation with it. Usually when RC-ing, I have a strategical spot I place the RC-Master. How do you use RC?

RudeBoiAlex

2007-05-30 18:57:56

should this be in tut island + the script download for an example?

nght spud

2007-05-31 10:14:57

The main reason I made the highscore lookup function was not to lookup your own characters, it was to look up other peoples characters, so instead of someone having to leave rs they just PM the bot a message, and it looks at the highscores for them, I guess it could be used to look at your own players though. I will add a command to fill the Player.Level[21] array sometime thanks for the idea.

Unlike you, I see RC as a way to give commands to bots, for example you could give a command 'start fishing' and the bot will stop what its doing and start fishing (trying to make a script that does this at the moment).

From: rudeboialex
should this be in tut island + the script download for an example?

I hope not, I havent actually explained how to do anything, Ive just given an example, I might make it into a tutorial soon.

RudeBoiAlex

2007-05-31 12:53:27

o lol, my bad soz

The devil

2007-06-01 03:44:40

Not bad.

tim46

2007-06-03 14:25:19

Nice stuff, good job.

BobboHobbo

2007-06-16 03:57:28

Nice its preety useful, and great scripting.

mamoth95

2007-06-19 23:20:10

cool oh and no The devil it was me that made runescape unavalible and ill tell u why…well ill just say this…assasination was involved

crossback7

2007-06-21 23:44:27

Ah dude. . .that's really cool actually. . .lots of potential, I was unaware that anything like your fishing idea could be done.

Lalaji

2007-06-22 11:02:15

That junk looks good to me!@@