PDA

View Full Version : The newbie guide to stats



grats
02-25-2015, 07:12 PM
Hello! Chances are you were linked here from a thread where you got confused on how to setup stats.

Every script is different! This is why we setup stats the way we do, so every script can use your stats and you the user only has to set it up once!
That's right, once!

Lets get started:
What is stats, why do we use it?
Stats is a system to keep track of everything we can think to keep track of.. exp made for everything, per script, per user, totals for example. Or even lobsters caught and cooked.
Here you can see a great example of a script with many variables, remember to click the variable names on the bottom to toggle on/off
http://stats.grats.pw/variable.php?sid=7

and here you can see a great example of a script with many users:
http://stats.grats.pw/script.php?sid=5

as a scripter it's nice to know your script gets used and how much
as a user it's nice to see all the scripts you use and compete for # 1 on a script

But how do I set it up!?!?
Well that's easy, most likely you've already gone here: http://stats.grats.pw/reg.php and registered
From this page we get:
email - what we use to login on the website and (assuming it's an actual email) what we use to recover password. You do not have to use an email for this field, however password recovery will not work if you don't. That's all.
Nickname - This is your public name on the stats website, it's what other people see you as and what you see yourself as in graphs etc.
Password - This is.. your password, used to commit to stats through a simba script AND used to login on the web page.
ID - This is used to commit via scripts, this will be given to you after your first login.

So now to the actual setup part, lets assume you've registered, now lets login! http://stats.grats.pw/login.php
After logging in you will be on the front, homepage. You should see something like this:
http://i.imgur.com/GB0op1W.jpg
This tells you exactly what you need to know
Your ID!
Now some scripts have a nice GUI for you to input your ID and password in, however a lot do not. Lets manually set it up once so every script forever will be able to access your stats info and you won't have to put that in anymore:

Navigate to:
C:\Simba\Stats
In there should be an Info.txt
no? Lets make one, open up notepad!
http://i.imgur.com/bdvgoDP.jpg
It should look like this!


[General]
Stats_ID=YOUR ID #
Stats_Pass=YOUR PASS

You're done!

This info can be found here (https://villavu.com/forum/showthread.php?t=108953&page=9&p=1331243#post1331243) reiterated by Flight; who also made the simba system to commit to stats, thanks Flight!




Post below if you have ANY questions and I will add more instruction.




Here's a speedy video.
This video ASSUMES you have registered (http://stats.grats.pw/reg.php) already.. and logged in.

http://youtu.be/MY9RcWNZ1MM
http://youtu.be/MY9RcWNZ1MM
the video is made to be quick, if you want more info.. read!
there is 1080p on the video so everything is clear and easy to read.

davyraitt
03-31-2015, 07:23 PM
Thanks for this, handy to know.

spaderdabomb
05-20-2015, 07:44 AM
Is there a way to view user stats? I wanted to see how much xp I've gained from botting =D

dutchp0wner
05-20-2015, 04:14 PM
This is great, using it for most of the scripts.

goodgamescript
06-15-2015, 11:53 PM
well this helped alot but for it being a newbie guide it is missing a couple of things that i had to figure out.
1. stats_Setup('id'); add this after setupsrl() id = to the script id.
2. When you get set your variables on the website you use that number as well --> stats_IncVariable('140', NumToAddon)
[140] Potions (Made) is the variable so you use the 140.
3. You have to commit your stats by , stats_Commit();
4. To get this to work in non AeroLib script you add this to your script.

{-----grats' stats!-----}
{
=====
Stats
=====
}

Const
stats_Path = AppPath+'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
stats_Timer : integer;
stats_ID,stats_Pass,
stats_ScriptID : string;
stats_Vars : Array of TStats_Vars;


procedure stats_Setup(_ScriptID : String);
var
id,pass : String;
begin
if (not directoryExists(stats_Path)) then
begin
forceDirectories(stats_Path);
writeINI('General', 'Stats_ID', '', stats_Path+stats_File);
writeINI('General', 'Stats_Pass', '', stats_Path+stats_File);
end;

id := readINI('General', 'Stats_ID', stats_Path+stats_File);
pass := readINI('General', 'Stats_Pass', stats_Path+stats_File);

if id = '' then
begin
case MessageBox('No Stats ID found, would you like to register?','Stats',1) of
1: openWebPage('http://stats.grats.pw/reg.php');
end;
end;

stats_ID := id;
stats_Pass := pass;
stats_ScriptID := _ScriptID;
stats_Timer := getSystemTime();
end

procedure stats_InitVariable(VarName: String; InitValue: Integer);
var
len: Integer;
begin
len := Length(stats_Vars);
SetArrayLength(stats_Vars, len + 1);
stats_Vars[len].Name := LowerCase(VarName);
stats_Vars[len].Value := InitValue;
end;

procedure stats_SetVariable(VarName: string; NewValue: Integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);

if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := NewValue;
Exit;
end;

stats_InitVariable(VarName, NewValue);
end;

procedure stats_IncVariable(VarName: string; Value: integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);

if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := stats_Vars[i].Value + Value;
Exit;
end;

stats_InitVariable(VarName, Value);
end;

function stats_Commit(): Boolean;
var
S : String;
Client,i,Worked,
ExtraTime : integer;
begin
ExtraTime := getSystemTime() - stats_Timer;
Worked := ExtraTime div 60000;

if Worked < 5 then Exit;
ExtraTime := ExtraTime - (Worked*60000);

stats_Timer := GetSystemTime - ExtraTime;

Client := InitializeHTTPClient(False);
ClearPostData(Client);

if (stats_ID = '') then
begin
stats_ID := '5';
stats_Pass := 'anon1337';
end;

AddPostVariable(Client, 'user_id', STATS_ID);
AddPostVariable(Client, 'password', STATS_PASS);
AddPostVariable(Client, 'script_id', STATS_SCRIPTID);
AddPostVariable(Client, 'timeamount', toStr(Worked));

if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;

AddPostVariable(Client, Name, toStr(Min(Value, 30000))); //Capped at 30000
end;

// Get & translate the return code
S := PostHTTPPageEx(Client, 'http://stats.grats.pw/POST.php');
FreeHTTPClient(Client);

case StrToIntDef(ExtractFromStr(S, Numbers), -1) of
42 : Result := True;
// 666 : writeln('Stats: User ID/Password not setup.'); // Disabled because of the default name ID & pass given above
9001: writeln('Stats: Invalid user ID/Password.');
1337: writeln('Stats: Invalid Script ID.');
255,
496 : writeln('Stats: Committing too fast; shame on you!');
else
writeln('Stats: No POST return');
end;

if Result then
begin
if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;
Value := 0; //Clear for next commit
end;
end;
end;
{-----grats' stats-----}



Added all together in a progress report procedure.

procedure Report;
begin
//code that shows in the report.
stats_IncVariable('140', NumToAddon)
stats_Commit();
end;

grats
06-26-2015, 01:26 AM
Is there a way to view user stats? I wanted to see how much xp I've gained from botting =D

Adding it slowly, been busy & was in hospital for a while so who knows lol
http://stats.grats.pw/user.php
you can find your name there, and now/in the future there will be info & more info


well this helped alot but for it being a newbie guide it is missing a couple of things that i had to figure out.
1. stats_Setup('id'); add this after setupsrl() id = to the script id.
2. When you get set your variables on the website you use that number as well --> stats_IncVariable('140', NumToAddon)
[140] Potions (Made) is the variable so you use the 140.
3. You have to commit your stats by , stats_Commit();
4. To get this to work in non AeroLib script you add this to your script.

{-----grats' stats!-----}
{
=====
Stats
=====
}

Const
stats_Path = AppPath+'Stats\';
stats_File = 'Info.txt';

type
TStats_Vars = record
Name: string;
Value: integer;
end;

var
stats_Timer : integer;
stats_ID,stats_Pass,
stats_ScriptID : string;
stats_Vars : Array of TStats_Vars;


procedure stats_Setup(_ScriptID : String);
var
id,pass : String;
begin
if (not directoryExists(stats_Path)) then
begin
forceDirectories(stats_Path);
writeINI('General', 'Stats_ID', '', stats_Path+stats_File);
writeINI('General', 'Stats_Pass', '', stats_Path+stats_File);
end;

id := readINI('General', 'Stats_ID', stats_Path+stats_File);
pass := readINI('General', 'Stats_Pass', stats_Path+stats_File);

if id = '' then
begin
case MessageBox('No Stats ID found, would you like to register?','Stats',1) of
1: openWebPage('http://stats.grats.pw/reg.php');
end;
end;

stats_ID := id;
stats_Pass := pass;
stats_ScriptID := _ScriptID;
stats_Timer := getSystemTime();
end

procedure stats_InitVariable(VarName: String; InitValue: Integer);
var
len: Integer;
begin
len := Length(stats_Vars);
SetArrayLength(stats_Vars, len + 1);
stats_Vars[len].Name := LowerCase(VarName);
stats_Vars[len].Value := InitValue;
end;

procedure stats_SetVariable(VarName: string; NewValue: Integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);

if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := NewValue;
Exit;
end;

stats_InitVariable(VarName, NewValue);
end;

procedure stats_IncVariable(VarName: string; Value: integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName);

if (h >= 0) then
for i := h downto 0 do
if (VarName = stats_Vars[i].Name) then
begin
stats_Vars[i].Value := stats_Vars[i].Value + Value;
Exit;
end;

stats_InitVariable(VarName, Value);
end;

function stats_Commit(): Boolean;
var
S : String;
Client,i,Worked,
ExtraTime : integer;
begin
ExtraTime := getSystemTime() - stats_Timer;
Worked := ExtraTime div 60000;

if Worked < 5 then Exit;
ExtraTime := ExtraTime - (Worked*60000);

stats_Timer := GetSystemTime - ExtraTime;

Client := InitializeHTTPClient(False);
ClearPostData(Client);

if (stats_ID = '') then
begin
stats_ID := '5';
stats_Pass := 'anon1337';
end;

AddPostVariable(Client, 'user_id', STATS_ID);
AddPostVariable(Client, 'password', STATS_PASS);
AddPostVariable(Client, 'script_id', STATS_SCRIPTID);
AddPostVariable(Client, 'timeamount', toStr(Worked));

if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;

AddPostVariable(Client, Name, toStr(Min(Value, 30000))); //Capped at 30000
end;

// Get & translate the return code
S := PostHTTPPageEx(Client, 'http://stats.grats.pw/POST.php');
FreeHTTPClient(Client);

case StrToIntDef(ExtractFromStr(S, Numbers), -1) of
42 : Result := True;
// 666 : writeln('Stats: User ID/Password not setup.'); // Disabled because of the default name ID & pass given above
9001: writeln('Stats: Invalid user ID/Password.');
1337: writeln('Stats: Invalid Script ID.');
255,
496 : writeln('Stats: Committing too fast; shame on you!');
else
writeln('Stats: No POST return');
end;

if Result then
begin
if (Length(stats_Vars) > 0) then
for i := high(stats_Vars) downto 0 do
with stats_Vars[i] do
begin
if (Value <= 0) then
Continue;
Value := 0; //Clear for next commit
end;
end;
end;
{-----grats' stats-----}



Added all together in a progress report procedure.

procedure Report;
begin
//code that shows in the report.
stats_IncVariable('140', NumToAddon)
stats_Commit();
end;


this thread is mostly for just basic users, I think you found the other dev thread by now though :D
I haven't actually used simba in years either so <_<



This is great, using it for most of the scripts.

http://stats.grats.pw/user.php?u=dutchp0wner

can see some of your individual stats now

terd
05-04-2017, 05:54 AM
I signed up for an account with an email and password that I know was consistent, but I never received an email and am unable to login. Is there an issue with account creation or am i just noob?

J0rdeh
06-04-2017, 10:10 PM
Whenever I get around to scripting I'll definitely look into this, thanks!

dotdotdot
06-05-2017, 12:00 PM
Border line grave dig and spam post ..lol