SRL Archive - Help and Support

Worked for = 0


~alex~

2007-04-22 06:44:14

This really is frying my head… Why does it always tell me worked for = 0?

program New;
{.include srl/srl.scar}
{.include srl/srl/skill/woodcutting.scar}
var
position:string;
enty,log,yew,color1,color2:integer;
axelost:boolean;
//******************** Set These Constants if Needed *******************//

const StartPlayer = 0; // Determines who will play first
Const Loads = 500; // Number of loads before switching Player.

//**********************RuneScape Constants*******************************//


//************************************************************************//
const VersionNumber = '0.1'; // Compliant with Rev 568+
//************************************************************************//

Procedure DeclarePlayers;
begin
HowManyPlayers :=6; // Set Number of Players here.
NumberOfPlayers(HowManyPlayers); // Sets the Players Array Length;
CurrentPlayer:=StartPlayer; // Current Player = Array Index

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='00b';
Players[0].Loc :='Loc1';
Players[0].Skill:='woodcutting';
Players[0].Active:=True;
players[0].integer1:= loads
{
Players[1].Name :='';
Players[1].Pass :='';
Players[1].Nick :='';
Players[1].Loc :='Loc1';
Players[1].Skill:='';
Players[1].Active:=True;

Players[2].Name :='';
Players[2].Pass :='';
Players[2].Nick :='';
Players[2].Loc :='Loc1';
Players[2].Skill:='';
Players[2].Active:=True;

Players[3].Name :='';
Players[3].Pass :='';
Players[3].Nick :='';
Players[3].Loc :='Loc1';
Players[3].Skill:='';
Players[3].Active:=True;

Players[4].Name :='';
Players[4].Pass :='';
Players[4].Nick :='';
Players[4].Loc :='Loc1';
Players[4].Skill:='';
Players[4].Active:=True;

Players[5].Name :='';
Players[5].Pass :='';
Players[5].Nick :='';
Players[5].Loc :='Loc1';
Players[5].Skill:='';
Players[5].Active:=True; }

writeln(inttostr(HowManyPlayers)+' Players');

end;

procedure proggyReport;
begin
writeln('---------------------------------------------------')
writeln('Current Player ' + players[currentplayer].name)
writeln('Logs Chopped ' + inttostr(players[currentplayer].integer2))
writeln('Exp gained ' + intTostr(players[currentplayer].integer3))
writeln('Banked : '+ inttostr(Players[CurrentPlayer].Banked) + ' times.');
writeln('Worked for ' + intTostr(players[currentplayer].worked)+' mins')
writeln('Script running for '+timerunning)
end;
procedure loadbmps;
begin

entY := BitmapFromString(2, 7, 'z78DA73367536333074B1707174' +
'737306B2612450C409C206CB3A199813603B22D800534513AF');
end;


//credit to starblaster for the next two procedures
procedure Color32ToRGB(Color: Integer; var R, G, B: Integer); // Also from PowerSkills, Used In Ent Detection
begin
B := (Color and $00ff0000) shr 16;
G := (Color and $0000ff00) shr 8;
R := (Color and $000000ff);
end;
{ ---------------------------------------------------------------------------- ]
[ >> Part of Woodcutting ]
[ >> Function StarFindEnt(TreeName: String): Boolean; ]
[ >> Returns True if an Ent is Found ]
[ ---------------------------------------------------------------------------- }

Function StarFindEnt(TreeName: String): Boolean;
Var
H, S, L: Extended;
R, G, B: Integer;
cx, cy, ax, ay, i: Integer;
Temp: Array[0..5] of Integer;
Begin
if (IsTextInAreaEx(7, 7, 180, 25, cx, cy, TreeName, 100, UpChars, True,
True, 0, 2, -1)) then
Begin
For i := 0 to 5 do
Begin
ax := cx + i;
ay := cy + 3;
Temp[i] := GetColor(ax, ay);
//Writeln(IntToStr(Temp[i])+' '+IntToStr(ax)+' '+IntToStr(ay));
end;
For i := 0 to 5 do
Begin
ColorToHSL(Temp[i], H, S, L);
Color32ToRGB(Temp[i], R, G, B);
If ((H >= 10) and (H <= 20) and
(S >= 80) and (S <= 100) and
(L >= 35) and (L <= 55)) then
Begin
Result := True;
Exit;
end else
If ((R > 190) and (R < 225) and
(G > 190) and (G < 225) and
(B >= 0) and (B < 25)) then
Begin
Result := True;
Exit;
end
end;
end;
end;

procedure freebmps;
begin
freebitmap(enty)
end;

Function FindFastRandoms: Boolean;
var
i: Integer;
begin
for i:=1 to 11 do
begin
case I of
1: If FindDead then
Result := True;
2: If FindMod then
Result := True;
3: If FindMime then
Result := True;
4: If FindMaze then
Result := True;
5: If FindQuiz then
Result := True;
6: If FindDemon then
Result := True;
7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;
8: begin
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Logout;
Exit;
end;
end;

9: begin
if not findhead then
begin
axelost:=true
end;
end;
10: begin
if starfindent('Yew') then
begin
mousespeed:=5
mouse(652,83,2,2,true)
boredhuman;
wait(30000+random(5000))
mousespeed:=8
EntsAvoided := EntsAvoided + 1;
end;
end;
11: begin
if findfight then
begin
runawaydirection('W')
wait(25000+random(5000))
runback;
end;
end;
end;
wait(1);
end;
end;

procedure getposition;
begin
if findsymbol(x,y,'water') then
begin
position:='North'
end else
begin
position:='South'
end;
end;

function switchposition:boolean;
begin
getposition;
if position = 'South' then
begin
if findcolorspiraltolerance(x,y,91905,630,20,672,67,50) then
begin
mouse(x+10,y+8,2,2,true)
flag;
result:= true
end else
result:=false
end;
if position = 'North' then
begin
if findcolorspiraltolerance(x,y,91905,610,96,661,150,50) then
begin
mouse(x+10,y - 8,2,2,true)
flag;
result:= true
end else
result:=false
end;
end;

function checkDoor:boolean;
begin
if FindObj(x,y,'Door',2575216,40) then
begin
mmouse(x,y,0,0)
wait(1000+random(245))
if isuptext('Open') then
begin
mouse(x,y,0,0,false)
clickoption('pen',1)
flag;
end;
end else
begin
writeln('Could not find door')
result:=false
end;
end;

function walktoyews:boolean;
var
tx,ty,mmyew:integer;
begin
mouse(646,142,3,3,true)
flag;
x:=MMCX
y:=MMCY
if FindColorspiralTolerance(x,y,236,MMX1,MMY1,MMX2,MMY2,20) then
begin
mouse(x,y,0,0,true)
flag;
end else
begin
result:=false
writeln('Could not find dungeon symbol')
exit;
end;
x:=mmcx
y:=mmcy
checkdoor;
// mmyew:=getsymbolcolor(tx,ty,'tree')
//if findcolorspiraltolerance(x,y,mmyew,mmx1,mmy1,mmx2,mmy2,30) then
//if findcolorspiraltolerance(x,y,91905,630,20,672,67,30) then
if findsymbol(x,y,'Tree') then
begin
mouse(x+10,y-3,3,3,true)
flag;
result := true
end else
begin
writeln('Could not find tree symbol')
result:=false
end;
end;

// By Sumilion and Lorax -- Edited by startblaster
Function UpdateCoords(Var cx, cy: Integer; ax, ay, TheColor, Tol: Integer): Boolean;
var
Counter: Integer;
Begin
If (ax < 20) then ax := 20; If (ay < 20) then ay := 20;
While (FlagPresent) and (FindColorSpiralTolerance(cx, cy, TheColor, ax-20, ay-20, ax+20, ay+20, Tol)) do
begin
ax := cx; ay := cy;
Wait(15);
end;
If (ax < 10) then ax := 10; If (ay < 10) then ay := 10;
While (FindColorSpiralTolerance(cx, cy, TheColor, ax-10, ay-10, ax+10, ay+10, Tol)) and (Counter < 60) do
begin
ax := cx; ay := cy;
Counter := Counter + 1;
Wait(15);
end;
Result := FindColorSpiralTolerance(cx, cy, TheColor, ax-10, ay-10, ax+10, ay+10, Tol);
if (not Result) then
else
end;

procedure tobank;
begin
getposition;
if position = 'North' then
switchposition;
if FindColorspiralTolerance(x,y,236,MMX1,MMY1,MMX2,MMY2,30) then
begin
mouse(x,y,2,2,true)
flag;
checkdoor;
mouse(650,20,5,5,true)
flag;
if findcolortolerance(x,y,6082797,mmx1,mmy1,mmx2,mmy2,50) then
begin
mouse(x,y,3,3,true)
flag;
end else
begin
writeln('Cannot find bank')
nextplayer(true)
end;
end;
end;

procedure Depositstuff;
begin
log:= DTMFromString('78DA8DD0310E40000C85E1D6E64A0C6211913' +
'020CEEC0AC226B120DC807FC4F2BCA47DCBB7B45E04668BBDD224' +
'A1F5B43317F10C33D927FED874891984A931A3302D6616A6C3ACC' +
'254985D981C730893624E6122CC264CFCE3AE44FFF906625F13BA' +
'');

openbank3;
flag;
players[currentplayer].integer2:= players[currentplayer].integer2 + CountItemDtm(log)
players[currentplayer].integer3:= players[currentplayer].integer2 * 175
reportvars[0]:=reportvars[0] + CountItemDtm(log)
writeln(inttostr(reportvars[0]))
reportvars[1]:= reportvars[1] + (CountItemDtm(log) * 175)
writeln(inttostr(reportvars[1]))
players[currentplayer].banked := players[currentplayer].banked + 1
if pinscreen then
begin
writeln('Pinscreen found. remove pin')
nextplayer(false)
end;
if bankscreen then
begin
Deposit(2,28,2)
closebank;
makecompass('N')
end;
if players[currentplayer].integer2 >= players[currentplayer].integer1 then
begin
writeln('All logs chopped')
nextPlayer(false)
end;
end;

procedure waitwhilecutting;
begin
color2:=getcolor(x,y)
marktime(mark)
repeat
findtalk;
findnormalrandoms;
findfastrandoms;
if invfull then break;
if timefrommark(mark) > 40000 then exit;
until(not isuptext('Chop'))
end;

function chop: boolean;
var
fx,fy,c:integer;
begin
repeat
//if FindObj(fx,fy,'Yew',2048,5) then
if FindObj(fx,fy,'Yew',1718328,5) then
begin
color1:=getcolor(fx,fy)
mouse(fx,fy,3,3,true)
result:= true
c:=0
if Updatecoords(x,y,fx,fy,color1,2) then
begin
mmouse(x,y,0,0)
waitwhilecutting;
end else exit;
end else
begin
wait(1000+random(500))
c:=c+1
end;
until((result = true) or (c >5 ))
if c > 5 then
begin
result:=false
c:=0
end;

end;

procedure setup;
begin
setupsrl;
scriptid := '127'
activateclient;
declareplayers;
loginplayer;
srlrandomsreport;
mousespeed:=8
makecompass('N')
highestangle
end;

begin
setup;
repeat
loadbmps;
walktoyews;
if not findaxeheadcolor then
begin
axelost:=true
end;
if not loggedin then loginplayer;
repeat
if not chop then
begin
if not switchposition then
begin
writeln('Lost')
nextplayer(true)
end;
end;
freebmps;
until((invfull) or (axelost))
if invfull or axelost then
begin
makecompass('N')
tobank;
makecompass('W')
depositstuff;
srlrandomsreport;
proggyReport;
end;
until(false)
end.

Pentti

2007-04-22 07:30:33

Maybe because you should set value for Players[#].Worked:
Players[CurrentPlayer].Worked:=Players[CurrentPlayer].Worked+PlayerStartTime;
Add this before switching player.
I think that should work.

nielsie95

2007-04-22 07:36:40

@Pentti: If I'm right, that should be implented in the Login Procedure.

So I don't know really..

~alex~

2007-04-22 07:44:43

Thanks for the replies.. I might use pentti's suggestion as a temp fix.

edit: After implementing penttis suggestion I get


Worked for 23422 mins
:|

tarajunky

2007-04-22 10:49:40

Don't mess with the Worked variable. That's for SRL Stats only.

If you want to keep track of how long your player has been working, you need to set up another unique variable to track it.

The reason it's always saying zero is because Worked is re-set to 0 by the stats system every time you do a randoms report.

I repeat, DO NOT MESS WITH IT.

Pentti

2007-04-22 12:23:04

Umm… that actually won't affect to SRL stats (maybe):
Worked    := M - LastMins2;
It sets value for integer worked when sending the data.

But ye, alex, you could use maybe Players[#].Integer2 instead of Players[#].Worked
Players[#].Integer2:=Players[#].Integer2+PlayerStartTime/60;
Now it returns as minutes.

~alex~

2007-04-22 13:04:40

Ive already used all 3 Integers.. Ill figure something out. Thanks guys

tarajunky

2007-04-22 13:13:09

Don't ever change Worked.

"Players[CurrentPlayer].Worked:=" should never appear in any script.

But you CAN copy it into another variable if you want. Try making a global Array of integer like PlayerTime or something.

Then for each player you can keep track by doing something like this.


procedure proggyReport;
begin
PlayerTime[currentplayer]:=PlayerTime[currentplayer]+Players[CurrentPlayer].Worked;
SRLRandomsReport;
writeln('---------------------------------------------------')
writeln('Current Player ' + players[currentplayer].name)
writeln('Logs Chopped ' + inttostr(players[currentplayer].integer2))
writeln('Exp gained ' + intTostr(players[currentplayer].integer3))
writeln('Banked : '+ inttostr(Players[CurrentPlayer].Banked) + ' times.');
writeln('Worked for ' + intTostr(PlayerTime[currentplayer])+' mins')
writeln('Script running for '+timerunning)
end;

You would have to do the SRLRandomsReport AFTER adding the Worked variable though, like I did above, so that Worked isn't re-set to zero until after you have added it up.

Infantry001

2007-04-22 15:35:28

THe worked variable only counts time after the second login, i believe.