SRL Archive - Development

Include to commit to SRL Stats


Wizzup?

2010-11-20 10:42:19

So I'm done adding an API to SRL-Stats that allows external sources (eg: Simba+SRL) to commit data.

But the actual Simba+SRL part needs to be written. I assume parts of the old SRL-Stats code can be used.

The URL to send POST data to is:
http://old.villavu.com/stats/api/commit

I made a quick specification:

http://git.villavu.com/?p=srlstats-new.git;a=blob_plain;f=stats_api.txt;hb=HEAD


On the SRL side I suppose it should be easy for the scripter to add send variables. Variables are identified by names. Eg, 'Coal'.

Perhaps something like this?
Init:

stats_SetScriptID(42);
stats_SetUserID(1337); // or perhaps user name
stats_SetPass('God');

On Commit:

stats_NewCommit(); // clear variables
stats_AddVariable('Coal', 26);
stats_AddVariable('Gem', 2);
stats_SetTimeAdded(10); // minutes
if stats_Commit() then
writeln('Commit success!');

If you're interested in writing this, reply here. If there are problems I'm here and on IRC for help.
Otherwise it'll be created (by me I suppose) in some time but I can't guarantee that will be today or tomorrow.

Shuttleu

2010-11-20 11:00:29

im very interested and would be glad to help

i will get started on it soon, but for now, i have a couple of irl jobs to do

~shut

Wizzup?

2010-11-20 11:23:38

How soon will that be? I wanted to have it ready for use this weekend. :p

Cstrike

2010-11-20 13:56:59

I don't know how stats works, will it require someone to go to the end of the entire script and then send data?
Or can the script call something like

stats_AddVariable('coal', 26)

every time the player banks?

Shuttleu

2010-11-20 14:02:01

i can start now :D

~shut

EDIT: could we net have it so everything is sent as strings, then the necessary stiff can be converted to ints when they get there?

Wizzup?

2010-11-20 14:40:26

From: Shuttleu
i can start now :D

~shut

EDIT: could we net have it so everything is sent as strings, then the necessary stiff can be converted to ints when they get there?


All POST data is a string. The server converts them to integers where possible. (if not possible it will raise 150

E: Also! I have a working version in Python. If you come to IRC I'll give you some details as to the password for the user.

From: cstrike
I don't know how stats works, will it require someone to go to the end of the entire script and then send data?
Or can the script call something like

stats_AddVariable('coal', 26)

every time the player banks?


Yes.

Wizzup?

2010-11-20 14:48:04

Shuttle, I understand Narcle is also trying his hand at this; if you come to IRC we can communicate in an easy way. :)

Shuttleu

2010-11-20 14:56:33

sure
on my way

~shut

Narcle

2010-11-20 15:19:25

This is what I'm thinking of:
type
TStats_Vars = record
Name: string;
Value: integer;
end;
var
stats_Vars: Array of TStats_Vars;
stats_UserName, stats_UserPass, stats_ScriptID: String;
stats_Timer: integer;

Procedure SetupSRLStats(ScriptID: integer; UserName, UserPass: string);
begin
stats_Timer := GetSystemTime;
stats_ScriptID := IntToStr(ScriptID);
stats_Username := UserName;
stats_UserPass := UserPass;
end;

Procedure stats_AddVariable(VarName: string; Value: integer);
var
i: Integer;
begin
If (Length(stats_Vars) > 0) then
for i := 0 to High(stats_Vars) do
if VarName = stats_Vars[i].Name then
begin
IncEx(stats_Vars[i].Value, Value);
Exit;
end;

SetArrayLength(stats_Vars, Length(stats_Vars) + 1);
stats_Vars[High(stats_Vars)].Name := VarName;
stats_Vars[High(stats_Vars)].Value := Value;
end;

Procedure stats_Commit;
var
SRLClient, Worked, i: integer;
S: String;
begin
Worked := (GetSystemTime - stats_Timer) / 60000;
if Worked < 2 then
Exit;

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

AddPostVariable(SRLClient, 'user', stats_UserName);
AddPostVariable(SRLClient, 'password', stats_UserPass);
AddPostVariable(SRLClient, 'script', stats_ScriptID);
AddPostVariable(SRLClient, 'time', IntToStr(Worked));

If (Length(stats_Vars) > 0) then
For i := 0 to High(stats_Vars) do
with stats_Vars[i] do
begin
AddPostVariable(SRLClient, Name, IntToStr(Value));
Value := 0;//Clear for next commit
end;

S := PostHTTPPageEx(SRLClient, 'http://old.villavu.com/stats/api/commit');
FreeHTTPClient(SRLClient);
Case ExtractFromStr(S, Numbers) of
'100': Writeln('SRL_Stats: Success');
'110': Writeln('SRL_Stats: Incorrect user and/or password');
'120': Writeln('SRL_Stats: Incorrect script ID');
'130': Writeln('SRL_Stats: Invalid time');
'140': Writeln('SRL_Stats: Variable does not exist');
'150': Writeln('SRL_Stats: Wrong info for variable');
'160': Writeln('SRL_Stats: Internal server error');
else
Writeln('SRL_Stats: No POST return');
end;
stats_Timer := GetSystemTime;
end;

e: changed stats_Password to stats_UserPass
e2: added more stuffs

TomTuff

2010-11-20 15:21:27

I just have one request - please don't make it require as much code as nielsie95's stats. an extra three or four hundred lines just bloats a script :(

Narcle

2010-11-20 15:25:59

From: TomTuff
I just have one request - please don't make it require as much code as nielsie95's stats. an extra three or four hundred lines just bloats a script :(


It'll be in SRL include.

Shuttleu

2010-11-20 18:30:16

my version
const
Stats_Link = 'http://old.villavu.com/stats/api/commit';

type TVar = record
Name: string;
Value: Integer;
end;

var
Stats_Values: array of TVar;
Stats_User, Stats_Pass, Stats_ID: string;
Stats_Time: Integer;
Stats_RandomCount: array [0..23] of Integer;
Stats_RandomName: array of string;

procedure SetupSRLStats(Username, Password: string; ScriptID: Integer);
begin
Stats_User:= Username;
Stats_Pass:= Password;
Stats_ID:= IntToStr(ScriptID);
Stats_Time:= GetSystemTime;
Stats_RandomName:= ['leo the gravedigger', 'freaky forester', 'maze', 'prison pete',
'evil bob...s island', 'drill demon', 'quiz', 'surprise exam',
'mollys evil twin', 'pinball', 'sandwich lady', 'bee keeper',
'pillory', 'capn arnav', 'abyssal teleport', 'certer', 'mime',
'frog', 'trade', 'mod', 'fight', 'lamp', 'bird nest', 'death'];
end;

procedure StatsIncVar(Name: string; Value: Integer);
var
i: Integer;
Exists: Boolean;
begin
for i:=0 to High(Stats_Values) do
if (Stats_Values[i].Name = Name) then
begin
Exists:= True;
break;
end;
if not Exists then
begin
SetArrayLength(Stats_Values, Length(Stats_Values)+1);
i:= High(Stats_Values);
Stats_Values[i].Name:= Name;
end;
IncEx(Stats_Values[i].Value, Value);
end;

procedure StatsCommit;
var
Client, i: Integer;
Returned: string;
NewTime, H, M, S: Integer;
begin
Client:= InitializeHTTPClient(False, False);
if (Stats_Time = 0) then
begin
Writeln('You must call StatsIncVar(Name: string; Value: Integer) before you can use the stats');
Exit;
end;
NewTime:= GetSystemTime;
Writeln(NewTime-Stats_Time);
ConvertTime(NewTime-Stats_Time, H, M, S);
if ((H<1) and (M<1)) then Exit;
Stats_Time:= (GetSystemTime-((NewTime-Stats_Time)-((H*60*60*1000)+(M*60*1000))));
for i:=0 to 23 do
if (RandSolved[i]>Stats_RandomCount[i]) then
begin
AddPostVariable(Client, Stats_RandomName[i], IntToStr(RandSolved[i]-Stats_RandomCount[i]));
Stats_RandomCount[i]:= RandSolved[i];
end;
AddPostVariable(Client, 'time', IntToStr((H*60)+M));
AddPostVariable(Client, 'user', Stats_User);
AddPostVariable(Client, 'password', Stats_Pass);
AddPostVariable(Client, 'script', Stats_ID);
for i:=0 to High(Stats_Values) do
AddPostVariable(Client, Stats_Values[i].Name, IntToStr(Stats_Values[i].Value));
Returned:= PostHTTPPageEx(Client, Stats_Link);
FreeHTTPClient(Client);
Case Returned of
'100': Writeln('SRL_Stats: Success');
'110': Writeln('SRL_Stats: Incorrect user and/or password');
'120': Writeln('SRL_Stats: Incorrect script ID');
'130': Writeln('SRL_Stats: Invalid time');
'140': Writeln('SRL_Stats: Variable does not exist');
'150': Writeln('SRL_Stats: Wrong info for variable');
'160': Writeln('SRL_Stats: Internal server error');
else
Writeln('SRL_Stats: No POST return');
end;
SetArrayLength(Stats_Values, 0);
end;

depending on which version gets used will depend on what you have to use, but the basic principle will be the same

if mine is used then you use it like so
  SetupSRLStats('user', 'pass', 5); //needed, sets up the stats

StatsIncVar('yew', 10); //adds 10 to the var yew
StatsIncVar('flax', 28); //adds 28 to the var flax
StatsIncVar('breaks', 1); //adds 1 to the var breaks

StatsCommit; //sends the stats to the server

~shut

Narcle

2010-11-20 18:41:16

Similar to Shuttleu (as we worked together)

type
TStats_Vars = record
Name: string;
Value: integer;
end;
var
stats_Vars: Array of TStats_Vars;
stats_UserName, stats_UserPass, stats_ScriptID: String;
stats_Timer: integer;
stats_RandNames: Array of String;
stats_RandSolved: Array of Integer;

Procedure SetupSRLStats(ScriptID: integer; UserName, UserPass: string);
begin
stats_Timer := GetSystemTime;
stats_ScriptID := IntToStr(ScriptID);
stats_Username := LowerCase(UserName);
stats_UserPass := LowerCase(UserPass);
stats_RandNames := ['leo the gravedigger', 'freaky forester', 'maze', 'prison pete',
'evil bob''s island', 'drill demon', 'quiz', 'surprise exam',
'mollys evil twin', 'pinball', 'sandwich lady', 'bee keeper',
'pillory', 'capn arnav', 'abyssal teleport', 'certer', 'mime',
'frog', 'trade', 'mod', 'fight', 'lamp', 'bird nest', 'death'];
SetArrayLength(stats_RandSolved, Length(stats_RandNames));
end;

Procedure stats_AddVariable(VarName: string; Value: integer);
var
i: Integer;
begin
if (Length(stats_Vars) > 0) then
for i := 0 to High(stats_Vars) do
if (LowerCase(VarName) = stats_Vars[i].Name) then
begin
IncEx(stats_Vars[i].Value, Value);
Exit;
end;

SetArrayLength(stats_Vars, Length(stats_Vars) + 1);
stats_Vars[High(stats_Vars)].Name := LowerCase(VarName);
stats_Vars[High(stats_Vars)].Value := Value;
end;

Procedure stats_Commit;
var
SRLClient, Worked, i, ExtraTime: integer;
S: String;
begin
ExtraTime := GetSystemTime - stats_Timer;
Worked := ExtraTime / 60000;
ExtraTime := ExtraTime - (Worked*60000);
if Worked < 1 then
Exit;
stats_Timer := GetSystemTime - ExtraTime;
SRLClient := InitializeHTTPClient(False, False);
ClearPostData(SRLClient);

AddPostVariable(SRLClient, 'user', stats_UserName);
AddPostVariable(SRLClient, 'password', stats_UserPass);
AddPostVariable(SRLClient, 'script', stats_ScriptID);
AddPostVariable(SRLClient, 'time', IntToStr(Worked));

for i := 0 to 23 do
if (RandSolved[i] > stats_RandSolved[i]) then
begin
AddPostVariable(SRLClient, stats_RandNames[i], IntToStr(RandSolved[i]-stats_RandSolved[i]));
stats_RandSolved[i]:= RandSolved[i];
end;

if (Length(stats_Vars) > 0) then
for i := 0 to High(stats_Vars) do
with stats_Vars[i] do
begin
AddPostVariable(SRLClient, Name, IntToStr(Value));
Value := 0;//Clear for next commit
end;

S := PostHTTPPageEx(SRLClient, 'http://old.villavu.com/stats/api/commit');
FreeHTTPClient(SRLClient);
Case ExtractFromStr(S, Numbers) of
'100': Writeln('SRL_Stats: Success');
'110': Writeln('SRL_Stats: Incorrect user and/or password');
'120': Writeln('SRL_Stats: Incorrect script ID');
'130': Writeln('SRL_Stats: Invalid time');
'140': Writeln('SRL_Stats: Variable does not exist');
'150': Writeln('SRL_Stats: Wrong info for variable');
'160': Writeln('SRL_Stats: Internal server error');
else
Writeln('SRL_Stats: No POST return');
end;
end;

Shuttleu

2010-11-20 18:48:36

From: Narcle
Similar to Shuttleu (as we worked together)


he says that, but we sort of stole a couple of each others ideas :p

i nicked his ideas
he nicked my code XD
(i dont mean to make that sound against you or anything Narcle)

~shut

Narcle

2010-11-20 18:51:34

From: Shuttleu
he says that, but we sort of stole a couple of each others ideas :p

i nicked his ideas
he nicked my code XD
(i dont mean to make that sound against you or anything Narcle)

~shut


nope its what we did rofl

Nava2

2010-11-21 00:41:03

What about stats global vars? Or is that handled on the server side (too lazy tobread the code right now…).

Shuttleu

2010-11-21 05:06:26

when you say 'global vars' i assume your talking about randoms
if you are, then we already have them

~shut

Nava2

2010-11-21 11:07:51

From: Shuttleu
when you say 'global vars' i assume your talking about randoms
if you are, then we already have them

~shut


No, stats has inbuilt global variables for things like ``iron'' and ``coal''. So I'm not sure if its up to the scripter to update these fields or if on commit the stats system will do it.

Wizzup?

2010-11-21 11:13:40

From: Nava2
No, stats has inbuilt global variables for things like ``iron'' and ``coal''. So I'm not sure if its up to the scripter to update these fields or if on commit the stats system will do it.


You're [completely] wrong. They have a full implementation of the stats system. All variables are strings and optionally sent. If you read even the slightest part of the API description I wrote in the first post you'd have known. All variables obviously have to be updated on Bank or similar by the scripter. The stats part can't magically know how much coal has been mined.

Nava2

2010-11-21 13:47:00

From: Wizzup?
You're [completely] wrong. They have a full implementation of the stats system. All variables are strings and optionally sent. If you read even the slightest part of the API description I wrote in the first post you'd have known. All variables obviously have to be updated on Bank or similar by the scripter. The stats part can't magically know how much coal has been mined.


No no! You missed my point!

What I was talking about was the ``Look how much coal SRL has mined!'' Those stats, of course you have to update the stats yourself. It would be silly to have something else do it. :p

Narcle

2010-11-21 16:33:55

From: Nava2
No no! You missed my point!

What I was talking about was the ``Look how much coal SRL has mined!'' Those stats, of course you have to update the stats yourself. It would be silly to have something else do it. :p


I didn't think this was planned?

Wizzup?

2010-11-21 16:35:35

From: Nava2
No no! You missed my point!

What I was talking about was the ``Look how much coal SRL has mined!'' Those stats, of course you have to update the stats yourself. It would be silly to have something else do it. :p


That has nothing to do with the client side implementation. The server handles all this, and the functionality is there, just not yet exposed.

Nava2

2010-11-21 17:48:55

From: Wizzup?
That has nothing to do with the client side implementation. The server handles all this, and the functionality is there, just not yet exposed.


Okay, great. That answers my question. :)

Wizzup?

2010-11-22 03:41:27

@Nava: I've implemented the feature partially now. You can see the ``Top Variables'' at the main page. (Their links will still 404): http://old.villavu.com/stats/

Shuttleu

2010-11-22 06:00:02

just out of curiosity, will the current stats be carried over to the new server?

or will everyone have to start again?

~shut

Wizzup?

2010-11-22 10:21:09

From: Shuttleu
just out of curiosity, will the current stats be carried over to the new server?

or will everyone have to start again?

~shut


Start over. There's no way to transfer it in a nice way.

Wizzup?

2010-11-22 10:53:12

It probably needs some tweaking, but this demonstrates some of the power… :p


Ignore the title, it is an overview of all the users who committed to the iron miner. The bigger their piece of the pie, the more minutes they committed. The same can be done to variables, etc.

Nava2

2010-11-22 11:03:51

From: Wizzup?
It probably needs some tweaking, but this demonstrates some of the power… :p


Ignore the title, it is an overview of all the users who committed to the iron miner. The bigger their piece of the pie, the more minutes they committed. The same can be done to variables, etc.


Odd, the image won't display..

Wizzup?

2010-11-22 11:07:41

From: Nava2
Odd, the image won't display..


It's SVG. Here's a PNG: http://old.villavu.com/merlijn/static/stats_graph.png

E: Hey… The SVN and the PNG aren't the same… wat
Anyway, get a SVG compatible browser. :p

E2: Inkscape could export it properly. :)

Shuttleu

2010-11-22 11:32:10

so can chrome :D

~shut

Gu3st...

2010-11-22 11:51:54

From: Shuttleu
so can chrome :D

~shut
It indeed can :D

That is awesome Wizzup!
But it needs a better design… :p
And what happened to "Whirr"? Why is he inside the pie?

Wizzup?

2010-11-22 13:24:15

From: Zyt3x
It indeed can :D

That is awesome Wizzup!
But it needs a better design… :p
And what happened to "Whirr"? Why is he inside the pie?


Not sure. I'll make sure that the pie chart has ~15 max entries anyway.

mormonman

2010-11-22 13:27:44

From: Wizzup?
Not sure. I'll make sure that the pie chart has ~15 max entries anyway.


And just leave the rest of the entries as "other"?

Wizzup?

2010-11-22 13:51:36

From: mormonman
And just leave the rest of the entries as "other"?


That was the idea. Although you can view all the users as a list of text somewhere probably.

Nava2

2010-11-22 14:52:00

From: Wizzup?
It's SVG. Here's a PNG: http://old.villavu.com/merlijn/static/stats_graph.png

E: Hey… The SVN and the PNG aren't the same… wat
Anyway, get a SVG compatible browser. :p

E2: Inkscape could export it properly. :)


I meant on the forums, I can view it in my browser, haha.

I use FF/Ice Weasel.

Wizzup?

2010-11-25 18:56:12

From: Nava2
I meant on the forums, I can view it in my browser, haha.

I use FF/Ice Weasel.


Works for me. (On the forums)

Also, I just enabled the "commits to script" and "commits by user" pages:
http://old.villavu.com/stats/user/60/commits
http://old.villavu.com/stats/script/5/commits

Shuttleu

2010-11-25 19:06:39

i think on the first one it should have all the commits to each script together, then you can click on it and it will take you to all the commits they have done for that script

~shut

Wizzup?

2010-11-29 12:42:38

From: Shuttleu
i think on the first one it should have all the commits to each script together, then you can click on it and it will take you to all the commits they have done for that script

~shut


I'll something like that later as well.

Hobbit

2010-12-02 10:54:50

On the website when you click on a script, the comment link should be "Comment on this script". Not to :)

Wizzup?

2010-12-02 10:56:21

From: Hobbit
On the website when you click on a script, the comment link should be "Comment on this script". Not to :)


Doesn't it say "Commits" not "Comments"?

Shuttleu

2010-12-02 11:04:01

"Commits to this script"

~shut

Hobbit

2010-12-02 13:12:15

Opps, yes it does say Commits. :redface:

Nava2

2010-12-30 15:02:30

(*

Stats
=====

The Stats include contains wrapper functions provided by the SRL Stats API.
The functions contained are meant for ease of use for implementation into
scripts.

*)

// behaves as entries in a dict.
type
TStats_Vars = record
Name: string;
Value: integer;
end;


var
stats_Vars: Array of TStats_Vars;
stats_UserName, stats_UserPass, stats_ScriptID: String;
stats_Timer: integer;
stats_RandNames: Array of String;
stats_RandSolved: Array of Integer;


(*
SetupSRLStats
~~~~~~~~~~~~~

.. code-block:: pascal
procedure SetupSRLStats(ScriptID: integer; UserName, UserPass: string);

Initializes all variables necessary for SRL stats to function. Username and
password are *not* case sensitive.

Example:
.. code-block:: pascal
SetupSRLStats(64, 'SRL-Developers', 'SRLSRLSRL');
*)
procedure SetupSRLStats(ScriptID: integer; UserName, UserPass: string);
begin
stats_Timer := GetSystemTime;
stats_ScriptID := IntToStr(ScriptID);
stats_Username := LowerCase(UserName);
stats_UserPass := LowerCase(UserPass);
stats_RandNames := ['leo the gravedigger', 'freaky forester', 'maze',
'prison pete', 'evil bob''s island', 'drill demon',
'quiz', 'surprise exam', 'mollys evil twin', 'pinball',
'sandwich lady', 'bee keeper', 'pillory', 'capn arnav',
'abyssal teleport', 'certer', 'mime', 'frog', 'trade',
'mod', 'fight', 'lamp', 'bird nest', 'death'];
SetArrayLength(stats_RandSolved, Length(stats_RandNames));
end;

(*
stats_InitVariable
~~~~~~~~~~~~~~~~~~

.. code-block:: pascal
stats_InitVariable(VarName: String; InitValue: Integer);

Helper method to clean up code in the include. Removes some repeating code
internally.

.. WARNING::
Use of this method outside of this include *may* lead to multiple variables
of the same name. It does **not** check to see if the variable is already
present.

.. code-block:: pascal
stats_InitVariable('coal', 0);

*)
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 := Value;
end;


(*
stats_SetVariable
~~~~~~~~~~~~~~~~~

.. code-block:: pascal
stats_SetVariable(VarName: string; NewValue: Integer);

Sets the passed variable to the new value regardless of old value. This method
behaves much like stats_InitVariable but checks for the variable present first.

Example:
.. code-block:: pascal
stats_SetVariable('runite', 10)
*)
procedure stats_SetVariable(VarName: string; NewValue: Integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName); // set it to lowercase since not case sensitive

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

// the variable is not present already, thus make a new entry into the dict.
stats_InitVariable(VarName, Value);
end;

(*
stats_IncVariable
~~~~~~~~~~~~~~~~~

.. code-block:: pascal
procedure stats_IncVariable(VarName: string; Value: integer);

Increments a variable by the value passed.

Example:
.. code-block:: pascal
stats_IncVariable('cod', 69);

*)
procedure stats_IncVariable(VarName: string; Value: integer);
var
i, h: Integer;
begin
h := High(stats_Vars);
VarName := LowerCase(VarName); // set it to lowercase since not case sensitive

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;

// the variable is not present already, thus make a new entry into the dict.
stats_InitVariable(VarName, Value);
end;


(*
stats_Commit
~~~~~~~~~~~~

.. code-block:: pascal
function stats_Commit: Boolean;

Sends all the information currently stored in the system to the server. Returns
true if commit was successful, displays error messages. One should note that the
stats variables are set to 0 on commit.

Example:
.. code-block:: pascal
if (stats_Commit) then
WriteLn('We are success.');

*)
function stats_Commit: Boolean;
var
SRLClient, Worked, i, ExtraTime: integer;
S: String;
begin
ExtraTime := GetSystemTime - stats_Timer;
Worked := ExtraTime / 60000;
ExtraTime := ExtraTime - (Worked*60000);
if Worked < 1 then
Exit;
stats_Timer := GetSystemTime - ExtraTime;
SRLClient := InitializeHTTPClient(False, False);
ClearPostData(SRLClient);

AddPostVariable(SRLClient, 'user', stats_UserName);
AddPostVariable(SRLClient, 'password', stats_UserPass);
AddPostVariable(SRLClient, 'script', stats_ScriptID);
AddPostVariable(SRLClient, 'time', IntToStr(Worked));

for i := 0 to 23 do
if (RandSolved[i] > stats_RandSolved[i]) then
begin
AddPostVariable(SRLClient, stats_RandNames[i], IntToStr(RandSolved[i]-stats_RandSolved[i]));
stats_RandSolved[i]:= RandSolved[i];
end;

if (Length(stats_Vars) > 0) then
for i := 0 to High(stats_Vars) do
with stats_Vars[i] do
begin
AddPostVariable(SRLClient, Name, IntToStr(Value));
Value := 0;//Clear for next commit
end;

S := PostHTTPPageEx(SRLClient, 'http://old.villavu.com/stats/api/commit');
FreeHTTPClient(SRLClient);
Result := False;
Case ExtractFromStr(S, Numbers) of
'100': Result := True; // successful commit.
'110': Writeln('SRL_Stats: Incorrect user and/or password');
'120': Writeln('SRL_Stats: Incorrect script ID');
'130': Writeln('SRL_Stats: Invalid time');
'140': Writeln('SRL_Stats: Variable does not exist');
'150': Writeln('SRL_Stats: Wrong info for variable');
'160': Writeln('SRL_Stats: Internal server error');
else
Writeln('SRL_Stats: No POST return');
end;
end;

My edits with the new doc style as well.

Shuttleu

2010-12-30 16:21:29

new doc style?

~shut

Nava2

2010-12-30 16:27:14

@shuttleu, just let it happen. :)

Shuttleu

2010-12-30 16:40:28

From: Nava2
@shuttleu, just let it happen. :)


is there a thread i can see about this new doc style?
also, when was this agreed? as i have heard nothing about it

~shut

Dgby714

2010-12-30 16:43:43

Mine:

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

const
stats_DefaultURL = 'http://old.villavu.com/stats/api/commit';
stats_URL = 0;
stats_UserID = 1;
stats_Pass = 2;
stats_ScriptID = 3;
stats_LastResult = 4;

var
stats_Config: array[stats_URL..stats_LastResult] of string;
stats_Vars: array of Tstats_Var;
stats_Randoms: array[0..23] of string;
stats_RandSolved: array[0..23] of integer;
stats_Time: integer;

procedure stats_SetUserID(const UserID: variant);
begin
if (not (VarType(UserID) = varString)) then
UserID := ToStr(UserID);
stats_Config[stats_UserID] := UserID;
end;

procedure stats_SetPass(const Pass: string);
begin
stats_Config[stats_Pass] := Pass;
end;

procedure stats_SetScriptID(const ScriptID: integer);
begin
stats_Config[stats_ScriptID] := IntToStr(ScriptID);
end;

procedure stats_NewCommit();
begin
SetLength(stats_Vars, 0);
stats_Time := 0;
end;

procedure stats_AddVariable(const Name: string; const Value: integer);
var
I: integer;
begin
for I := 0 to High(stats_Vars) do
if (stats_Vars[I].Name = Name) then
begin
IncEx(stats_Vars[I].Value, Value);
Exit;
end;

SetLength(stats_Vars, Length(stats_Vars) + 1);
stats_Vars[High(stats_Vars)].Name := Name;
stats_Vars[High(stats_Vars)].Value := Value;
end;

procedure stats_SetTimeAdded(const Minutes: integer);
begin
IncEx(stats_Time, Minutes);
end;

procedure stats_SetURL(const URL: string);
begin
stats_Config[stats_URL] := URL;
end;

function stats_Commit(): boolean;
var
Client, I: integer;
begin
Result := False;

if (stats_Config[stats_UserID] = '') then
RaiseException(erCustomError, 'SRL Stats: Username has not been set.');

if (stats_Config[stats_Pass] = '') then
RaiseException(erCustomError, 'SRL Stats: Password has not been set.');

if (stats_Config[stats_ScriptID] = '') then
RaiseException(erCustomError, 'SRL Stats: Script ID has not been set.');

if (stats_Randoms[0] = '') then
stats_Randoms := ['leo the gravedigger', 'freaky forester', 'maze',
'prison pete', 'evil bob''s island', 'drill demon',
'quiz', 'surprise exam', 'mollys evil twin', 'pinball',
'sandwich lady', 'bee keeper', 'pillory', 'capn arnav',
'abyssal teleport', 'certer', 'mime', 'frog', 'trade',
'mod', 'fight', 'lamp', 'bird nest', 'death'];

Client := InitializeHTTPClient(True);
try
ClearPostData(Client);
AddPostVariable(Client, 'user', stats_Config[stats_UserID]);
AddPostVariable(Client, 'password', stats_Config[stats_Pass]);
AddPostVariable(Client, 'script', stats_Config[stats_ScriptID]);
AddPostVariable(Client, 'time', IntToStr(stats_Time));

for I := 0 to High(stats_Vars) do
AddPostVariable(Client, stats_Vars[I].Name, IntToStr(stats_Vars[I].Value));

for I := 0 to High(stats_RandSolved) do
if (RandSolved[I] > stats_RandSolved[I]) then
begin
AddPostVariable(Client, stats_Randoms[I], IntToStr(RandSolved[I] - stats_RandSolved[I]));
stats_RandSolved[I] := RandSolved[I];
end;

if (stats_Config[stats_URL] = '') then
stats_Config[stats_URL] := stats_DefaultURL;

stats_Config[stats_LastResult] := PostHTTPPageEx(Client, stats_Config[stats_URL]);
case stats_Config[stats_LastResult] of
'100': Result := True;
'110': RaiseException(erCustomError, 'SRL Stats: Incorrect user and/or password.');
'120': RaiseException(erCustomError, 'SRL Stats: Incorrect script ID.');
'130': RaiseException(erCustomError, 'SRL Stats: Invalid time.');
'140': RaiseException(erCustomError, 'SRL Stats: Variable does not exist.');
'150': RaiseException(erCustomError, 'SRL Stats: Wrong info for variable.');
'160': RaiseException(erCustomError, 'SRL Stats: Internal server error.');
else
RaiseException(erCustomError, 'SRL Stats: Unknown error.');
end;
finally
FreeHTTPClient(Client);
end;
end;

Shuttleu

2010-12-30 16:52:54

From: Dgby714
Mine:

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

const
stats_DefaultURL = 'http://old.villavu.com/stats/api/commit';
stats_URL = 0;
stats_UserID = 1;
stats_Pass = 2;
stats_ScriptID = 3;
stats_LastResult = 4;

var
stats_Config: array[stats_URL..stats_LastResult] of string;
stats_Vars: array of Tstats_Var;
stats_Randoms: array[0..23] of string;
stats_RandSolved: array[0..23] of integer;
stats_Time: integer;

procedure stats_SetUserID(const UserID: variant);
begin
if (not (VarType(UserID) = varString)) then
UserID := ToStr(UserID);
stats_Config[stats_UserID] := UserID;
end;

procedure stats_SetPass(const Pass: string);
begin
stats_Config[stats_Pass] := Pass;
end;

procedure stats_SetScriptID(const ScriptID: integer);
begin
stats_Config[stats_ScriptID] := IntToStr(ScriptID);
end;

procedure stats_NewCommit();
begin
SetLength(stats_Vars, 0);
stats_Time := 0;
end;

procedure stats_AddVariable(const Name: string; const Value: integer);
var
I: integer;
begin
for I := 0 to High(stats_Vars) do
if (stats_Vars[I].Name = Name) then
begin
IncEx(stats_Vars[I].Value, Value);
Exit;
end;

SetLength(stats_Vars, Length(stats_Vars) + 1);
stats_Vars[High(stats_Vars)].Name := Name;
stats_Vars[High(stats_Vars)].Value := Value;
end;

procedure stats_SetTimeAdded(const Minutes: integer);
begin
IncEx(stats_Time, Minutes);
end;

procedure stats_SetURL(const URL: string);
begin
stats_Config[stats_URL] := URL;
end;

function stats_Commit(): boolean;
var
Client, I: integer;
begin
Result := False;

if (stats_Config[stats_UserID] = '') then
RaiseException(erCustomError, 'SRL Stats: Username has not been set.');

if (stats_Config[stats_Pass] = '') then
RaiseException(erCustomError, 'SRL Stats: Password has not been set.');

if (stats_Config[stats_ScriptID] = '') then
RaiseException(erCustomError, 'SRL Stats: Script ID has not been set.');

if (stats_Randoms[0] = '') then
stats_Randoms := ['leo the gravedigger', 'freaky forester', 'maze',
'prison pete', 'evil bob''s island', 'drill demon',
'quiz', 'surprise exam', 'mollys evil twin', 'pinball',
'sandwich lady', 'bee keeper', 'pillory', 'capn arnav',
'abyssal teleport', 'certer', 'mime', 'frog', 'trade',
'mod', 'fight', 'lamp', 'bird nest', 'death'];

Client := InitializeHTTPClient(True);
try
ClearPostData(Client);
AddPostVariable(Client, 'user', stats_Config[stats_UserID]);
AddPostVariable(Client, 'password', stats_Config[stats_Pass]);
AddPostVariable(Client, 'script', stats_Config[stats_ScriptID]);
AddPostVariable(Client, 'time', IntToStr(stats_Time));

for I := 0 to High(stats_Vars) do
AddPostVariable(Client, stats_Vars[I].Name, IntToStr(stats_Vars[I].Value));

for I := 0 to High(stats_RandSolved) do
if (RandSolved[I] > stats_RandSolved[I]) then
begin
AddPostVariable(Client, stats_Randoms[I], IntToStr(RandSolved[I] - stats_RandSolved[I]));
stats_RandSolved[I] := RandSolved[I];
end;

if (stats_Config[stats_URL] = '') then
stats_Config[stats_URL] := stats_DefaultURL;

stats_Config[stats_LastResult] := PostHTTPPageEx(Client, stats_Config[stats_URL]);
case stats_Config[stats_LastResult] of
'100': Result := True;
'110': RaiseException(erCustomError, 'SRL Stats: Incorrect user and/or password.');
'120': RaiseException(erCustomError, 'SRL Stats: Incorrect script ID.');
'130': RaiseException(erCustomError, 'SRL Stats: Invalid time.');
'140': RaiseException(erCustomError, 'SRL Stats: Variable does not exist.');
'150': RaiseException(erCustomError, 'SRL Stats: Wrong info for variable.');
'160': RaiseException(erCustomError, 'SRL Stats: Internal server error.');
else
RaiseException(erCustomError, 'SRL Stats: Unknown error.');
end;
finally
FreeHTTPClient(Client);
end;
end;


i dont like the fact that you have different procedures for the user id, pass and script id

i also dont like how setting the time added is manual as people can easily get this wrong

and i also dont like how you have a procedure to set the stats location, i mean there is only ever going to be one location, so why would you need to change it, just set it to the URL when it is first run

finally, i dont like how you have to manually reset the stats vars after you call the stats commit, people could easily forget this

Do what me and Narcle did and have only three procedures, much easier and simpler

~shut

Dgby714

2010-12-30 16:56:15

From: Shuttleu
i dont like the fact that you have different procedures for the user id, pass and script id

i also dont like how setting the time added is manual as people can easily get this wrong

and i also dont like how you have a procedure to set the stats location, i mean there is only ever going to be one location, so why would you need to change it, just set it to the URL when it is first run

finally, i dont like how you have to manually reset the stats vars after you call the stats commit, people could easily forget this

Do what me and Narcle did and have only three procedures, much easier and simpler

~shut


I just went by how it was in Wizzup?'s post =/
Well I added the URL thing because as it stands now there are 2 stats sites (Tho one is temp)

3Garrett3

2010-12-30 17:06:07

From: Shuttleu
is there a thread i can see about this new doc style?
also, when was this agreed? as i have heard nothing about it

~shut


New document style. It's in the new SRL iirc. There is a couple threads in the MSI forums about MSI adapting the style generally, but I'm not sure if they're in public boards… Hmm. I dunno where else I've heard about it.

Coh3n

2010-12-30 19:39:00

From: Shuttleu

and i also dont like how you have a procedure to set the stats location, i mean there is only ever going to be one location, so why would you need to change it, just set it to the URL when it is first run

Could just have it set the default link if the scripter didn't call the procedure. You never know, the link could change sometime. :p

Shuttleu

2011-01-01 13:03:16

which script are we using?
and is it already included in srl?

~shut

**BANNED The Man

2011-01-01 13:17:16

From: Shuttleu
which script are we using?
and is it already included in srl?

~shut


This ^
I want to start adding it to my scripts xD

-Boom

Nava2

2011-01-01 14:58:24

The version I posted, possibly modified a bit, will be included into SRL5, for now, feel free to use the function names there. I'm not sure if we want to commit it to SRL4 right now..

Not my call to make individually! I do not see why we shouldn't at this point.

Shuttleu

2011-01-01 15:50:25

will there be any authors named?

~shut

Coh3n

2011-01-01 16:34:09

From: Nava2
The version I posted, possibly modified a bit, will be included into SRL5, for now, feel free to use the function names there. I'm not sure if we want to commit it to SRL4 right now..

Not my call to make individually! I do not see why we shouldn't at this point.

I don't see why it shouldn't be either.

From: Shuttleu
will there be any authors named?

~shut

Why..?

Shuttleu

2011-01-01 16:56:18

From: Coh3n
Why..?


i was told that mine and Naike's name were gonna go on it, but in the new doc type i dont see any author names

~shut

Wizzup?

2011-01-01 17:29:14

To be honest credits to go Shuttleu and Narcle

Nava2

2011-01-01 17:50:03

To be honest, I'm not a fan of the whole credit thing. I think contributors pages are substantial enough.

Just saying. I really really dislike when people do things purely for the credits. I find it immature and irritating.

Frement

2011-01-01 17:53:39

Its a motivational thing.

Wizzup?

2011-01-01 19:24:34

From: Nava2
To be honest, I'm not a fan of the whole credit thing. I think contributors pages are substantial enough.

Just saying. I really really dislike when people do things purely for the credits. I find it immature and irritating.


They wrote the entire thing together. They deserve the credits. If not at the top of the file / documentation, then at every function.

Narcle

2011-01-02 04:01:55

From: Nava2
To be honest, I'm not a fan of the whole credit thing. I think contributors pages are substantial enough.

Just saying. I really really dislike when people do things purely for the credits. I find it immature and irritating.


I think its good to know who wrote it so you can ask them about it. Just like I was ask quite a few times about worldswitcher.

Shuttleu

2011-01-02 09:25:19

From: Nava2
To be honest, I'm not a fan of the whole credit thing. I think contributors pages are substantial enough.

Just saying. I really really dislike when people do things purely for the credits. I find it immature and irritating.


i didnt do it for the credits, but i do think that if someone has spent some time on something then they should have their name on it so people know who done it
also like Frement said, if someone thinks they can have their name in the include then they are more likely to make something

~shut

Dgby714

2011-01-02 20:45:20

I always thought we had names on functions so if it breaks we know who to turn to for help fixing it. =?

Nava2

2011-01-02 21:07:40

From: Shuttleu
i didnt do it for the credits, but i do think that if someone has spent some time on something then they should have their name on it so people know who done it
also like Frement said, if someone thinks they can have their name in the include then they are more likely to make something

~shut


You, of all people, would agree with that.

I think that when people contribute to Open Source projects with the intent of just getting their names in it, its ridiculous.

@Dgby, Yes, but no. In my opinion, code should be properly documented so that one can understand what is going on in the code removing the need for having a dependence on someone.

Narcle

2011-01-02 21:39:59

From: Nava2
You, of all people, would agree with that.

I think that when people contribute to Open Source projects with the intent of just getting their names in it, its ridiculous.

@Dgby, Yes, but no. In my opinion, code should be properly documented so that one can understand what is going on in the code removing the need for having a dependence on someone.


Then there should be no credits given to those that made Linux? If you spent hundreds even thousands of hours working on it you wouldn't add your name to it eh? (not implying I did on this, just the principle of it…)

And I really doubt you would add a step by step guide to every function for documentation.

Nava2

2011-01-02 21:51:27

From: Narcle
Then there should be no credits given to those that made Linux? If you spent hundreds even thousands of hours working on it you wouldn't add your name to it eh? (not implying I did on this, just the principle of it…)


There's a difference there. Magnitude is the key part there.

From: Narcle
And I really doubt you would add a step by step guide to every function for documentation.


I try my best to do that! It makes life easier for those who come across later. It takes minimal amounts of time for us to do it, but when others spend hours trying to figure out what the hell you did, thats not right.

Wizzup?

2011-01-03 01:46:19

I thought we agreed upon keeping the credits when we set this standard. Let us not deviate and just add the damn credits as they are well deserved!

Besides, if you like it your way start off by not giving yourself credits, don't bother others with it. :)

3Garrett3

2011-01-03 02:33:53

Could we not argue about credits and just commit something to SRL so we can get to adding this to our scripts? :)

Capricorn

2011-01-03 02:40:57

From: 3Garrett3
Could we not argue about credits and just commit something to SRL so we can get to adding this to our scripts? :)


I agree with this fine chap.

Dgby714

2011-01-03 03:01:18

From: 3Garrett3
Could we not argue about credits and just commit something to SRL so we can get to adding this to our scripts? :)


This ^

Wanted

2011-01-03 03:17:41

Pull together something that fits into SRL 4 and someone will commit it

3Garrett3

2011-01-03 10:34:55

A bunch of code samples have been given already, if we were given the problems with them then perhaps we could make it work better?

Gu3st...

2011-01-03 10:59:44

Did some tiny edits to the script shut posted:
// Credits goes to Shuttleu and Narcle
const
Stats_Link = 'http://old.villavu.com/stats/api/commit';

type
TVar = record
Name : String;
Value : Integer;
end;

var
Stats_Values : array of TVar;
Stats_User, Stats_Pass, Stats_ID : String;
Stats_Time : Integer;
Stats_RandomCount : TIntegerArray;
Stats_RandomNames : TStringArray;

procedure SetupSRLStats(Username, Password : String; ScriptID : Integer; RandomNames : TStringArray);
begin
Stats_User := Username;
Stats_Pass := Password;
Stats_ID := IntToStr(ScriptID);
Stats_Time := GetSystemTime;
Stats_RandomNames := RandomNames;
SetLength(Stats_RandomCount, Length(Stats_RandomNames));
end;

procedure StatsIncVar(Name : String; Value : Integer);
var
I, H : Integer;
Exists : Boolean;
begin
while (not Exists) and (I <= High(Stats_Values)) do
begin
if Stats_Values[I].Name = Name then Exists := True;
Inc(I);
end;
if not Exists then
begin
SetArrayLength(Stats_Values, Length(Stats_Values)+1);
H := High(Stats_Values);
Stats_Values[H].Name := Name;
end;
IncEx(Stats_Values[H].Value, Value);
end;

procedure StatsCommit;
var
Client, I : Integer;
Returned : String;
NewTime, H, M, S : Integer;
begin
Client := InitializeHTTPClient(False, False);

if (Stats_Time = 0) then
begin
Writeln('You must call SetupSRLStats before you can use the stats.');
Exit;
end;

NewTime := GetSystemTime;
ConvertTime(NewTime-Stats_Time, H, M, S);
if ((H < 1) and (M < 1)) then Exit; // If only seconds has passed then don't bother comitting... ( I don't think the system is made for second precision either )

Stats_Time := (GetSystemTime-((NewTime-Stats_Time)-((H*60*60*1000)+(M*60*1000))));
for I := High(Stats_RandomCount) downto 0 do
if (RandSolved[I]>Stats_RandomCount[I]) then
begin
AddPostVariable(Client, Stats_RandomNames[I], IntToStr(RandSolved[I]-Stats_RandomCount[I]));
Stats_RandomCount[I] := RandSolved[I];
end;

AddPostVariable(Client, 'time', IntToStr((H*60)+M));
AddPostVariable(Client, 'user', Stats_User);
AddPostVariable(Client, 'password', Stats_Pass);
AddPostVariable(Client, 'script', Stats_ID);
for I := High(Stats_Values) downto 0 do
AddPostVariable(Client, Stats_Values[I].Name, IntToStr(Stats_Values[I].Value));
Returned := PostHTTPPageEx(Client, Stats_Link);

Case Returned of
'100': Writeln('SRL_Stats: Success');
'110': Writeln('SRL_Stats: Incorrect user and/or password');
'120': Writeln('SRL_Stats: Incorrect script ID');
'130': Writeln('SRL_Stats: Invalid time');
'140': Writeln('SRL_Stats: Variable does not exist');
'150': Writeln('SRL_Stats: Wrong info for variable');
'160': Writeln('SRL_Stats: Internal server error');
else
Writeln('SRL_Stats: No POST return');
end;

SetArrayLength(Stats_Values, 0);
FreeHTTPClient(Client);
end;
No major changes, but note the changes I did on SetupSRLStats (added RandomNames variable)

Wizzup?

2011-01-03 12:25:42

Oh, how useful git is for this kind of stuff…

Icefire, what needs to be changed to make this work with SRL 4? Except for the patch to make SRL record and send it's randoms?

Wanted

2011-01-03 21:11:49

From: Wizzup?
Oh, how useful git is for this kind of stuff…

Icefire, what needs to be changed to make this work with SRL 4? Except for the patch to make SRL record and send it's randoms?


Make it compile in simba and has the SRL 4 doc.

Narcle

2011-01-03 22:44:42

Try using the SRL 5 one I commited yesterday. Nava forgot to change the var names in his new functions… Only thing that didn't let it compile. It should work in both unless there is something I'm missing?

Wizzup?

2011-01-04 02:34:07

I say commit the one from SRL-5. The new documentation style doesn't really matter. It's not like some program creates documentation from SRL-4 anyway.

BraK

2011-01-09 18:33:13

Has this been Committed yet? If so where is it in the include and How do we use it? If not why not what needs to be Improved? Thanks in advance.

~BraK

Coh3n

2011-01-09 18:34:20

From: BraK
Has this been Committed yet? If so where is it in the include and How do we use it? If not why not what needs to be Improved? Thanks in advance.

~BraK

Yes it has, to SRL/SRL/misc/Stats.simba, and I made another thread asking how to use it because I can't get it to work. :(

BraK

2011-01-10 00:06:09

Ah that's in MSI… Was more or less talking about SRL if that's what you meant I don't see it there.

~BraK

NVM found it.

Next question:

procedure stats_IncVariable(VarName: string; Value: integer);

What am I putting in for the Var name considering how long some of the names are. Do I put:

stats_IncVariable('Total Levels Gained', 1);

to add one to Variable(Total Levels Gained). Do I have to reset the total to 0 after I use it every time as on Nielsie's we didn't have to it was in his code.

~BraK

Nava2

2011-01-10 00:25:54

From: BraK
Ah that's in MSI… Was more or less talking about SRL if that's what you meant I don't see it there.

~BraK

NVM found it.

Next question:

procedure stats_IncVariable(VarName: string; Value: integer);

What am I putting in for the Var name considering how long some of the names are. Do I put:

stats_IncVariable('Total Levels Gained', 1);

to add one to Variable(Total Levels Gained). Do I have to reset the total to 0 after I use it every time as on Nielsie's we didn't have to it was in his code.

~BraK


stats_Commit() takes care of all that. :)

BraK

2011-01-10 00:52:19

From: Nava2
stats_Commit() takes care of all that. :)


I get it to compile. What I'm trying to do is get it usable. I still need to declare which it's supposed to inc with. Stats_IncVariable right?

Here's what I got that's coming back with a false Boolean.

program new;
{$i srl/srl.scar}
{$i srl/srl/misc/stats.simba}
begin
SetupSRLStats(17, 'brak', '****');
stats_IncVariable('Total Levels Gained', 1);
if stats_Commit then
writeln('Woot')
else
writeln('Dang');
end.

~BraK

Coh3n

2011-01-10 03:19:38

From: BraK
I get it to compile. What I'm trying to do is get it usable. I still need to declare which it's supposed to inc with. Stats_IncVariable right?

Here's what I got that's coming back with a false Boolean.

program new;
{$i srl/srl.scar}
{$i srl/srl/misc/stats.simba}
begin
SetupSRLStats(17, 'brak', '****');
stats_IncVariable('Total Levels Gained', 1);
if stats_Commit then
writeln('Woot')
else
writeln('Dang');
end.

~BraK

Does it say invalid username/pass? I was getting that when I put 'Coh3n' as my username. It went away when I used my ID rather than name. Also, the link in Stats.simba isn't right, that's why nothing is being added.

Try changing the link to stats.villavu.com/api/commit and see if that works. Let me know so I can commit as soon as possible. :)

E: I just committed to SRL, your little test script should work now. :)

BraK

2011-01-10 06:13:49

From: Coh3n
Does it say invalid username/pass? I was getting that when I put 'Coh3n' as my username. It went away when I used my ID rather than name. Also, the link in Stats.simba isn't right, that's why nothing is being added.

Try changing the link to stats.villavu.com/api/commit and see if that works. Let me know so I can commit as soon as possible. :)

E: I just committed to SRL, your little test script should work now. :)


Changed the link and yea that was wrong. It is also getting an unknown Identifier error with the Random Variables. I never got the I correct Username Issue. I'm currently testing the one the Dbgy714 wrote up. He has already used it to post with, I'll most Likely include his into my script if it works.

~BraK

E: Tested with the update it's still giving me a false and still reading as no Commits(Tested using both User name and User ID.)

Bobzilla69

2011-01-10 06:25:56

i am using my username to commit and it seems to work. i am also using the simba updater

BraK

2011-01-10 06:36:55

From: bobzilla69
i am using my username to commit and it seems to work. i am also using the simba updater


Please post what your using to commit and how you wrote it out.

~BraK

Bobzilla69

2011-01-10 06:42:48

program new;
{$i SRL\SRL.scar}
{$i SRL\SRL\Misc\stats.simba}
var
i:integer;

procedure DeclarePlayers;
var
I: integer;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

DebugTheTPA := False; //True if you want to see TPA debug (color only)

with Players[0] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

for I := 0 to HowManyPlayers - 1 do
with Players[I] do
begin
BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;
end;

begin
setupsrl;
declarepalyers;
SetupSRLStats(Script id, 'SRLStats_UserUsername', 'SRLStats_Password');
stats_IncVariable('stat to inc name', 1);
repeat
wait(5000);
inc(i); //i just loop for a while so that it has been on for a few minutes
until(i >= 30)
end.

think that was all of it

BraK

2011-01-10 06:51:06

From: bobzilla69
program new;
{$i SRL\SRL.scar}
{$i SRL\SRL\Misc\stats.simba}
var
i:integer;

procedure DeclarePlayers;
var
I: integer;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

DebugTheTPA := False; //True if you want to see TPA debug (color only)

with Players[0] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

for I := 0 to HowManyPlayers - 1 do
with Players[I] do
begin
BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;
end;

begin
setupsrl;
declarepalyers;
SetupSRLStats(Script id, 'SRLStats_UserUsername', 'SRLStats_Password');
stats_IncVariable('stat to inc name', 1);
repeat
wait(5000);
inc(i); //i just loop for a while so that it has been on for a few minutes
until(i >= 30)
end.

think that was all of it


Is that what you put for user name and Password? 'SRLStats_username' that doesn't make much sense otherwise that's what I put… I gotta go back to work will test again when I get home.

~BraK

Bobzilla69

2011-01-10 06:54:26

no i use constants in the script to set it so it would be
SetupSRLStats(ScriptID, SRLStats_UserUsername, SRLStats_Password);

but what i gave you is a simple script to make sure it works so you can simply eneter your details in there like
SetupSRLStats(14588, 'jamesk', 'mypassword123');

BraK

2011-01-10 08:45:00

From: bobzilla69
no i use constants in the script to set it so it would be
SetupSRLStats(ScriptID, SRLStats_UserUsername, SRLStats_Password);

but what i gave you is a simple script to make sure it works so you can simply eneter your details in there like
SetupSRLStats(14588, 'jamesk', 'mypassword123');


I have the same thing on my test as shown above it just doesn't work how are you declaring your Variables that you are increasing.

~BraK

Bobzilla69

2011-01-10 08:47:49

all i am doing for say after killing a rat is
stats_IncVariable('Giant Rats Killed', 1);
just make sure the variable you are sending is in the script

you dont have to declare them, if i am reading the stats.simba correctly

Bixby Sayz

2011-01-11 12:58:36

Just a quick comment on the signup process. After signing up there is no indication of what your id is.

You have to go to the list of users and click next, next, next, etc to get to the end of the list to find yourself. Not a problem now, but as the list of users grows…

Dgby714

2011-01-11 13:24:46

From: Bixby Sayz
Just a quick comment on the signup process. After signing up there is no indication of what your id is.

You have to go to the list of users and click next, next, next, etc to get to the end of the list to find yourself. Not a problem now, but as the list of users grows…


Use your user name instead?

Wizzup?

2011-01-15 05:36:36

From: Bixby Sayz
Just a quick comment on the signup process. After signing up there is no indication of what your id is.

You have to go to the list of users and click next, next, next, etc to get to the end of the list to find yourself. Not a problem now, but as the list of users grows…


Right. That's a good point.
Added to TODO:
    -   Implement searches.
- Give the user a permanent link to his acccount; on register.
- Redirect to the user to his own account; on login.

Nava2

2011-01-15 13:42:07

From: Wizzup?
Right. That's a good point.
Added to TODO:
    -   Implement searches.
- Give the user a permanent link to his acccount; on register.
- Redirect to the user to his own account; on login.


Perhaps adding ``sort by colums'' would be nice as well. :)