Ok, I got pretty far today.
I uploaded the changes to FreeHostia and here's the SCAR script:
program New;
{.include SRL/SRL.scar}
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;
function Stats_GetScriptInfo(out Version, News, Link: string; out OutDated: Boolean): 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) = 4) then
begin
Result := True;
Version := sa[0];
News := sa[1];
Link := sa[2];
OutDated := sa[3] = '1';
end;
FreeHTTPClient(Client );
end;
var
Stats_GlobalVars: array[1..25] 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;
Time := 5;
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 := 1 to 25 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;
PostHTTPPageEx(Client, Stats_Link);
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));
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;
end;
FreeHTTPClient(Client);
stats_SendAccountInfo;
end;
var
i: Integer;
begin
SetupSRL;
NumberOfPlayers(2);
Players[0].Name := 'NielsTest';
Players[0].Loc := 'LolLand';
Players[0].Active := True;
Players[1].Name := 'NielsTest123';
Players[1].Loc := 'Geen Idee';
Players[1].Active := False;
Stats_UserID := '';
Stats_Password := '';
Stats_ScriptID := '';
repeat
for i := Low(RandSolved) to High(RandSolved) do
RandSolved[i] := RandSolved[i] + Random(10);
for i := Low(Stats_CustomVars) to High(Stats_CustomVars) do
Stats_CustomVars[i] := Random(10);
Stats_ManageAccounts;
Stats_SendReport;
Wait(5000);
until IsFKeyDown(5);
end.
You should be able to see what scripts you're running, see the stats, (de)activate accounts and release scripts. In SCAR, you should be able to download the version number, news, the link (if entered) and if it's outdated.
I created a very basic admin function which should help us manage it a bit easier. Also the news is parsed from a thread (a random thread currently). I don't know if that works on FreeHostia as they disabled outgoing connection, it checks every 15 mins and uses a temporary file (which is why it looks like it's still working).
I have it made so you need to enter either a userID or a scriptID, they can work seperately, but are bound together if both are filled in. So I hope that makes an end to "scriptaccounts".
You can see who are running / have runned a script (the blue messenger-like icon turns green).
Anyone care to test?