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