Pyro
01-10-2009, 12:40 AM
NextPlayer(false)
I wrote a similar tutorial about a year ago. And since im bored today i thought i would write it out again maybe a bit more clear this time. So here goes.
This Tut is all about how to use nextplayer appropriately. More so as a failsafe and more ss using nextplayer(false) then nextplayer(true). So on we go. ...
Logging out
In this first chapter i will tell you the basics of the logout type failsafe. Im sure most of you would know it but ill go into it anyway.
In the early days of RS scripting when we didnt have multiplayer'd scripts. We would just use the command terminatescript; and it would end everything till we woke up the next morning. However nowadays we want the script to continue on.
For this to happen what we now do is just logout, and let the script continue on. Such as if we cant find any rocks or if while walking we get lost then we want to logout, not terminate everything. As an example :
Procedure walk2rocks;
begin
if(findrocksymbol)then
begin
mouseclick
.....
flag;
end else
begin
logout;
exit;
end
end;
As you can see from the above example, If we cant find the rock symbol. Then we want to logout of our character. And then ofcourse we want to exit the procedure. We want to exit because obviously we dont want the script continuing on through that procedure as we have already been screwed up and logged out. We dont want it looking for things on the login screen.
Which brings me to my next point...
if(not(loggedin))then exit
The above is a simple command. And yet in EVERY script you will see by a developer or by any good scripter will have it in abundance. Ill show you an example then explain.
Procedure walk2rocks;
begin
if(findrocksymbol)then
begin
mouseclick
.....
flag;
end else
begin
logout;
exit;
end
end;
procedure clickrocks;
begin
if(not(loggedin)) then exit
...
clickrocks etc
...
end;
begin // Our main loop
walk2rocks;
clickrocks;
end;
So basically from the above example you can see we added an extra procedure called clickrocks. And also added our main loop with it walking to the rocks first. Then the procedure to click them.
Now if say when we were walking to the rocks, it couldnt find the rock symbol and it logged out as we had scripted in out last chapter. It then exits that procedure and goes to the next one in the main loop. That is click rocks. NOW! The most important part, we are now logged out, but the main loop WILL continue. So it enters clickrocks. Now the first thing it checks is if it is logged in. Since we are currently logged out it will then EXIT this procedure.
This is the most important part. We are logged out. So we dont want it looking for rocks on the login screen. More so we dont want it doing ANYTHING on the login screen. So any procedures to follow in the main loop should have the "if(not(loggedin))then exit"
Even if you are not logging out as a failsafe (Which you should be but..) incase RS lags, or for whatever reason you get logged out. You dont want your script going batshit crazy on the login screen.
Nextplayer(false)
Next if we are logged out. We want to move on right?
Procedure walk2rocks;
begin
if(findrocksymbol)then
begin
mouseclick
.....
flag;
end else
begin
logout;
exit;
end
end;
procedure clickrocks;
begin
if(not(loggedin)) then exit
...
clickrocks etc
...
end;
begin // Our main loop
walk2rocks;
clickrocks;
if(not(loggedin)) then
begin
nextplayer(false)
resetcounters etc...
end;
end;
As you can see from the above example. I have added a piece of code to the end of the main loop. This means that if it gets to the end of the loop, and you are logged out for whatever reason. If will then move onto the next player and begin again.
The end
To me the above is the most important part of scripting. To make sure if something does go wrong you handle it efficiently and move on.
Basically all we want is
if we get into trouble then we log out
at the start of all procedures to put "if(not(loggedin))then exit" so that our script does not continue on the login screen
We go nextplayer(false) at the end of the loop to start over
Ill prob rewrite this later. But any questions then fire away
I wrote a similar tutorial about a year ago. And since im bored today i thought i would write it out again maybe a bit more clear this time. So here goes.
This Tut is all about how to use nextplayer appropriately. More so as a failsafe and more ss using nextplayer(false) then nextplayer(true). So on we go. ...
Logging out
In this first chapter i will tell you the basics of the logout type failsafe. Im sure most of you would know it but ill go into it anyway.
In the early days of RS scripting when we didnt have multiplayer'd scripts. We would just use the command terminatescript; and it would end everything till we woke up the next morning. However nowadays we want the script to continue on.
For this to happen what we now do is just logout, and let the script continue on. Such as if we cant find any rocks or if while walking we get lost then we want to logout, not terminate everything. As an example :
Procedure walk2rocks;
begin
if(findrocksymbol)then
begin
mouseclick
.....
flag;
end else
begin
logout;
exit;
end
end;
As you can see from the above example, If we cant find the rock symbol. Then we want to logout of our character. And then ofcourse we want to exit the procedure. We want to exit because obviously we dont want the script continuing on through that procedure as we have already been screwed up and logged out. We dont want it looking for things on the login screen.
Which brings me to my next point...
if(not(loggedin))then exit
The above is a simple command. And yet in EVERY script you will see by a developer or by any good scripter will have it in abundance. Ill show you an example then explain.
Procedure walk2rocks;
begin
if(findrocksymbol)then
begin
mouseclick
.....
flag;
end else
begin
logout;
exit;
end
end;
procedure clickrocks;
begin
if(not(loggedin)) then exit
...
clickrocks etc
...
end;
begin // Our main loop
walk2rocks;
clickrocks;
end;
So basically from the above example you can see we added an extra procedure called clickrocks. And also added our main loop with it walking to the rocks first. Then the procedure to click them.
Now if say when we were walking to the rocks, it couldnt find the rock symbol and it logged out as we had scripted in out last chapter. It then exits that procedure and goes to the next one in the main loop. That is click rocks. NOW! The most important part, we are now logged out, but the main loop WILL continue. So it enters clickrocks. Now the first thing it checks is if it is logged in. Since we are currently logged out it will then EXIT this procedure.
This is the most important part. We are logged out. So we dont want it looking for rocks on the login screen. More so we dont want it doing ANYTHING on the login screen. So any procedures to follow in the main loop should have the "if(not(loggedin))then exit"
Even if you are not logging out as a failsafe (Which you should be but..) incase RS lags, or for whatever reason you get logged out. You dont want your script going batshit crazy on the login screen.
Nextplayer(false)
Next if we are logged out. We want to move on right?
Procedure walk2rocks;
begin
if(findrocksymbol)then
begin
mouseclick
.....
flag;
end else
begin
logout;
exit;
end
end;
procedure clickrocks;
begin
if(not(loggedin)) then exit
...
clickrocks etc
...
end;
begin // Our main loop
walk2rocks;
clickrocks;
if(not(loggedin)) then
begin
nextplayer(false)
resetcounters etc...
end;
end;
As you can see from the above example. I have added a piece of code to the end of the main loop. This means that if it gets to the end of the loop, and you are logged out for whatever reason. If will then move onto the next player and begin again.
The end
To me the above is the most important part of scripting. To make sure if something does go wrong you handle it efficiently and move on.
Basically all we want is
if we get into trouble then we log out
at the start of all procedures to put "if(not(loggedin))then exit" so that our script does not continue on the login screen
We go nextplayer(false) at the end of the loop to start over
Ill prob rewrite this later. But any questions then fire away