SRL Archive - SRL Member Goodies

How To Register And Use The New SRL Stats


Dynamite

2009-08-19 14:46:41

How To Register And Use The New SRL Stats

3 Sections:
I := Registering Stats and Registering Script
II := Adding the Stats To your script
III := Getting a Stats Signature

NOTE: SRL ID AND SRL PASS ARE DIFFERENT THAN SRL USERNAME AND PASS
Not many scripts at the moment have the new SRL Stats, but I think it is important that you have one.

I

Firstly go to this link: http://scriptmanager.freehostia.com/
You should see this:
Now register:
You will see this:
Fill out your info then click
You will then see:
Click:
Then Login with the account you just made.
Click Profile in the top right:
Write down your User ID (or remember it):
Now you have your User ID and your Password!
To release a script you click:
It will then come up with:
Type in the info of your script.
At the bottom there is:
Type in something like:
Or whatever you want/need.
NOTE: I will be teaching you how to Use these variables in your script later on.
Now click Register.
Done.

Dynamite

2009-08-19 14:59:21

II

Adding The Stats To Your Script

The Code:
const
Stats_Link = 'http://scriptmanager.freehostia.com/submit.php';

var
Stats_UserID, Stats_Password, Stats_ScriptID: string;
Stats_LastTime: Integer;

Stats_CustomVars: array [1..20] of Integer;

procedure Stats_CheckOutput(s: string);
var
i: Integer;
sa: TStringArray;
begin
sa := Explode(#10, s);
for i := 0 to High(sa) do
if (Trim(sa[i]) <> '') then
if StartsWith('ERROR(1)', sa[i]) then
begin
WriteLn('STATS: "' + sa[i] + '"');
Stats_UserID := '';
Stats_Password := '';
end
else if StartsWith('ERROR(2)', sa[i]) then
begin
WriteLn('STATS: "' + sa[i] + '"');
Stats_ScriptID := '';
end
else
WriteLn('STATS: "' + sa[i] + '"');

end;

function Stats_GetScriptInfo(out Version, News, Link: string; out OutDated: Boolean; out LastUpdate_HoursAgo: Integer): Boolean;
var
Client: Integer;
s: string;
sa: TStringArray;
begin
Result := False;
if (Stats_ScriptID = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'getinfo');
AddPostVariable (Client, 'sID', Stats_ScriptID);

s := PostHTTPPageEx(Client, Stats_Link);
sa := Explode(#10'GLUE'#10, s);
if (Length(sa) = 5) then
begin
Result := True;
Version := sa[0];
News := sa[1];
Link := sa[2];
OutDated := sa[3] = '1';
LastUpdate_HoursAgo := StrToIntDef(sa[4], -1);
end
else
Stats_CheckOutput(s);

FreeHTTPClient(Client );
end;

var
Stats_GlobalVars: array[1..24] of Integer;

procedure Stats_SendReport;
var
i, Client, Time: Integer;
s: string;
begin
if (Stats_UserID = '') and (Stats_Password = '') and (Stats_ScriptID = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'submit');

Time := (GetTimeRunning - Stats_LastTime) div 1000 div 60;
if (Time < 5) then
Time := 0
else
Stats_LastTime := GetTimeRunning;
AddPostVariable(Client, 'sTime', IntToStr(Time));

if (Stats_UserID <> '') and (Stats_Password <> '') then
begin
AddPostVariable(Client, 'uID', Stats_UserID);
AddPostVariable(Client, 'uPass', Stats_Password);

for i := Low(Stats_GlobalVars) to High(Stats_GlobalVars) do
begin
case i of
1: s := IntToStr(SRL_Logs - Stats_GlobalVars[i]);
2: s := IntToStr(Banks - Stats_GlobalVars[i]);
3: s := IntToStr(RandSolved[rand_Death] - Stats_GlobalVars[i]);
else if ((i - 3) < Length(RandSolved) - 1 {for Death}) then
s := IntToStr(RandSolved[i - 3] - Stats_GlobalVars[i]);
end;
AddPostVariable(Client, 'rndGlobal' + IntToStr(i), s);
Stats_GlobalVars[i] := Stats_GlobalVars[i] + StrToInt(s);
end;
end
else
begin
AddPostVariable(Client, 'uID', '-1');
AddPostVariable(Client, 'uPass', '');
end;

if (Stats_ScriptID <> '') then
begin
AddPostVariable (Client, 'sID', Stats_ScriptID);

for i := Low(Stats_CustomVars) to High(Stats_CustomVars) do
begin
AddPostVariable(Client, 'rndCustom' + IntToStr(i), IntToStr(Stats_CustomVars[i]));
Stats_CustomVars[i] := 0;
end;
end
else
begin
AddPostVariable (Client, 'sID', '-1');
end;

s := PostHTTPPageEx(Client, Stats_Link);
Stats_CheckOutput(s);
FreeHTTPClient(Client);

if (SRL_Procs[srl_OnSendStats] <> nil) then
SRL_Procs[srl_OnSendStats]();
end;

procedure Stats_SendAccountInfo;
var
i, Client: Integer;
Accounts: TStringArray;
begin
if (Stats_UserID = '') and (Stats_Password = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'setaccounts');
AddPostVariable(Client, 'uID', Stats_UserID);
AddPostVariable(Client, 'uPass', Stats_Password);
if (Stats_ScriptID <> '') then
AddPostVariable (Client, 'sID', Stats_ScriptID)
else
AddPostVariable (Client, 'sID', '-1');

SetLength(Accounts, HowManyPlayers);
for i := 0 to HowManyPlayers - 1 do
Accounts[i] := Implode('.|€stat€|.', [Players[i].Name, Players[i].Loc, IntToStr(Integer(Players[i].Active))]);

AddPostVariable(Client, 'accInfo', Implode(#10'ACC'#10, Accounts));
Stats_CheckOutput(PostHTTPPageEx(Client, Stats_Link));
FreeHTTPClient(Client);
end;

procedure Stats_ManageAccounts;
var
i, ii, Client: Integer;
s: string;
Accounts, Stats: TStringArray;
begin
if (Stats_UserID = '') and (Stats_Password = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'getaccounts');
AddPostVariable(Client, 'uID', Stats_UserID);
AddPostVariable(Client, 'uPass', Stats_Password);

s := PostHTTPPageEx(Client, Stats_Link);
Accounts := Explode(#10'ACC'#10, s);
for i := 0 to High(Accounts) do
begin
Stats := Explode('.|€stat€|.', Accounts[i]);
if (Length(Stats) = 3) then
begin
for ii := 0 to HowManyPlayers - 1 do
if (LowerCase(Players[ii].Name) = LowerCase(Stats[0])) then
begin
Players[ii].Loc := Stats[1];
Players[ii].Active := Stats[2] = '1';
Break;
end;
end
else
begin
Stats_CheckOutput(s);
Break;
end;
end;

FreeHTTPClient(Client);
stats_SendAccountInfo;
end;
How it might look in a script:
  //*** STATS ***//

const

Stats_Link = 'http://scriptmanager.freehostia.com/submit.php';

var
Stats_UserID, Stats_Password, Stats_ScriptID: string;
Stats_LastTime: Integer;

Stats_CustomVars: array [1..10] of Integer;

//*** STATS ***//

Procedure DeclarePlayers;
begin
HowManyPlayers := 1
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Stats_UserID := ''; // Your ID on Nielsies Stats if you dont have leave
Stats_Password := ''; // Your Pass on Nielsies Stats if you dont have leave

with Players[0] do
begin
Name :='';
Pass :='';
Nick :='';
Strings[0] := 'willow'; // Tree you want to cut
Integers[2] := 15000; //Max Time per log
Loc := 'draynorwillow'; // Location, Look at top for locations.
Active := True;
end;
end;

//*** STATS ***//

procedure Stats_CheckOutput(s: string);
var
i: Integer;
sa: TStringArray;
begin
sa := Explode(#10, s);
for i := 0 to High(sa) do
if (Trim(sa[i]) <> '') then
if StartsWith('ERROR(1)', sa[i]) then
begin
WriteLn('STATS: "' + sa[i] + '"');
Stats_UserID := '';
Stats_Password := '';
end
else if StartsWith('ERROR(2)', sa[i]) then
begin
WriteLn('STATS: "' + sa[i] + '"');
Stats_ScriptID := '';
end
else
WriteLn('STATS: "' + sa[i] + '"');

end;

function Stats_GetScriptInfo(out Version, News, Link: string; out OutDated: Boolean; out LastUpdate_HoursAgo: Integer): Boolean;
var
Client: Integer;
s: string;
sa: TStringArray;
begin
Result := False;
if (Stats_ScriptID = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'getinfo');
AddPostVariable (Client, 'sID', Stats_ScriptID);

s := PostHTTPPageEx(Client, Stats_Link);
sa := Explode(#10'GLUE'#10, s);
if (Length(sa) = 5) then
begin
Result := True;
Version := sa[0];
News := sa[1];
Link := sa[2];
OutDated := sa[3] = '1';
LastUpdate_HoursAgo := StrToIntDef(sa[4], -1);
end
else
Stats_CheckOutput(s);

FreeHTTPClient(Client );
end;

var
Stats_GlobalVars: array[1..24] of Integer;

procedure Stats_SendReport;
var
i, Client, Time: Integer;
s: string;
begin
if (Stats_UserID = '') and (Stats_Password = '') and (Stats_ScriptID = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'submit');

Time := (GetTimeRunning - Stats_LastTime) div 1000 div 60;
if (Time < 5) then
Time := 0
else
Stats_LastTime := GetTimeRunning;
AddPostVariable(Client, 'sTime', IntToStr(Time));

if (Stats_UserID <> '') and (Stats_Password <> '') then
begin
AddPostVariable(Client, 'uID', Stats_UserID);
AddPostVariable(Client, 'uPass', Stats_Password);

for i := Low(Stats_GlobalVars) to High(Stats_GlobalVars) do
begin
case i of
1: s := IntToStr(SRL_Logs - Stats_GlobalVars[i]);
2: s := IntToStr(Banks - Stats_GlobalVars[i]);
3: s := IntToStr(RandSolved[rand_Death] - Stats_GlobalVars[i]);
else if ((i - 3) < Length(RandSolved) - 1 {for Death}) then
s := IntToStr(RandSolved[i - 3] - Stats_GlobalVars[i]);
end;
AddPostVariable(Client, 'rndGlobal' + IntToStr(i), s);
Stats_GlobalVars[i] := Stats_GlobalVars[i] + StrToInt(s);
end;
end
else
begin
AddPostVariable(Client, 'uID', '-1');
AddPostVariable(Client, 'uPass', '');
end;

if (Stats_ScriptID <> '') then
begin
AddPostVariable (Client, 'sID', Stats_ScriptID);

for i := Low(Stats_CustomVars) to High(Stats_CustomVars) do
begin
AddPostVariable(Client, 'rndCustom' + IntToStr(i), IntToStr(Stats_CustomVars[i]));
Stats_CustomVars[i] := 0;
end;
end
else
begin
AddPostVariable (Client, 'sID', '-1');
end;

s := PostHTTPPageEx(Client, Stats_Link);
Stats_CheckOutput(s);
FreeHTTPClient(Client);

if (SRL_Procs[srl_OnSendStats] <> nil) then
SRL_Procs[srl_OnSendStats]();
end;

procedure Stats_SendAccountInfo;
var
i, Client: Integer;
Accounts: TStringArray;
begin
if (Stats_UserID = '') and (Stats_Password = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'setaccounts');
AddPostVariable(Client, 'uID', Stats_UserID);
AddPostVariable(Client, 'uPass', Stats_Password);
if (Stats_ScriptID <> '') then
AddPostVariable (Client, 'sID', Stats_ScriptID)
else
AddPostVariable (Client, 'sID', '-1');

SetLength(Accounts, HowManyPlayers);
for i := 0 to HowManyPlayers - 1 do
Accounts[i] := Implode('.|€stat€|.', [Players[i].Name, Players[i].Loc, IntToStr(Integer(Players[i].Active))]);

AddPostVariable(Client, 'accInfo', Implode(#10'ACC'#10, Accounts));
Stats_CheckOutput(PostHTTPPageEx(Client, Stats_Link));
FreeHTTPClient(Client);
end;

procedure Stats_ManageAccounts;
var
i, ii, Client: Integer;
s: string;
Accounts, Stats: TStringArray;
begin
if (Stats_UserID = '') and (Stats_Password = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'getaccounts');
AddPostVariable(Client, 'uID', Stats_UserID);
AddPostVariable(Client, 'uPass', Stats_Password);

s := PostHTTPPageEx(Client, Stats_Link);
Accounts := Explode(#10'ACC'#10, s);
for i := 0 to High(Accounts) do
begin
Stats := Explode('.|€stat€|.', Accounts[i]);
if (Length(Stats) = 3) then
begin
for ii := 0 to HowManyPlayers - 1 do
if (LowerCase(Players[ii].Name) = LowerCase(Stats[0])) then
begin
Players[ii].Loc := Stats[1];
Players[ii].Active := Stats[2] = '1';
Break;
end;
end
else
begin
Stats_CheckOutput(s);
Break;
end;
end;
FreeHTTPClient(Client);
stats_SendAccountInfo;
end;
//*** STATS ***//

procedure SwitchWorlds;
begin
if CountDots('white') > TooManyPlayers then
begin
Inc(Stats_CustomVars[7]);
ChooseWorldBy(['players'], [True], SmartMembers, False);
end;
end;

To add a Custom Variable You will do something like:
Inc(Stats_CustomVars[1]);
That will add 1 to the Variable 1 to your scripts progress on the website.
I have done:
procedure SwitchWorlds;
begin
if CountDots('white') > TooManyPlayers then
begin
Inc(Stats_CustomVars[7]);
ChooseWorldBy(['players'], [True], SmartMembers, False);
end;
end;
So everytime I call my SwitchWorlds procedure and it switches world It will add to the Custom Variable 7.
If you have any questions on this part please ask :)

Now to actually get your script to send the info to the website you will want to call Stats_SendReport and Stats_ManageAccounts about every 15 minutes.
I have put mine so that everytime my progress report comes up (after the script does 1 load) it sends the info:
Procedure Proggy;
var
i, loads: integer;
s: string;
XPGained, tmp: Extended;
begin
for i:= 0 to HowManyPlayers-1 do
begin
if i = CurrentPlayer then
ExpGained;
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked + TimeFromMark(RestTime);
IncEx(loads, Players[i].Banked);
tmp := Players[CurrentPlayer].Integers[0]*XpGain[g];
Players[CurrentPlayer].Extendeds[0] := tmp;
XPGained := XPGained + tmp;
end;

ClearReport;
SRLProgressReport(
ResultDebugBox, 'ProWoodcutter', 'The Man', Version,
['Time running', 'Loads', 'EXP Gained'],
[TimeRunning, loads, XPGained]
);
s := SRLProgressReport(
ResultString, 'ProWoodcutter', 'The Man', Version,
['Time running', 'Loads', 'EXP Gained'],
[TimeRunning, loads, XPGained]
);

SRLPlayerReport(
ResultDebugBox, 0, false,
[true, true, false, false, false, true],
['logs', 'Tree', 'EXP Gained'],
[], [0], [0], [0]
);
s := s + char(#13) + SRLPlayerReport(
ResultString, 0, false,
[true, true, false, false, false, true],
['logs', 'Tree', 'EXP Gained'],
[], [0], [0], [0]
);

i := ReWriteFile(ScriptPath + ScriptName + '.txt', False);
WriteFileString(i, s);
CloseFile(i);
writeln('Progress report saved to: ' + ScriptPath + ScriptName + '.txt');
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked - TimeFromMark(RestTime) + 5;
Stats_SendReport;
Stats_ManageAccounts;
end;
You see the last 2 lines?
That is what sends the info.

III

Getting A Signature!
Now I know this is the bit that everyone wants so this is how you do it:
NOTE: You need your user id
In your Browsers navbar simply type:
http://scriptmanager.freehostia.com/signature/signature.php?uid=YourUserID
Oviously replacing YourUserID with… well hmmm Your User ID ;)

Hope this guide helps lots :)
Please comment :)

T~M


ShowerThoughts

2009-08-19 16:00:42

What's up with the fonts I am getting mad.
Nielsie did explain it already?

EvilChicken!

2009-08-19 17:04:06

Nice tutorial, good job making this! :)
Though, I have to agree with Hermen (although he might've worded himself a tab better :p), your font could've been smaller and less colorful – it would make the tutorial seem more organized and structured.

Should be stickied, in my opinion.

Dynamite

2009-08-19 17:14:16

Sure :)
And thank you for the Sticky Opinion :)
Changed the font and color.
Is it ok?

T~M

EvilChicken!

2009-08-19 17:31:54

Much better!

Furthermore, you use very large-sized images, and you use almost the same images twice a couple times. Maybe crop them to only include the relevant parts?
Plus, use ImageShack as your file host, or some other website that doesn't add not-so-great-looking "Hosted by […]" to your images.

But, good job picking a new font, I like Courier New very much. :D

Dynamite

2009-08-19 17:45:14

I made images smaller.
I have the little watermark on there because it is a piece of software that I use that makes it easy to Screenie>choose what you want>and it uploads for you.
in like 5 seconds.
(Idea for tut :D)

T~M

Naum

2009-08-19 18:30:19

Nice tutorial, anyway, use www.tinypic.com for your pictures as I'm sure Swift will agree ;)

Wizzup?

2009-08-19 18:50:30

From: EvilChicken!
Nice tutorial, good job making this! :)
Though, I have to agree with Hermen (although he might've worded himself a tab better :p), your font could've been smaller and less colorful – it would make the tutorial seem more organized and structured.

Should be stickied, in my opinion.


These stats are only temporarily.

Dynamite

2009-08-19 18:58:04

From: NaumanAkhlaQ
Nice tutorial, anyway, use www.tinypic.com for your pictures as I'm sure Swift will agree ;)


http://www.villavu.com/forum/showthread.php?t=49040
;)

Wizzup? is right though.
This is for the temp stats, but then again.
These stats will probably be around for quite a while?

T~M

Naum

2009-08-20 01:24:18

From: The Man
http://www.villavu.com/forum/showthread.php?t=49040
;)

Wizzup? is right though.
This is for the temp stats, but then again.
These stats will probably be around for quite a while?

T~M


Trust me, your tutorial should use TinyPic, has no annoying watermark as well…