SRL Archive - Senior Scripts and Snippets

Introducing: [F]orever [A]gainst [G]old [F]arming - BETA


Kyle Undefined

2012-01-10 18:03:58

Stopped development on this!

Ok, so here's a BETA version of my anti gold farming measures. It's messy and ugly, and could use a clean up.

Basically, what it does is, on startup it reaches out to my webserver and grabs the IP of the current autoer. Then, it returns their IP, Expiration Date (Now + 6 hours), and if there is already an IP in the database for the script name that you pass in with the "FAGF_Setup();" procedure.

If there is a record already, it returns the database row ID, IP, stored expiration date, and True for already in use. It then tells the user when they could run the script again and terminates.

Also, if it's a first entry, it adds a procedure to the OnTerminate procedure that will erase that record it added at startup when the script finishes.

Let me know what you think, I've included the zip file as long as posting the code here for a quick view. I also pasted a test script on how it would be run, although it won't do much use to you since I was using it to make sure all the calls were correct while tracing the database.

It goes in the Include folder, but I'm sure you already knew that :p

Also, hope you enjoy what I've gotten so far. Oh, and this can also be modified easily for the script authing.

EDIT: This is only a TESTING method, I had already written this code/documentation/name and it's more of a way to show that you "could" use a method like this for online script authing and could eliminate sharing as well. It literally takes 10 minutes to change it for that purpose.

I was just too lazy to change it around, so sorry for the confusion.

FAGF/FAGF.simba:

type
TFAGF = record
ID : Integer;
ScriptName : String;
UserIP : String;
ExpDate : String;
AlreadyConnected : Boolean;
end;

type
TFAGFArray = Array of TFAGF;

var
gSetup : TFAGF;

function OnSetup() : TFAGF;
var
responseArr : TStringArray;
begin
responseArr := Explode('|', GetPage('http://srl.kyleundefined.com/FAGF/setup.php'));

try
if(StrToBool(responseArr[3]))then
begin
with Result do
begin
ID := StrToInt(responseArr[0]);
UserIP := responseArr[1];
ExpDate := responseArr[2];
AlreadyConnected := StrToBool(responseArr[3]);
end;
end;
except
with Result do
begin
UserIP := responseArr[0];
ExpDate := responseArr[1];
AlreadyConnected := StrToBool(responseArr[2]);
end;
end;
end;

procedure OnTerminate();
var
FAGF_Client : Integer;
FAGF_PostData : String;
begin
try
FAGF_Client := InitializeHTTPClient(false, false);
FAGF_PostData := 'id=' + IntToStr(gSetup.ID);
PostHTTPPage(FAGF_Client, 'http://srl.kyleundefined.com/FAGF/remove.php', FAGF_PostData);
except
{Just eat it}
finally
FreeHTTPClient(FAGF_Client);
end;
end;

{Stolen from AddOnTerminate}
procedure FAGF_End(const proc : string);
var
OldProcs : TVariantArray;
i : integer;
begin
GetScriptProp(SP_OnTerminate,OldProcs);
for i := 0 to high(OldProcs) do
if lowercase(OldProcs[i]) = lowercase(proc) then
exit;
setlength(OldProcs,Length(OldProcs)+1);
OldProcs[high(OldProcs)] := proc;
SetScriptProp(SP_OnTerminate,oldprocs);
end;

procedure FAGF_Setup(script : String);
var
setup : TFAGF;
_id, FAGF_Client : Integer;
FAGF_PostData : String;
begin
setup := OnSetup();
setup.ScriptName := script;
if(not(setup.AlreadyConnected))then
begin
try
FAGF_Client := InitializeHTTPClient(false, false);
FAGF_PostData := 'script=' + script;
FAGF_PostData := PostHTTPPage(FAGF_Client, 'http://srl.kyleundefined.com/FAGF/add.php', FAGF_PostData);
_id := StrToInt(FAGF_PostData);
setup.ID := _id;
except
{Just eat it}
finally
FreeHTTPClient(FAGF_Client);
end;
gSetup := setup;
FAGF_End('OnTerminate');
end else
begin
WriteLn('You are already running this script from this IP, you can run ' +
'this script again at: ' + setup.ExpDate);
TerminateScript;
end;
end;

Test:

program new;
{$i srl/srl.simba}
{$i FAGF/FAGF.simba}

begin
SetupSRL();
FAGF_Setup('Test');
Wait(10000);
end.

YoHoJo

2012-01-10 18:07:43

What this do bruh!

Kyle Undefined

2012-01-10 18:15:08

Updated the original post, sorry :p

lordsaturn

2012-01-10 18:27:24

Sorry, I would not willingly restrict my freedoms or recommend this to anyone.

YoHoJo

2012-01-10 18:33:45

From: lordsaturn
Sorry, I would not willingly restrict my freedoms or recommend this to anyone.


Wat?
This is for if/when people decide to sell scripts and stop people from running multiple/sharing scripts.

Kyle Undefined

2012-01-10 18:35:14

This is more of a working test method, it works based on script name. However, if this was to be used for script authing, it would use an ID/Pass combo and still use the same methods.

Flight

2012-01-10 19:36:16

I can see where it's going, and this pretty much proves it can be done. I like it, Kyle.

Markus

2012-01-11 06:03:19

Uhm, if you actually want to restrict people from using multiple scripts, just modify SRL stats so it only allows one token per user, and terminate the script if it is expired. As stats get checked in every 5 minutes, that should do.
OnTerminateScript is unreliable, one access violation and you are stuck with a running script forever.

Kyle Undefined

2012-01-11 09:33:13

Markus, I've updated the first post. I realize I didn't put why I actually posted this. Sorry for the confusion everyone.