SRL Archive - Senior Scripts and Snippets

Sms


nielsie95

2008-11-17 11:25:52

Hey,

I decided to do another project in PHP. This time it's a 'copy' of the SRL stats. I'm still working on it, but I think I got the base done.

http://scriptmanager.freehostia.com/

At the moment you can:
  • Register (a script)
  • Manage your account (+ scripts)
  • It tracks every script for every user so you can see who is running/runs your script
  • View averages
  • Version history
  • News (will be downloadable through SCAR)
  • Stats levels (1 - 100), no one will max out this time :p
  • Able to mark a script as outdated (by scripter). If a script hasn't been updated in 3 months, it says "maybe outdated" (updating news counts as updating).
  • You also have an option to view/reset your accounts while you're running a script (tuCos), but it only becomes visible when you have 1+ accounts.

Future plans (in the correct order):
  • news system for the index + online users/scripts (online as in running).
  • Ranks (admin - mod)
  • SCAR part
  • FAQ
  • Nothing
  • Signatures

I might move the signatures up a bit if someone gets me some nice templates.
Create as much scripts / accounts as you want, it's still a testing phase.

Now, please give me some suggestions/bugs :)

Bobarkinator

2008-11-17 20:47:31

Why is the title SMS? I was hoping it would text me something :(

nielsie95

2008-11-18 01:52:51

Script Management System. I'm not very creative when it comes to names :p

EvilChicken!

2008-11-18 03:35:24

Really good job, Niels, looks really good!

I'm hoping this can replace the current one(s) we have.
I especially like the extra features, suck as the ability to view who has been running your script and the possibility to mark a script as outdated ..

Freddy1990

2008-11-18 10:07:28

From: nielsie95
Script Management System.


Figured as much :p
Looks very nice, though I'd replace the template's example text with something more fitting :p

nielsie95

2008-11-18 15:13:50

Thanks guys :)

The example text will be replaced with the news.
I added a page where you can view all users. Also added a search to scripts + users.

mastaraymond

2008-11-18 15:48:17

I thought you devlopped some kind of SMS system xD. Original!

HyperSecret

2008-11-18 21:39:25

From: nielsie95

  • Stats levels (1 - 100), no one will max out this time :p


Is that a challenge? Looks good though. I like the feature to look who has run the script, nice.

Sir R. M8gic1an

2009-04-29 16:51:23

hummm…. any chance this still works ? :)

might save some time and th features look good ;)

~RM

Wizzup?

2009-04-29 17:06:49

From: Rasta Magician
hummm…. any chance this still works ? :)

might save some time and th features look good ;)

~RM


Would definitely save me some time. I haven't tried to make my own vBulletin mod yet, though.

nielsie95

2009-05-02 00:50:51

It still works, I haven't made much progress since the start of this thread though.. The committing part is the only thing that's left to make it work at a minimum level.

Hobbit

2009-05-05 09:28:14

From: mastaraymond
I thought you devlopped some kind of SMS system xD. Original!


^^ I'm still working on that

Its getting closer now that I have a dedicated mail server to use for it :p

I like it nielsie :) Except i can't read it :(

nielsie95

2009-08-13 17:46:56

I was thinking of adjusting this to work with Wizzy's database, but I'm just going to finish this as it is instead. There's done a lot already and it shouldn't take long to finish it (at least it'll be faster than starting all over again).

It's not the best system, but it should do a good job as a new temporary stats system (it has taken some time, but there's still nothing more than a database) and, in my opinion, it's better than the old stats (option-wise). Does anyone has objections or tips?

Sir R. M8gic1an

2009-08-13 18:05:50

From: nielsie95
I was thinking of adjusting this to work with Wizzy's database, but I'm just going to finish this as it is instead. There's done a lot already and it shouldn't take long to finish it (at least it'll be faster than starting all over again).

It's not the best system, but it should do a good job as a new temporary stats system (it has taken some time, but there's still nothing more than a database) and, in my opinion, it's better than the old stats (option-wise). Does anyone has objections or tips?


I say go for it :)

Better to have working stats without being linked, than having no stats at all, and your system looks pretty good.

~RM

nielsie95

2009-08-14 15:23:44

Thanks :)
What do you mean by being linked?

Sir R. M8gic1an

2009-08-14 15:32:52

From: nielsie95
Thanks :)
What do you mean by being linked?


By being linked i meant the stats and the forum accounts having a connection, as in you use your SRL Forums account username + pw for stats, and like when you view someone's profile you can see their stats etc.

~RM

nielsie95

2009-08-14 16:40:08

Ah, I see.. Yeah, I've also looked into that and it's not as easy as it sounds :p So that's another reason why I've chosen to finish this first. Now I look at the code again, I see how I could've done things different/better, so it is a good practice for the next version too :)

nielsie95

2009-08-14 23:46:10

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('.|&#8364;stat&#8364;|.', [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('.|&#8364;stat&#8364;|.', 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?