Log in

View Full Version : Problem with a script.



Orrealis
11-06-2009, 04:26 PM
Hello, this is my first thread, so i dont know if i made wrong or right : p but yeah yeah, as my title says, i got a problem with a script i tried ( akwardsaws multipower cutter v 3.1 scar )(SMART).
i think i will make wrong upload it, but here it is :



program New;
{.include SRL/SRL/Misc/Smart.scar}
{.Include SRL/SRL.scar}
{.include srl/srl/misc/Reports.scar}
{.include srl/srl/misc/FindXP.scar}

{List of trees: Normal Teak
Oak Mahogony
Willow Yew
Maple Magic
}


var
sendto, SRLname: string;
wanttoemail: boolean;
debug, H_Ver: TBooleanArray;
Max_Cut_Time : integer;

Stats_UserID, Stats_Password: string;

procedure LoadVars;
begin
//stats setup
Stats_UserID:= '';
Stats_Password:= '';

//debug setup
SetArrayLength(debug, 4);
debug[0]:= true;//if want to debug
debug[1]:= false;//if want to writeln debug
debug[2]:= false;//if want to alert debug
debug[3]:= true;//if want to status debug

//email setup
wanttoemail:= true; //True = You want to e-mail a progress report to be sent to you
SRLname:= ''//your SRL user name. leave blank if you want it to be anonymous
//the name helps me know who actually used the script, and your name will
//be on my thread :D
sendto:= ''; //Your E-Mail Address, if you want to get e-mailed

//script setup
SetArrayLength(H_Ver, 2);
H_Ver[0]:= false;//check version
H_Ver[1]:= false;//check news
Max_Cut_Time := 1000 * 60;//max tree cutting time in miliseconds
end;

procedure DeclarePlayers;
begin

HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

writeln('Declaring Players');

with Players[0] do
begin
Name := 'Username';
Pass := 'Password';
Nick := 'Nickname';
Active := True;
Integers[0] := 000; //loads to do
Booleans[0] := false; //false = hatchet is weilded!!!!!!
Strings[0] := 'willow'; //name of the tree
BoxRewards := ['XP'];
end;
end;


procedure prog; forward;
procedure AntiBan; forward;

//my custom debug procedure
procedure A_Debug(text: string);
begin
if not debug[0] then exit;
if debug[1] then
writeln('[' + thetime + '] ' + players[currentplayer].name + ' ' + text);
if debug[2] then
alert('[' + thetime + '] ' + players[currentplayer].name + ' ' + text);
if debug[3] then
status('[' + thetime + '] ' + players[currentplayer].name + ' ' + text);
end;

//checks the version of script
function A_GetVersion(site, ver: string): boolean;
var Version: string;
begin
Version:= GetPage(site);
if Ver = Version then result := true;
end;

//gets the news for this script
procedure A_NewsFlash(site : string);
var
News : string;
begin
News:= GetPage('http://akwardversions.webs.com/PowerChopperNews.txt');
writeln(' ');
WriteLn(News);
Wait(10000);
writeln(' ');
end;
var k : integer;
//custom Object Finder
function A_FindObj(color, tol : integer; uptext : string; left : boolean): boolean;
var
T : tpointarray;
i, x, y, d: integer;
time : integer;
FindThis : boolean;
begin
result:= true;
d:= 0;
if not loggedin then loginplayer;
ColorToleranceSpeed(3);
time := 0;
marktime(time);
while not FindThis do
begin
for i:= 1 to tol do
begin
if FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol) then
break;
end;
k := length(t);
FindThis := k > 0; //thanks to noidea :)
if timefrommark(time) > 5000 then break;
end;
ColorToleranceSpeed(1);
if Length(T) = 0 then
begin
A_Debug('color not found');
result:= false;
exit;
end;
for i:= 0 to high(t) do
begin
mmouse(T[i].X, T[i].Y, 0, 0);
if isuptext(uptext) then
begin
getmousepos(x, y);
mouse(x, y, 0, 0, left);
A_Debug('clicked tree');
if invfull then exit;
wait(100 + random(2000));
break;
end;
end;
if not result then
begin
A_Debug('Something has gone wrong');
players[currentplayer].active := false;
end;
end;

const
Stats_Link = 'http://scriptmanager.freehostia.com/submit.php';

var
Stats_LastTime: Integer;
Stats_ScriptID: string;
Stats_CustomVars: array [1..20] of Integer;

procedure Stats_CheckOutput(s: string);
var
i: Integer;
sa: TStringArray;
begin
sa := Explode(#10, s);
for i := 0 to High(sa) do
if (Trim(sa[i]) <> '') then
if StartsWith('ERROR(1)', sa[i]) then
begin
WriteLn('STATS: "' + sa[i] + '"');
end
else if StartsWith('ERROR(2)', sa[i]) then
begin
WriteLn('STATS: "' + sa[i] + '"');
Stats_ScriptID := '5';
end
else
WriteLn('STATS: "' + sa[i] + '"');

end;

function Stats_GetScriptInfo(out Version, News, Link: string; out OutDated: Boolean; out LastUpdate_HoursAgo: Integer): 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) = 5) then
begin
Result := True;
Version := sa[0];
News := sa[1];
Link := sa[2];
OutDated := sa[3] = '1';
LastUpdate_HoursAgo := StrToIntDef(sa[4], -1);
end
else
Stats_CheckOutput(s);

FreeHTTPClient(Client );
end;

var
Stats_GlobalVars: array[1..24] 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;
if (Time < 5) then
Time := 0
else
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 := Low(Stats_GlobalVars) to High(Stats_GlobalVars) 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;

s := PostHTTPPageEx(Client, Stats_Link);
Stats_CheckOutput(s);
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));
Stats_CheckOutput(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
else
begin
Stats_CheckOutput(s);
Break;
end;
end;

FreeHTTPClient(Client);
stats_SendAccountInfo;
end;

//my own NextPlayer procedure
procedure NextPlayerP;
begin
LogOut;
prog;
NextPlayer(Players[(CurrentPlayer + 1)].Active);
end;

//moves the mouse, and moves it back to around the same position
procedure A_ChangeMindMMouse(x, y, rx, ry: integer);
var a, b: integer;
begin
getmousepos(a, b);
mmouse(x, y, rx, ry);
wait(100 + random(1000));
mmouse(a, b, 20, 20);
end;

//anti ban
procedure AntiBan;
begin
A_Debug('anti ban - start');
if LevelUp then inc(players[currentplayer].integers[5]);
FindNormalRandoms;
case random(32) of
0: Gametab(1+random(13));
1: wait(1000 + random(3000));
2: A_ChangeMindMMouse(random(500), random(500), 20, 20);
4: RandomMovement;
5: HoverSkill('woodcutting', false);
6: RandomRClick;
7: ExamineInv;
end;
A_Debug('anti ban - finished 1');
gametab(tab_inv);
A_Debug('anti ban - finished 2');
makecompass(0);
A_Debug('anti ban - finished 3');
FindNormalRandoms;
A_Debug('anti ban - finished 4');
end;

//Object type
type
TObj = Record
Name: string;
UpText: string;
DTM: integer;
Color: integer;
Tol: integer;
Tile: TPointArray;
ID: TIntegerArray;
end;

var
TA : TObj;

//loads all of the trees info into the TObj type
procedure LoadTrees;
begin
case lowercase(players[currentplayer].strings[0]) of
'normal': with TA do
begin
name := 'normal';
uptext := 'ree';
color := 4094573;
tol := 4;
end;

'oak': with TA do
begin
name := 'oak';
uptext := 'Oak';
color := 5739656;
tol := 4;
end;

'willow': with TA do
begin
name := 'willow';
uptext := 'illow';
color := 4282446;
tol := 4;
end;

'maple': with TA do
begin
name := 'maple';
uptext := 'aple';
color := 3956883;
tol := 4;
end;
'teak': with TA do
begin
name := 'teak';
uptext := 'eak';
color := 5410940;
tol := 4;
end;
'mahogany': with TA do
begin
name := 'mahogany';
uptext := 'ahogany';
color := 1525307;
tol := 4;
end;
'yew': with TA do
begin
name := 'yew';
uptext := 'ew';
color := 1259054;
tol := 4;
end;
'magic':with TA do
begin
name := 'magic';
uptext := 'agic';
color := 12836577;
tol := 4;
end;
end;
end;

function findax:boolean;
var
i, a: integer;
tpa: TPointArray;
c: TIntegerArray;
begin
colortolerancespeed(3);
c := [5064763, 593214, 5261885, 869985];
for i:= 0 to high(c) do
if findcolorstolerance(tpa, c[i], mscx - 40, mscy - 40, mscx + 40, mscy + 40, 5) then
inc(a);
result := (a > 0);
colortolerancespeed(1);
end;

//chops the tree, repeats untill inv is full or cant find a tree
Function ChopTree(uptext: string; color : integer) : boolean;
begin
A_Debug('started ChopTree proc');
repeat
A_Debug('starting to chop');
result:= A_FindObj(color, 7, uptext, true);
A_Debug('waiting');
antiban;
while findax do
begin
antiban;
if invfull then break;
end;
A_Debug('done chopping');
if invfull then break;
until invfull or not result;
A_Debug('ended ChopTree proc');
end;

//loads exp of the trees
function loadexp: extended;
begin
result := FindXP('woodcutting', players[currentplayer].strings[0])
end;

//my own drop all proc
procedure A_dropallex(start : integer);
var i: integer;
begin
for i:= start to 28 do dropitem(i);
end;

//converts a boolean to an integer, true = 1, false = 0
function BoolToInt(B: boolean):integer;
begin
if b then result:= 1;
end;

//drops the logs, handles Prog variables
procedure DropLogs;
var i: integer; exp: extended;
begin
if not loggedin then exit;
if not invfull then exit;

i:= booltoint(players[CurrentPlayer].booleans[0]);

A_dropallex(1 + i);

incex(players[currentplayer].integers[2], 27 + i);
exp:= (players[currentplayer].integers[2] * loadexp);
players[currentplayer].integers[4]:= round(exp);
inc(players[currentplayer].integers[3]);
Stats_CustomVars[1]:= players[currentplayer].integers[2];
Stats_CustomVars[2]:= players[currentplayer].integers[3];
prog;
end;

//e-mails prog to user
procedure Email(SendTo, Msg, SubjectName, Name: string);
var
Client : integer;
begin
Client := InitializeHTTPClient(True, True);
AddPostVariable(Client, 'email', SendTo); //email to send it to
AddPostVariable(Client, 'message', Msg); //message
AddPostVariable(Client, 'subject', SubjectName); //subject name
AddPostVariable(Client, 'sender', 'phpemail@akwardsaw.hostoi.com'); //senders e-mail
AddPostVariable(Client, 'name', Name); //name of sender
PostHTTPPageEx(Client, 'http://akwardsaw.hostoi.com/email.php'); //website
FreeHTTPClient(Client);
end;

//proggy
procedure prog;
begin
players[currentplayer].level[Skill_WoodCutting] := GetSkillLevel(Skill_WoodCutting);
changereportwidth(10);
SRLPlayerReport(
ResultDebugBox, 0, false,
[True, False, True, False, False, True],
['Logs Chopped', 'Loads Done', 'Exp Gained', 'Levels Increased'],
[], [2, 3, 4, 5], [], []);

Stats_SendReport;
Stats_ManageAccounts;
end;

//re-writes the script if its out dated
procedure A_UpdateScript(website, filename: string);
var
NewScript: String;
scriptFile: Integer;
begin
newScript := GetPage(website);
scriptFile := RewriteFile(filename, True);
WriteFileString(scriptFile, newScript);
CloseFile(scriptFile);
end;

procedure scriptterminate;
var mess: string;
begin
if wanttoemail then
begin
mess:= ('Hello, ' + SRLname + '! This is an e-mailed proggy sent to you from: ' +
'Awkwardsaw''s Multi Power Chopper!' + chr(13) +
'Current Player: ' + players[currentplayer].nick + chr(13) +
'Current Player chopped: ' + inttostr(players[currentplayer].integers[2]) + chr(13) +
'Current Player Gained: ' + inttostr(players[currentplayer].integers[4]) + ' EXP' + chr(13));
Email(SendTo, mess, 'MPC: Progress Report', 'Awkwardsaw');
end;
Email('akwardsaw@yahoo.com', mess, 'MPC: Progress Report', SRLname);

prog;
end;

//sets up the script
procedure AwkSetUp(m, w : integer; s, l: boolean);
begin
if (w > 0) and s then Smart_Server := w;
setupsrl;
mousespeed := m + random(5);
if l then
if not loggedin then loginplayer;
end;

//main loop
procedure MainLoop;
begin
LoadVars;
DeclarePlayers;
if H_Ver[0] then
if not A_GetVersion('http://akwardversions.webs.com/PowerChopperVersion.txt', '3.00') then
if GetApplication.MessageBox('Current Script is outdated! Auto Update script?', 'OUTDATED', 4) = mryes then
A_UpdateScript('http://akwardversions.webs.com/PowerCutterUpdate.txt', scriptpath + 'Akwardsaw''s Multi Power Cutter v3.scar');
if H_Ver[1] then
A_NewsFlash('http://akwardversions.webs.com/PowerChopperNews.txt');
AwkSetUp(7 + random(2), 20, true, true);

activateclient;
LoadTrees;
ChatsOff;
ClickNorth(true);
repeat
repeat
A_Debug('starting cycle');
if not invfull then
if not ChopTree(TA.uptext, TA.color) then break;
A_Debug('inv full');
if invfull then
DropLogs;
A_Debug('inv empty');
until (players[currentplayer].integers[3] = players[currentplayer].integers[0]) or players[currentplayer].active = false;
NextPlayerP;
until allplayersinactive;
end;

begin
MainLoop;
end.

so here it is.
im writing my username,pass,nick,how many logs, and if i got axe wield.
i use to be at draynor village, and it starts to cut once, then it anti ban, and then looks in the inventory, then it just do that all the time untill i stop the script, i am realy bad at english, as you maybe see, but i try to explain all i can, and when im doing the script this comes up in the box lowest down in SCAR :
** Warning in GameTab: Tab 10 is not a valid tab number.**
** Warning in GameTab: Tab 3 is not a valid tab number.**
** Warning in GameTab: Tab 11 is not a valid tab number.**
** Warning in GameTab: Tab 1 is not a valid tab number.**
** Warning in GameTab: Tab 5 is not a valid tab number.**
** Warning in GameTab: Tab 4 is not a valid tab number.**
** Warning in GameTab: Tab 8 is not a valid tab number.**
** Warning in GameTab: Tab 8 is not a valid tab number.**
** Warning in GameTab: Tab 1 is not a valid tab number.**
** Warning in GameTab: Tab 4 is not a valid tab number.**
** Warning in GameTab: Tab 10 is not a valid tab number.**
** Warning in GameTab: Tab 12 is not a valid tab number.**
** Warning in GameTab: Tab 9 is not a valid tab number.**
** Warning in GameTab: Tab 1 is not a valid tab number.**
** Warning in GameTab: Tab 4 is not a valid tab number.**
** Warning in GameTab: Tab 3 is not a valid tab number.**

and many more of these.

i hope i wasn't real bad at explaining my problem, im bad at english, and i hope i made this right doing my first thread, im realy bad at scripts, and just started so dont be to angry on me : )

YoHoJo
11-06-2009, 04:34 PM
1) Post scripts in CODE or SCAR tags so they dont take up so much room
2)If you need help with a script YOU MADE it belongs in the "Scrip Help" section
3)If your having trouble with a SPECIFIC SCRIPT then post it IN THE THREAD WHERE YOU FOUND THE SCRIPT
Good Luck Getting It Working
~YoHoJo