SRL Archive - Help and Support

Small help


Infantry001

2007-04-21 21:26:14

ALright, i made a new script, as i need to do something for hte community (i have been focusing too much on my InfMiner ;))

It works great, except for one problem… My players always switch as false! ill post the script below. Can anyone help me?

//-----------------------------------------------------------------------\\
// The DesertFlame Smelter by: \\
// Infantry001 \\
//***********************************************************************\\
{ The DesertFlame Smelter 1.0
DESCRIPTION: Smiths ores and banks in Al-Kharid.
SETUP: Start in Al-Kharid Bank, and have ores in top of bank.
DIRECTIONS: Set 'skill' to which bar to smelt, and 'Loc' to either
'Furnace' or 'Bank' (MUST be capital). Set 'String1' to your
pin number (if any).
NOTES:
BUGS: Players will go false for no reason, sometimes (rare)
misses the bankersDTM and goes for a different dot (no clue
why).
NEXT VERSION: Make better banking procedure, smooth out procdures,
create better and more random walking.
Contact me at: [email]kkeyl@hotmail.com[/email]
Enjoy! }

program AlKharidSmither;

{.include SRL\SRL.scar}
{.include SRL\SRL\skill\smithing.scar}

const
TimeLoggedIn = 800; //Time to stay logged in in seconds
//Script WILL add a random time
DoDebug = 4; //Change from 1-4 (Look below for details)
Version = '1.0'; //Don't touch this

type
iAmt = record
Exp,Needed,Made : extended;
end;

var
Bar : iAmt;
PMark,LTime : integer;
TheBmp,TheBmp2 : integer;
LvlsGained,BarsMade,ExpGained,LoadsDone : integer;

Procedure InfDebug(reason:string);
begin
Case DoDebug of
1: Status(Reason);
2: Writeln(Reason);
3: DisguiseScar(Reason);
4: begin
Status(Reason);
Writeln(Reason);
DisguiseScar(Reason);
end;
end;
end;

Procedure PlayerStats;

var A: string;
var i : integer;
begin
if Players[CurrentPlayer].Active then
A:='True'
else
A:='False';
writeln('<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>');
writeln('Name : '+ Players[CurrentPlayer].Name);
writeln('Number : '+ inttostr(CurrentPlayer));
writeln('Active : '+ A);
writeln('Location : '+ Players[CurrentPlayer].loc);
writeln('Smithing Level : '+ inttostr(Players[CurrentPlayer].Level[16]));
writeln('Bars Made : '+ floattostr(Players[CurrentPlayer].Integer1));
writeln('Loads Done : '+ floattostr(Players[CurrentPlayer].Integer2));
writeln('Worked for : '+ inttostr(Players[i].Worked)+' minutes.');
if(Players[CurrentPlayer].Banked > 0) then
writeln('Banked : '+ inttostr(Players[CurrentPlayer].Banked) + ' times.');
writeln('<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>');

for i := 0 to HowManyPlayers-1 do
begin
if Players[i].Active=True then A:='True' else A:='False';
writeln( (inttostr(i))+' : '+Players[i].name+ ' = '+A
+'. - Lvl: '+inttostr(Players[i].Level[16])
+'. - W: '+intToStr(Players[i].Worked)+' mins.'
+' - Bars: '+floatToStr(Players[i].Integer1)
+'. - Loads: '+floatToStr(Players[i].Integer2)
+'. - Loc: '+Players[i].loc);
end
writeln('**********************************************');
end;

Procedure ScriptBy;
begin
Writeln(' ________ __ ');
Writeln(' \______ \ ____ ______ ____________/ |_ ');
Writeln(' | | \_/ __ \ / ___// __ \_ __ \ __\');
Writeln(' | ` \ ___/ \___ \\ ___/| | \/| | ');
Writeln(' /_______ /\___ >____ >\___ >__| |__| ');
Writeln(' \/ \/ \/ \/ ');
Writeln(' ___________.__ ');
Writeln(' \_ _____/| | _____ _____ ____ ');
Writeln(' | __) | | \__ \ / \_/ __ \ ');
Writeln(' | \ | |__/ __ \| Y Y \ ___/ ');
Writeln(' \___ / |____(____ /__|_| /\___ > ');
Writeln(' \/ \/ \/ \/ ');
Writeln(' by: ');
Writeln(' _ _ _ ____ ____ _ _ ___ ____ _ _ ');
Writeln(' | |\ | |___ |__| |\ | | |__/ \_/ 0 0 1 ');
Writeln(' | | \| | | | | \| | | \ | ');
end;

Procedure ProgRep;
var
barRate,lRate : extended;
secs,bph,lph : integer;
begin
secs := (GetSystemTime - ST) div 1000;
if BarsMade > 0 then
begin
barrate := (BarsMade / secs) * 3600;
bph := Round(BarRate);
end;
if loadsDone > 0 then
begin
lrate := (loadsDone / secs) * 3600;
lph := Round(lrate);
end;
ScriptBy;
Writeln('<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>');
Writeln('| DesertFlame ' + Version + ' Progress Report');
Writeln('|Script has been running for ' +TimeRunning + '.');
if LvlsGained > 0 then
Writeln('|Gained a total of '+IntToStr(LvlsGained)+' levels!');
if ExpGained > 0 then
Writeln('|Gained a total of '+IntToStr(ExpGained)+' exp!');
Writeln('|The DesertFlame has gotten '+IntToStr(BarsMade)+' bars in all.');
Writeln('|The DesertFlame has done '+IntToStr(LoadsDone)+' loads in all.');
Writeln('|We are averaging '+IntToStr(bph)+' bars per hour!');
Writeln('|We are averaging '+IntToStr(lph)+' loads per hour!');
PlayerStats;
SRLRandomsReport;
end;

Procedure SetBars;
begin
InfDebug('Setting Bar Info');
Case lowercase(Players[CurrentPlayer].Skill) of
'bronze' : begin TheBmp := BronzeBar; TheBmp2 := copperore; Bar.Exp := 6.5; Bar.Needed := 28; Bar.Made := 14; end;
'iron' : begin TheBmp := IronBar; TheBmp2 := ironore; Bar.Exp := 12.5; Bar.Needed := 28; Bar.Made := 28; end;
'silver' : begin TheBmp := SilverBar; TheBmp2 := silverore; Bar.Exp := 13.5; Bar.Needed := 28; Bar.Made := 28; end;
'steel' : begin TheBmp := SteelBar; TheBmp2 := ironore; Bar.Exp := 17.5; Bar.Needed := 27; Bar.Made := 9; end;
'gold' : begin TheBmp := GoldBar; TheBmp2 := goldore; Bar.Exp := 22.5; Bar.Needed := 28; Bar.Made := 28; end;
'mithril' : begin TheBmp := MithrilBar; TheBmp2 := mithore; Bar.Exp := 30; Bar.Needed := 25; Bar.Made := 5; end;
'admantite': begin TheBmp := AdamantBar; TheBmp2 := adamantore; Bar.Exp := 37.5; Bar.Needed := 28; Bar.Made := 4; end;
'runite' : begin TheBmp := RuniteBar; TheBmp2 := runiteore; Bar.Exp := 50; Bar.Needed := 27; Bar.Made := 3; end;
end;
end;

Procedure WithdrawBmpAmmount(Bitmap, Amount : Integer); // Based on Fawki's proc
var
TimesChecked : Integer;
Begin
if(BankScreen)and(TimesChecked < 4)then
Begin
TimesChecked := TimesChecked+1;
if not (FindBitMapToleranceIn(Bitmap, X, Y, 5, 5, 498, 323, 10))then
begin
Writeln('Player has finished ores. Logging out');
Players[CurrentPlayer].Active := false;
Players[CurrentPlayer].Loc := 'Ores Finished';
Logout;
exit;
end;
if(FindBitMapToleranceIn(Bitmap, X, Y, 5, 5, 498, 323, 10))then
Begin
Mouse(X, Y, 8, 8, False);
Wait(500);
if ChooseOption(x,y,'X') then
Begin
repeat
Wait(250);
until(FindColor(x,y,8388608,256,410,256,410))
TypeSEnd(IntToStr(Amount));
End;
End;
End;
Wait(500 + Random(300));
End;

procedure WithdrawOres; //Based on inferno's procedure
begin
if not LoggedIn then exit;
InfDebug('Withdrawing ores');
Case lowercase(Players[CurrentPlayer].Skill) of
'bronze' : begin
WithdrawBmpAmmount(TinOre, 14);
WithdrawBmpAmmount(CopperOre, 14);
end;
'iron' : WithdrawBmpAmmount(IronOre, 28);
'silver' : WithdrawBmpAmmount(SilverOre, 28);
'steel' : begin
WithdrawBmpAmmount(CoalOre, 18);
WithdrawBmpAmmount(IronOre, 9);
end;
'gold' : WithdrawBmpAmmount(GoldOre, 28);
'mithril' : begin
WithdrawBmpAmmount(CoalOre, 20);
WithdrawBmpAmmount(MithOre, 5);
end;
'admantite': begin
WithdrawBmpAmmount(CoalOre, 24);
WithdrawBmpAmmount(AdamantOre, 4);
end;
'runite' : begin
WithdrawBmpAmmount(CoalOre, 24);
WithdrawBmpAmmount(RuniteOre, 3);
end;
end;
if (InvCount <> Round(Bar.Needed)) then
begin
InfDebug('Player '+IntToStr(CurrentPlayer)+' is done.');
Players[CurrentPlayer].Loc := 'Finished';
Players[CurrentPlayer].Active := false;
end;
end;

Procedure CM(left : boolean);
begin
GetMousePos(x, y);
HoldMouse(x + 1, y, left);
Wait(50 + Random(50));
GetMousePos(x, y);
ReleaseMouse(x, y, left);
Wait(100 + Random(50));
end;

function ClickContinue : boolean;
begin
if FindColor(x,y,16711680,5,345,510,465) and (not FindColor(x,y,0,18,434,25,434)) then //Finds blue NPC text and not the black line seperating text
begin
InfDebug('Found ClickToContinue');
if FindNPCChatText('level') then
begin
ReportVars[3] := ReportVars[3] + 1;
LvlsGained := LvlsGained + 1;
end;
while FindNpcChatText('ontinu') do
begin
Mouse(x,y,20,5,true);
Wait(500 + random(500));
result := true;
end;
Case Random(5) of
1: TypeSend('Yes i gained a lvl =]');
2: TypeSend('woot gained a lvl');
3: TypeSend('lol one more lvl gained');
4: TypeSend('yay my smithing''s lvl '+IntToStr(Players[CurrentPlayer].Level[16]));
end;
end;
end;

function ModOpenBankQuiet(bank : string) : boolean;
var
i,tol,ox,oy : integer;
begin
if not LoggedIn then exit;
repeat
if not LoggedIn then break;
i := i + 1;
tol := tol + 2;
if FindObj(x,y,'ank',4547183,tol) or
FindObj(x,y,'ank',5066840,tol) or
FindObj(x,y,'ank',1984346,tol) then
begin
GetMousePos(ox,oy);
CM(false);
if ChooseOption(ox,oy,'uick') then
begin
result := true;
repeat
Wait(100 + random(100));
until(Bankscreen or InPin(Players[CurrentPlayer].String1))
break;
end;
end;
until(result or (i >= 10))
if not result then
result := OpenBankQuiet(bank);
end;

procedure StoreAll;
begin
if not LoggedIn then exit;
InfDebug('Storing useless items');
if not InvEmpty then
begin
if ModOpenBankQuiet('akb') then
Deposit(1,28,2);
end;
end;

function MyOpenFurnace : boolean;
var i,tol : integer;
begin
if not LoggedIn then exit;
InfDebug('Trying to open furnace');
repeat
InfDebug('Try with tol - '+IntToStr(tol));
if FindColoredAreaTolerance(x,y,1913510,MSX1,MSY1,MSX2,MSY2,50,tol) then
begin
MMouse(x - 5,y,5,5);
if IsUpTextMulti('melt','urna','ace') then
begin
CM(true);
repeat
if not LoggedIn then break;
FTWait(1);
until(FindColor(x,y,128,244,378,244,378))
result := true;
end;
end else
begin
tol := tol + 2;
i := i + 1;
end;
until(result or (i > 15))
end;

function WeAreInBank : boolean;
var
angle : extended;
BankerDTM : integer;
begin
BankerDTM := DTMFromString('78DA636C626260F06600035608C5F0E70F139' +
'86604E2FF40C0D8865F0D98EEA68E1A0007930F53');
result := FindDTMRotated(BankerDTM,x,y,MMX1,MMY1,MMX2,MMY2,-1.0,2.0,0.2,angle);
end;

function WeAreAtFurnace : boolean;
begin
result := FindSYmbol(x,y,'furnace');
end;

function ToFurnace : boolean;
begin
if not LoggedIn then exit;
InfDebug('To furnace');
MouseFlag(675,95,20,20);
result := WeAreAtFurnace;
if result then
begin
Players[CurrentPlayer].Loc := 'Furnace';
MouseFlag(x + 5,y,0,0);
Wait(1000 + random(1000));
Flag;
end;
end;

function ToBank : boolean;
begin
if not LoggedIn then exit;
InfDebug('To bank');
MouseFlag(595,85,20,20);
result := WeAreInBank;
if result then
begin
Players[CurrentPlayer].Loc := 'Bank';
MouseFlag(x,y + 5,5,5);
end;
end;

function SmeltBars : boolean;
var
temp : integer;
Item : TPoint;
begin
if not LoggedIn then exit;
InfDebug('Beginning smelting process');
if not MyOpenFurnace then
begin
Writeln('Furnace not found');
Writeln('I really should get another procedure in here');
TerminateScript;
end;
//Players[CurrentPlayer].Loc := 'Smelting Bars';
Item.y := 390;
Case lowercase(Players[CurrentPlayer].Skill) of
'bronze' : Item.x := 40;
'iron' : Item.x := 140;
'silver' : Item.x := 190;
'steel' : Item.x := 245;
'gold' : Item.x := 290;
'mithril' : Item.x := 345;
'admantite': Item.x := 400;
'runite' : Item.x := 450;
end;
Mouse(Item.x,Item.y,15,15,false);
if ChooseOption(Item.x,Item.y,'X') then
begin
repeat
Wait(250);
until(FindColor(x,y,8388608,256,410,256,410))
TypeSend(floatToStr(Bar.Made));
MarkTime(temp)
repeat
if ClickContinue then
begin
MyOpenFurnace;
SmeltBars;
break;
end;
FindNormalRandoms;
Wait(500);
until((not FindBitMapToleranceIn(TheBmp2,x,y,MIX1,MIY1,MIX2,MIY2,10) or
(TimeFromMark(temp) > 120000)))
result := (InvCount = round(Bar.Made));
if not result then SmeltBars;
ReportVars[0] := ReportVars[0] + CountItemBmpTol(TheBmp,5);
BarsMade := BarsMade + CountItemBmpTol(TheBmp,5);
Players[CurrentPlayer].Integer1 := Players[CurrentPlayer].Integer1 + CountItemBmpTol(TheBmp,5);
ReportVars[2] := ReportVars[2] + Round(Bar.Made * Bar.Exp);
ExpGained := ExpGained + Round(Bar.Made * Bar.Exp);
ReportVars[1] := ReportVars[1] + 1;
LoadsDone := LoadsDone + 1;
Players[CurrentPlayer].Integer2 := Players[CurrentPlayer].Integer2 + 1;
end;
end;

procedure MyCloseBank;
begin
while Bankscreen do
begin
Wait(500 + random(500));
CloseBank;
end;
end;

procedure BankBars;
begin
if not LoggedIn then exit;
InfDebug('Banking bars');
//Players[CurrentPlayer].Loc := 'Banking Bars';
if not BankScreen then
ModOpenBankQuiet('akb');
begin
FixBank;
if FindBitMapTol(x,y,TheBmp,MIX1,MIY1,MIX2,MIY2) then
begin
Mouse(x,y,2,2,false);
ChooseOption(x,y,'All');
Players[CurrentPlayer].Banked := Players[CurrentPlayer].Banked + 1;
Banks := Banks + 1;
end;
WithdrawOres;
MyCloseBank;
end;
MakeCompass('W');
end;

Procedure SetupRS;
begin
MarkTime(PMark);
LTime := (TimeLoggedIn + Random(TimeLoggedIn / 2)) * 1000;
SetRun(true);
GetAllLevels;
SetBars;
HighestAngle;
MakeCompass('W');
StoreAll;
end;

begin
ClearDebug;
ClearReport;
SetupSRL;
ScriptID := '123';
SetupSRLSmithing;
ScriptBy;
StartPlayers(true,'skill location string1');
SymbolAccuracy := 0.4;
ActivateClient;
ReportVars[4] := ReportVars[4] + 1;
LoginPlayer;
repeat
SetupRS;
repeat
if not LoggedIn then break;
if (TimeFromMark(PMark) > LTime) then break;
if Players[CurrentPlayer].Loc = 'Bank' then
begin
BankBars;
ProgRep;
ToFurnace;
end;
if Players[CurrentPlayer].Loc = 'Furnace' then
begin
SmeltBars;
ToBank;
end;
until(false)
if LoggedIn then NextPlayer(true) else NextPlayer(false);
until(false)
end.

Doofy

2007-04-21 22:28:48

Try this, I'm not sure if it works, but post again and tell me if it does or doesn't.

ADD Active to var as Boolean (Active: Boolean).


begin
ClearDebug;
ClearReport;
SetupSRL;
ScriptID := '123';
SetupSRLSmithing;
ScriptBy;
StartPlayers(true,'skill location string1');
SymbolAccuracy := 0.4;
ActivateClient;
ReportVars[4] := ReportVars[4] + 1;
LoginPlayer;
repeat
SetupRS;
repeat
if (TimeFromMark(PMark) > LTime) then break;
if Players[CurrentPlayer].Loc = 'Bank' then
begin
BankBars;
ProgRep;
ToFurnace;
end;
if Players[CurrentPlayer].Loc = 'Furnace' then
begin
SmeltBars;
ToBank;
end;
NextPlayer(Active);
until(NextPlayer(False))
until(NextPlayer(False))
if(LoggedIn) then
begin
Logout;
end;
TerminateScript;
end.

Infantry001

2007-04-21 22:41:58

will not work; nextplayer isnt a function, and doesnt return a bolean value. thanks for trying to help, thoiugh! i appreciate it

Doofy

2007-04-22 01:11:43

thats exactly what i thought too lol…but i tried it on one of my scripts and it seemed to work:confused: but if you used nextplayer, how would you know whether to put true or false? it depends on the players[currentplayer].active…. idk lol

Infantry001

2007-04-22 18:45:18

It didnt work for me…

But, i want this script to work! I know its probably something really small. Can anyone help figure out what i did wrong?

Doofy

2007-04-22 18:52:09

i think i might have figured it out….. try this out:


begin
ClearDebug;
ClearReport;
SetupSRL;
ScriptID := '123';
SetupSRLSmithing;
ScriptBy;
StartPlayers(true,'skill location string1');
SymbolAccuracy := 0.4;
ActivateClient;
ReportVars[4] := ReportVars[4] + 1;
LoginPlayer;
repeat
SetupRS;
repeat
if not LoggedIn then break;
if (TimeFromMark(PMark) > LTime) then break;
if Players[CurrentPlayer].Loc = 'Bank' then
begin
BankBars;
ProgRep;
ToFurnace;
end;
if Players[CurrentPlayer].Loc = 'Furnace' then
begin
SmeltBars;
ToBank;
end;
until(false)
if(LoggedIn) then
begin
Logout;
end;
if(Players[CurrentPlayer].Active) then
begin
NextPlayer(true);
end else
begin
NextPlayer(false);
end;
until(Players[CurrentPlayer].Active = False)
TerminateScript;
end.

Infantry001

2007-04-22 19:28:02

O i got it working now. The failsafe at the end of WIthdraw ores wasnt right. :P

Thanks for hlepin, though, Doofy!

Doofy

2007-04-22 19:43:12

lol no problem, hope it turns out good!!