SRL Archive - Help and Support

Feedback needed


Bonfield

2010-09-26 01:27:13

function Deposit_RandomArray(Arr: Array of Integer; UpText: Array of String): Boolean;
var
Arr_Length, Random_Int, x, y: Integer;
Temp_Arr: Array of Integer;
Inv_Slot: TBox;
begin
if BankScreen then
begin
Arr_Length := High(Arr);
SetLength(Temp_Arr, Arr_Length);

while (not InIntArray(Arr, Random_Int)) do
Random_Int:= RandomRange(Low(Temp_Arr), High(Temp_Arr));

writeln('Random_Int is '+IntToStr(Random_Int));

if InIntArray(Arr, Random_Int) then
begin
Inv_Slot := InvBox(Random_Int);
MouseBox(Inv_Slot.X1, Inv_Slot.Y1, Inv_Slot.X2, Inv_Slot.Y2, 3);
GetMousePos(x, y);

if WaitUpTextMulti(UpText, 500 ) then
begin
Mouse(x, y, 0, 0, False);
wait(50 + Random(25));
ChooseOption('All');
Result := True;
end else
writeln('Could not find UpText');
end else
writeln('Random_Int not in Array');
end;
end

can people post feedback please on this please

thanks in advance
Bonfield

lordsaturn

2010-09-26 22:26:27

function Deposit_RandomArray(Arr: Array of Integer; UpText: Array of String): Boolean;
var
Arr_Length, Random_Int, x, y: Integer;
Temp_Arr: Array of Integer;
Inv_Slot: TBox;
begin
if BankScreen then
begin
//Arr_Length := High(Arr); //this isnt the array length. array length is high+1, because high(arr) grabs the highest index of the array
Arr_Length := Length(Arr); //or High(Arr) + 1;
//SetLength(Temp_Arr, Arr_Length); //why does temp_Arr even exist? it isn't being used

Random_Int := -1; //Random_Int is by default zero, so if 0 is in your Arr then it will choose the 0 index every time
while (not InIntArray(Arr, Random_Int)) do
//Random_Int:= RandomRange(Low(Temp_Arr), High(Temp_Arr)); //at this point you know that low is 0 and you have already found the highest index. once again why are you using an array for this?
Random_Int := Random(Arr_Length);

writeln('Random_Int is '+IntToStr(Random_Int));

//if InIntArray(Arr, Random_Int) then //unnecessary, you check for this a couple lines up
begin
Inv_Slot := InvBox(Random_Int);
MouseBox(Inv_Slot.X1, Inv_Slot.Y1, Inv_Slot.X2, Inv_Slot.Y2, 3); //smart use of invbox
GetMousePos(x, y);

if WaitUpTextMulti(UpText, 500 ) then
begin
Mouse(x, y, 0, 0, False);
wait(50 + Random(25));
//ChooseOption('All');
//Result := True; //what if chooseoption fails?
Result := ChooseOption('All');
end else
writeln('Could not find UpText');
end;
//writeln('Random_Int not in Array');
end;
end
also, standards

Bonfield

2010-09-27 03:26:32

thankyou, i know the code is really messy

the point of this is to find items in the inventory, lets say iron ore and these are located in inventory slots 3, 5, 7, 9, 10 and 27 and use a random spot in the array to deposit the items

i did not know High(Arr) + 1; is the length thanks, 0 should never be in the array goes from 1-28, but that is a good thing to know

about Temp_Array i used it in the beginning but i was just passing the array declared in the parameter to it so i decided to get rid of it but i see i didnt really

i never thought of chooseoption failing

thankyou for looking through this


EDIT: what is a better failsafe for chooseoption?
if ChooseOption('All') then
begin
Result := True;
writeln('Successfully banked '+IntToStr(Arr_Length)+' items.');
end else
writeln('ChooseOption failed');

or what you had
Result := ChooseOption('All');

NCDS

2010-09-27 15:14:50

WaitOption adds in a nice failsafe as well ;)

lordsaturn

2010-09-27 17:48:31

From: Bonfield

EDIT: what is a better failsafe for chooseoption?

If you want to debug, use your code. if not, use mine. It's a matter of opinion really. Also if you want a further failsafe incase chooseoption fails sometimes what i like to do is surround the whole function in a counter.

i.e.

function Deposit_RandomArray(Arr: Array of Integer; UpText: Array of String): Boolean;
begin
Counter := 0;
while (not(Result)) and (counter < 5) do
begin
Inc(Counter);
if BankScreen then
begin
//all code here
Result := WaitOption('All', 250); //or whatever the params are
end;
end;
end;
ya dig?

Bonfield

2010-09-28 05:05:32

i get it, i was going to do this in my withdraw function, thats the counter and i will use waitoption, thank you both

BraK

2010-09-28 05:19:22

If you don't like the counter. One thing I tend to do is using time marks.

function Deposit_RandomArray(Arr: Array of Integer; UpText: Array of String): Boolean;
C: integer;
begin
C := GetTimeRunning + 5000;
while (not(Result)) and (GetTimeRunning < C) do
begin
if BankScreen then
begin
//all code here
Result := WaitOption('All', 250); //or whatever the params are
end;
end;
end;

Just looked over it right quick but that should work.

Bonfield

2010-09-28 05:57:21

function Deposit_RandomArray(Arr: array of Integer; UpText: array of string): Boolean;
var
Arr_Length, Random_Int, x, y, Counter: Integer;
Inv_Slot: TBox;
begin
Counter := 0;
while (not (Result)) and (Counter < 5) do
begin
Inc(Counter);
if BankScreen then
begin
Arr_Length := Length(Arr);
SetLength(Arr, Arr_Length);
Random_Int := - 1;
while (not InIntArray(Arr, Random_Int)) do
Random_Int := Random(Arr_Length);
writeln('Random_Int is ' + IntToStr(Random_Int));
begin
Inv_Slot := InvBox(Random_Int);
MouseBox(Inv_Slot.X1, Inv_Slot.Y1, Inv_Slot.X2, Inv_Slot.Y2, 3);
GetMousePos(x, y);
if WaitUpTextMulti(UpText, 500) then
begin
Mouse(x, y, 0, 0, False);
wait(50 + Random(25));
if WaitOption('All', 250) then
begin
Result := True;
writeln('Successfully banked ' + IntToStr(Arr_Length) + ' items.');
end else
writeln('ChooseOption failed');
end else
writeln('Could not find UpText');
end;
end;
end;
end;

thats what i ended up with, i will see what i prefer BraK i like the idea of a max time, i use pretty much the same thing in my banking procedure

BraK

2010-09-28 06:01:07

I like counters and all but the amount of time changes. Due to how many and length of the waits in the counter loops. It's easier to say. I want this to take no longer than this else kill script/Restart mainloop/check for location.

lordsaturn

2010-09-28 10:16:56

How about instead of having Random_Int use Random_Index?

Bonfield

2010-09-29 04:16:29

that is a much better name

here is the whole script im working on, its nearly finished, i think i may have made a simple mistake with how i increased my script totals but i know how to fix and was rushed for time


program Bones_To_Bananas;
{water rune 38 x 2 = 76
earth rune 40 x 2 = 80
nature rune 203 x 1 = 203
bones 193 x 1 = 193
total = 552
with earth staff = 472

bananas 26 x 209 = 5434

}


{$i SRL/SRL.scar}
{$i SRL/SRL/Misc/Stats.scar}
{$i SRL/SRL/Misc/Users.scar}
{$i SRL/SRL/Misc/Reports.scar}
{$i SRL/SRL/Skill/Magic.scar}
{$i SRL/SRL/Misc/Debug.scar}

const
SCRIPTVERSION = '1.00';

YOURSTATSUSERID = '46'; // User UID from scriptmanager.freehostia.com
YOURSTATSPASS = 'jacob'; // Your pass from scriptmanager.freehostia.com

WORLD = 32; // Smart World
MEMBERS = False; // Use Members World
SIGNED = True; // Use Signed applet

TAKE_SCREENSHOT = True; // Take Screenshot on level up.
DEBUG_SCRIPT = True; // Do you want the script to debug.

USE_BREAKS = False; // Do you want to break?
RANDOM_BREAKTIME = 5; // Adds random time to each breaktime eg. + or - 5 minutes.


type
func = procedure();

var
TOT_Spells, TOT_Bananas, TOT_XP_Gained: Integer;
Script_Total: array[0..4] of LongInt;

procedure DeclarePlayers;
begin
HowManyPlayers := 1; // How many players declared?
CurrentPlayer := 0; // Number of player to start with.
NumberOfPlayers(HowManyPlayers);

with Players[0] do
begin
Name := 'aserser'; // Characters full RS username.
Pass := '2narellan'; // Characters RS password.

Integers[0] := 5; // How long before breaking or switching in minutes
Integers[1] := 6; // How long to break for in minutes + or - Random_Breaktime const
Integers[2] := 1; // Bankslot bones are in 1 - 20 please
Strings[0] := 'VWB'; // What bank to use
Active := True;
end;
end;

{<!--------------------------------------------------------------------------!>}
{<!--------------------------- END OF SETUP! -------------------------------!>}
{<!--------------------------------------------------------------------------!>}

const
//PLAYER INTEGERS

TIME_TILL_BREAK = 0;
TIME_TO_BREAK_FOR = 1;
BONE_BANKSLOT = 2;
LEVELS_GAINED = 3;
SPELLS_CASTED = 4;
XP_GAINED = 5;
BANANAS = 6;

//PLAYER STRINGS

WHICH_BANK = 0;

// SCRIPT TOTALS

TOTAL_TIME_RAN = 0;
TOTAL_CASTS = 1;
TOTAL_BANANAS = 2;
TOTAL_XP_GAINED = 3;

// SCRIPT STATS i havent added this yet

STATS_CASTS = 0;
STATS_XP_GAINED = 1;

// SCRIPT CONSTANTS

Y_MOD = 15; // Used in Get_Black_Count to miss numbers
BONE_BLACKCOUNT = 61;
BANANA_BLACKCOUNT = 26;
BANANA_COL = 3118230;
BANANA_TOL = 10;

CAST_X1 = 641; // A TBox of Bones to Bananas spell
CAST_Y1 = 248;
CAST_X2 = 654;
CAST_Y2 = 262;
{*******************************************************************************
procedure Debug(x :string);
Description: Debugs the script if Debug_Script is true
*******************************************************************************}
procedure Debug(x :string);
begin
if (not DEBUG_SCRIPT) then exit;
writeln(x);
end;

{*******************************************************************************
procedure DeactivatePlayer(PlayerNum: Byte; Reason: string);
By: SRL Template
*******************************************************************************}
procedure DeactivatePlayer(PlayerNum: Integer; Reason: string);
begin
LogOut;
Players[PlayerNum].Loc := Reason;
Players[PlayerNum].Active := False;
srl_Warn('Player ' + IntToStr(PlayerNum) + ' (' +Players[PlayerNum].Nick + ')', 'deactivated -- ' + Reason, warn_Debug);
end;

{*******************************************************************************
function Convert_To_Time(BreakTime: integer): string;
By: Bonfield
Description: Gets the current time and adds BreakTime in ms and dispays that time.
eg. Taking a break at 06:21:43 PM
Breaking for 10 minutes (10 * 60000)
Returning at 06:31:43 PM
*******************************************************************************}
function Convert_To_Time(BreakTime: integer): string;
var
Time, PA: string;
Hours, hh, Minutes, mm, Seconds, ss, Total_Ms : integer;
begin
Time := TheTime;

hh:= StrToInt(Time[1]) * 10 + StrToInt(Time[2]);
mm:= StrToInt(Time[4]) * 10 + StrToInt(Time[5]);
ss:= StrToInt(Time[7]) * 10 + StrToInt(Time[8]);
PA:= time[10]+time[11];

Hours:= (Hh * 3600000);
Minutes:= (Mm * 60000);
Seconds:= (Ss * 1000);
Total_Ms:= Hours + Minutes + Seconds + BreakTime

Result:= MsToTime(Total_Ms,3)+' '+PA;
end;

{*******************************************************************************
function function Take_Break: Integer;
By: Bonfield
Description: Break or switches players depending on howmanyplayers.
*******************************************************************************}
function Take_Break: Integer;
var
Break_Time: Integer;
begin
if (USE_BREAKS) then
begin
if ((GetTimeRunning mod (Players[CurrentPlayer].Integers[TIME_TILL_BREAK] * 60000)) = 0) then
begin
Players[CurrentPlayer].Loc := 'Breaking.';
Result := Players[CurrentPlayer].Integers[TIME_TO_BREAK_FOR];
Logout;
writeln(TheTime);
if (HowManyPlayers > 1) then
begin
NextPlayer(True);
end else
begin
writeln('Taking a break at ' + TheTime);
Break_Time := (Result * 60000) + (RandomRange( - RANDOM_BREAKTIME, + RANDOM_BREAKTIME) * 60000);
writeln('Breaking for ' + IntToStr(Break_Time / 60000) + ' minutes');
writeln('Returning at ' + Convert_To_Time(Break_Time));
wait(Break_Time);
LoginPlayer;
end;
end;
end;
end;

{*******************************************************************************
function Level_Up: Boolean;
By: Bonfield
Description: Checks for Level up message and takes screenshot
*******************************************************************************}
function Level_Up: Boolean;
begin
Result := FindNPCChatText('ongratulations', Nothing);
if (not Result) then Exit;

if (TAKE_SCREENSHOT) then
TakeScreenshotEx(AppPath + '\Scripts\Screenshots\', MSX1, MSY1, MSX2, MSY2);

Inc(Players[CurrentPlayer].Level[SKILL_MAGIC]);
Debug(Players[CurrentPlayer].Name + ' now has ' + ToStr(Players[CurrentPlayer].Level[SKILL_MAGIC]) + 'magic');
Inc(Players[CurrentPlayer].Integers[LEVELS_GAINED]);
end;

{*******************************************************************************
function Check_Magic: boolean;
By: Bonfield
Description: Checks that player can cast Bones To Bananas
and the magic level is greater than 15
*******************************************************************************}
function Check_Equipment: Boolean;
var
Spell_Box: TBox;
begin
if (not LoggedIn) then Exit;
if (Players[CurrentPlayer].Level[SKILL_MAGIC] >= 15) then
begin
Players[CurrentPlayer].Loc := 'Check Equipment';
Gametab(tab_Magic);
wait(50);
if (SpellAvailable(Spell_Box, 'bones to bananas')) then
begin
Result := True;
Writeln('Have runes for Bones To Bananas.');
Exit;
end else
begin
Writeln('Not enough runes to cast Bones To Bananas.');
DeactivatePlayer(CurrentPlayer, 'Not enough Runes.');
end;
end else
begin
Writeln('Player['+IntToStr(CurrentPlayer)+']''s magic level is less than 15');
DeactivatePlayer(CurrentPlayer, 'Magic level low.');
end;
end;

{*******************************************************************************
function In_Bank: Boolean;
By: Bonfield
Description: Checks to see is a player is in the bank
*******************************************************************************}
function In_Bank: Boolean;
var
bx, by, ColFace, ColGrey, ColBlue: Integer;
begin
ColFace := 7774419; // Face Color
ColGrey := 6381925; // Grey Color [ Clothes ]
ColBlue := 2429979; // Blue Color [ Clothes ]

Result := (FindSymbol(bx, by,'bank') or FindObjThroughMM(bx, by, 'npc', [ColFace, ColBlue, ColGrey], [5, 5, 5],
['anke', 'to B', 'Banker', 'nker'], 2, 2));
if (not Result) then
begin
srl_Warn('In_Bank', 'Player['+IntToStr(CurrentPlayer)+'] not in bank.' , 0);
DeactivatePlayer(CurrentPlayer,'Not In Bank');
end;
end;

{
function Open_Bank(Bank: String): Boolean; // really ugly code.....
var
Max_Time: Integer;
begin
//Max_Time := GetSystemTime + (100 * 1000);
Result := True;

if not (OpenBankFast(Bank)) then
if not (OpenBankGlass(Bank, False, False)) then
if not (OpenBank(Bank, False, False)) then
if not (OpenBankNPC) then
if not (OpenBankQuiet(Bank)) then Result := False;

{ if (Max_Time >= GetSystemTime) then
begin
writeln('Open_Bank took longer than 100 seconds');
DeactivatePlayer(CurrentPlayer,'Could not open bank');
end;
end;
}


{*******************************************************************************
function Get_Black_Count(Slot, DivideBy: Integer; Bank: Boolean): Integer;
By: Bonfield
Description: Counts number of black pixels in bankslot
*******************************************************************************}
function Get_Black_Count(Slot, Color: Integer; Bank: Boolean): Integer;
var
b: TBox;
begin
Result := 0;
if Bank then
b := BankIndexToMSBox(Slot)
else
b := InvBox(Slot);
Result := CountColor(Color, b.X1, b.Y1 + Y_MOD, b.X2, b.Y2);
end;

{*******************************************************************************
function Open_Bank(Bank: string): boolean;
By: Bonfield
Description: Opens the Bank
*******************************************************************************}
function Open_Bank(Bank: string): boolean;
begin
Result := True;

if not (OpenBankFast(Bank)) then
if not (OpenBankGlass(Bank, False, False)) then
if not (OpenBank(Bank, False, False)) then
if not (OpenBankNPC) then
if not (OpenBankQuiet(Bank)) then
Result := False
end;

{*******************************************************************************
function Count_Items(Count, Start_Slot, Finish_Slot: Integer; out Slots: array of Integer): Integer;
By: Bonfield and alot if help from Dans the Man
Description: Counts how many items in the inventory based on black pixel count
*******************************************************************************}
function Count_Items(Count, Start_Slot, Finish_Slot: Integer; out Slots: array of Integer): Integer;
var
i: Integer;
begin
SetLength(Slots, 28);
Result := 0;
GameTab(tab_Inv);

for i := Start_Slot to Finish_Slot do
if(Get_Black_Count(i, SRL_OUTLINE_BLACK, False) = Count) then
begin
Inc(Result);
Slots[Result - 1] := i;
end;

SetLength(Slots, Result);
end;

{*******************************************************************************
procedure OutputArray(const Arr: TIntegerArray);
By: Dans The Man
Description: SWrites an array like this [0, 2, 5]
*******************************************************************************}
procedure OutputArray(const Arr: TIntegerArray; Write: string);
var
I, ArrLength: Integer;
S: string;
begin
ArrLength := High(Arr);
S := ' ' + Write + ' := [';

for I := 0 to ArrLength do
S := S + IntToStr(Arr[I]) + ', ';

Delete(S, Length(S) - 1, Length(S));
S := S + '];';
Writeln(S);
end;


{*******************************************************************************
function Deposit_RandomArray(Arr: Array of Integer: UpText: Array of String): Boolean;
By: Bonfield with help from lord saturn
Description: Deposits random spot in the array
*******************************************************************************}
function Deposit_RandomArray(Arr: array of Integer; UpText: array of string): Boolean;
var
Arr_Length, Random_Index, x, y, Counter: Integer;
Inv_Slot: TBox;
begin
Counter := 0;
while (not (Result)) and (Counter < 5) do
begin
Inc(Counter);
if BankScreen then
begin
Arr_Length := Length(Arr);
SetLength(Arr, Arr_Length);
Random_Index := - 1;

while (not InIntArray(Arr, Random_Index)) do
Random_Index := Random(Arr_Length);
writeln('Random_Index is ' + IntToStr(Random_Index));
begin
Inv_Slot := InvBox(Random_Index);
MouseBox(Inv_Slot.X1, Inv_Slot.Y1, Inv_Slot.X2, Inv_Slot.Y2, 3);
GetMousePos(x, y);
if WaitUpTextMulti(UpText, 500) then
begin
Mouse(x, y, 0, 0, False);
wait(50 + Random(25));
if WaitOption('All', 250) then
begin
Result := True;
writeln('Successfully banked ' + IntToStr(Arr_Length) + ' items.');
end else
writeln('ChooseOption failed');
end else
writeln('Could not find UpText');
end;
end else
writeln('BankScreen false');
end;
end;

{*******************************************************************************
function Deposit_Bananas: Boolean;
By: Bonfield
Description: Deposits bananas to bank
*******************************************************************************}
function Deposit_Bananas: Boolean;
var
Item_Count, Black_Count, Banana_Slot: Integer;
SlotsIn: array of Integer;
begin
if (not LoggedIn) then Exit;
if (not In_Bank) then Exit;

Open_Bank(Players[CurrentPlayer].Strings[WHICH_BANK]);
WaitFunc(@ BankScreen, 10 + Random(15), 750);

Item_Count := Count_Items(BANANA_BLACKCOUNT, 1, 28, SlotsIn);
writeln('Item_Count is ' + IntToStr(Item_Count) + '.');

Black_Count := Get_Black_Count(Banana_Slot, srl_outline_black, False);
writeln('Black count is ' + IntToStr(Black_Count) + '.');

if (Item_Count > 0) then
begin
Writeln('There are ' + IntToStr(Item_Count) + ' items with ' + IntToStr(BANANA_BLACKCOUNT) + ' black pixels in inventory slots 1 to 28');
Writeln('These items were located in:');
OutputArray(SlotsIn, 'Bananas in');
Deposit_RandomArray(SlotsIn, ['Deposit-1', 't-1 Banana', 'anana']);
Result := True;
writeln('Banked ' + IntToStr(Item_Count) + ' Bananas.')

IncEx((Players[CurrentPlayer].Integers[BANANAS]), Item_Count);
IncEx(Script_Total[TOTAL_BANANAS], Item_Count);
WriteINI('Script_Total', IntToStr(TOTAL_BANANAS), IntToStr(Script_Total[TOTAL_BANANAS]), ScriptPath + 'ScriptStats.INI');

Exit;
end else
writeln('Item_Count = 0 no Banannas in inventory');
end;

{*******************************************************************************
function Withdraw_Bones: Boolean;
By: Bonfield
Description: Withdraws bones from bank
*******************************************************************************}
function Withdraw_Bones: Boolean;
var
Index: TPoint;
Bank_Slot: TBox;
Black_Count: Integer;
SlotsIn: Array of Integer;
begin
if (not LoggedIn) then Exit;
if (not In_Bank) then Exit;
if (Count_Items(BANANA_BLACKCOUNT, 1, 28, SlotsIn) > 0) then Deposit_Bananas;

Open_Bank(Players[CurrentPlayer].Strings[WHICH_BANK]);
WaitFunc(@ BankScreen, 10 + Random(15), 750);
Black_Count := Get_Black_Count(Players[CurrentPlayer].Integers[BONE_BANKSLOT], SRL_OUTLINE_BLACK, True);
writeln('Black count is ' + IntToStr(Black_Count) + '.');

if (Black_Count = BONE_BLACKCOUNT) then
begin
Index := BankIndexToBankPoint(Players[CurrentPlayer].Integers[BONE_BANKSLOT]);
writeln('Index X is ' + IntToStr(Index.X));
writeln('Index Y is ' + IntToStr(Index.Y));
Bank_Slot := BankIndexToMSBox(Players[CurrentPlayer].Integers[BONE_BANKSLOT]);
MouseBox(Bank_Slot.X1, Bank_Slot.Y1, Bank_Slot.X2, Bank_Slot.Y2, 3);

if WaitUpTextMulti(['Withdraw-1', 'w-1 Bone', 'one'], 500) then
begin
Result := True;
Withdraw(Index.X, Index.Y, 0);
writeln('Withdrew Bones');
CloseBank;
Exit;
end else
Result := False;
writeln('WithdrawEx failed CountColor was correct but uptext wasnt');
DeactivatePlayer(CurrentPlayer, 'WithdrawEx failed.');
end else
begin
Result := False;
writeln('Item in Bankspot ' + inttostr(Players[CurrentPlayer].Integers[BONE_BANKSLOT]) + ' Blacklist number wrong');
DeactivatePlayer(CurrentPlayer, 'Could not find bones.');
end;
end;

{*******************************************************************************
function Out_Of_Runes : Boolean;
By: Bonfield
Description: Looks for chat message to show there are not enough runes to
cast a spell
*******************************************************************************}
function Out_Of_Runes: Boolean;
begin
Result := Pos('runes', GetChatBoxText(8, clBlack)) > 0;
if (not Result) then Exit;
writeln('Player['+IntToStr(CurrentPlayer)+'] is out of runes.');
DeactivatePlayer(CurrentPlayer,'Out of Runes.');
end;

{*******************************************************************************
procedure Cast_Bones_To_Bananas;
By: Bonfield
Description: Casts Bones To Bananas spell
*******************************************************************************}
procedure Cast_Bones_To_Bananas;
begin
if (not LoggedIn) then Exit;

GameTab(tab_Magic);
//Cast('bones to bananas', False);
mousebox(CAST_X1, CAST_Y1, CAST_X2, CAST_Y2, 1);
wait(1000 + random(250));
FindNonInventoryRandoms;
Level_Up;

Inc((Players[CurrentPlayer].Integers[SPELLS_CASTED]));
IncEx((Players[CurrentPlayer].Integers[XP_GAINED]), (Players[CurrentPlayer].Integers[SPELLS_CASTED] * 25));

Inc(Script_Total[TOTAL_CASTS]);
WriteINI('Script_Total', IntToStr(TOTAL_CASTS), IntToStr(Script_Total[TOTAL_CASTS]), ScriptPath + 'ScriptStats.INI');
IncEx(Script_Total[TOTAL_XP_GAINED], 25);
WriteINI('Script_Total', IntToStr(TOTAL_XP_GAINED), IntToStr(Script_Total[TOTAL_XP_GAINED]), ScriptPath + 'ScriptStats.INI');
end;

{*******************************************************************************
procedure Script_Totals;
By: Bonfield
Description: Displays the totals for the script user.
*******************************************************************************}
procedure Script_Totals;
var
i : Integer;
begin
for i := 0 to 4 do
Script_Total[i] := StrToIntDef(ReadINI('Script_Total', IntToStr(i), ScriptPath + 'ScriptStats.INI'), 0);

Writeln(' Total Time Ran : ' + MsToTime(Script_Total[TOTAL_TIME_RAN], Time_Formal));
Writeln(' Total Casts : ' + IntToStr(Script_Total[TOTAL_CASTS]));
Writeln(' Total Bananas : ' + IntToStr(Script_Total[TOTAL_BANANAS]));
Writeln(' Total XP Gained : ' + IntToStr(Script_Total[TOTAL_XP_GAINED]));
end;

{*******************************************************************************
function SRLProgressReport(
ResultType:integer; ScriptName, ScriptAuthor, ScriptVersion: String;
VarNames: TStringArray;
VarValues: TVariantArray
): Variant;
By: Rasta Magician
Description: Prints a Standardized Progress Report, with the variables of your choice
*******************************************************************************}
procedure Progress_Report;
var
XP_per_Hour: Integer;
begin
TOT_XP_Gained := (TOT_Spells * 25);
XP_per_Hour := Round(TOT_XP_Gained / (GetTimeRunning / 3600000.0));

IncEx(Script_Total[TOTAL_TIME_RAN], GetTimeRunning);
WriteINI('Script_Total', '0', IntToStr(Script_Total[TOTAL_TIME_RAN]), ScriptPath + 'ScriptStats.INI')

SRLProgressReport(
ResultDebugBox, 'Bones To Bananas', 'Bonfield', SCRIPTVERSION,
['Time Running','Spells Casted', 'Bananas Made','XP Gained', 'XP per hour'],
[TimeRunning, TOT_Spells, TOT_Bananas, TOT_XP_Gained, XP_per_Hour ]
);

SRLPlayerReport(
ResultDebugBox, 6, False,
[True, False, True, True, False, False],
['Spells Casted', 'Bananas Made', 'XP Gained', 'Levels Gained'],
[], [SPELLS_CASTED ,BANANAS ,XP_GAINED ,LEVELS_GAINED], [], []
);

end;

{*******************************************************************************
procedure Script_Terminate;
By: Bonfield
Description: Displays Progress Report and saves upon the end of the script
*******************************************************************************}
procedure Script_Terminate;
begin
writeln('[Report]');
Progress_Report;
writeln('');
writeln('Thanks for using my script');
writeln('Please post proggies on forums');
writeln('[/Report]');
end;

{*******************************************************************************
procedure Setup_Script;
By: Bonfield
Description: Sets the script up
*******************************************************************************}
procedure Setup_Script;
begin
if (not DirectoryExists(AppPath+'\Scripts\Screenshots')) then CreateDirectory(AppPath+'\Scripts\Screenshots');
Debug('Script Starting up.');

{ Smart_Server := WORLD;
Smart_Members:= MEMBERS;
Smart_Signed := SIGNED;
Smart_SuperDetail := False; }

SetUpSRL;

Stats_ScriptID := '';
Stats_UserID := YOURSTATSUSERID;
Stats_Password := YOURSTATSPASS;


Stats_SendReport;
Stats_ManageAccounts;

DeclarePlayers;

Script_Totals;
// AddOnTerminate('Script_Terminate');
ActivateClient;
end;

{*******************************************************************************
procedure Setup_Player;
By: Bonfield
Description: Sets up each player
*******************************************************************************}
procedure Setup_Player;
begin
Debug('Setting up Player['+IntToStr(CurrentPlayer)+'].');
LogInPlayer;
FindNormalRandoms;
if (not LoggedIn) then Exit;;

GetAllLevels;

SetAllChats('All', 'off', 'on', 'off', 'off', 'off');

//Check_Equipment; SpellAvailable fails
end;

procedure Main_Loop;
begin
Setup_Script;
repeat
Setup_Player;
repeat
Withdraw_Bones
Cast_Bones_To_Bananas;
Out_Of_Runes;
Deposit_Bananas
if ((GetTimeRunning mod (10 * 60000)) = 0) then Progress_Report;
//Antiban; Need to make a simple antiban
Take_Break;
until (not LoggedIn);
until(AllPlayersInactive);
end;

begin
Main_Loop;
end.

it still needs some more organization, but i thought i would start to test itand it work fine for about 20 minutes but in my withdraw procedure it gets hung on a few items in my bank, fire talisman, chaos rune and i can not see why

any thoughts on this script? i didnt think so much would go into a script that casts bones to bananas, i suppose i havent really coded in a while and the last script i spent some time is up to the exact same stage but i dont think i want to finish it

EDIT: I added a max time of 5 minutes to procedures like withdraw bones, deposit bananas and my casting procedure, that should prevent any account being stuck searching for anything, but it doesnt really fix the problem

BraK

2010-09-29 05:07:22

From: Bonfield
that is a much better name

here is the whole script im working on, its nearly finished, i think i may have made a simple mistake with how i increased my script totals but i know how to fix and was rushed for time

it still needs some more organization, but i thought i would start to test itand it work fine for about 20 minutes but in my withdraw procedure it gets hung on a few items in my bank, fire talisman, chaos rune and i can not see why

any thoughts on this script? i didnt think so much would go into a script that casts bones to bananas, i suppose i havent really coded in a while and the last script i spent some time is up to the exact same stage but i dont think i want to finish it

EDIT: I added a max time of 5 minutes to procedures like withdraw bones, deposit bananas and my casting procedure, that should prevent any account being stuck searching for anything, but it doesnt really fix the problem


5 minutes for a withdraw procedure is a bit much. I'd take it down to about a minute and a half at most for withdarwing items. Your character would logout before 5 minutes is past and it'd look botty for a few minutes. I'll look through your code when I get home.

Bonfield

2010-09-29 05:49:06

good point, i chose 5 minutes because it should well and truly finish in that time

the player wouldnt be forced to logout, because where it gets stuck atm it moves the mouse, so the max_time of 5 minutes prevents a possible endless loop i have included in this script