The Killer
2012-04-26 15:34:16
don't know how to phrase this whatsoever, but is there a way i can get simba to turn off my laptop once the script has failed, this would be handy for overnight botting
2012-04-26 15:34:16
2012-04-26 15:37:23
2012-04-26 15:45:32
2012-04-26 15:46:14
2012-04-26 15:55:06
2012-04-26 16:00:20
From: abu_jwka
Create a bat which shutdowns your computer.
Google it.
2012-04-27 02:42:04
Repeat
DoStuff;
MoreStuff;
Until(Not LoggedIn);
If ( Not LoggedIn) then
begin
OpenFile("Shutdown.batDirectory");
end;
end;2012-04-27 02:48:11
//-----------------------------------------------------------------\\
{ ShutDownPC - Shuts down your computer (Do'h?) ||
{ By: Jahuro / Edit by Hy71194 ||
\\-----------------------------------------------------------------//}
procedure ShutDownPC;
begin
if (ShutDownYourPC = False) then
TerminateScript;
if ShutDownYourPC then
begin
WriteLn('');
WriteLn('Shutting down your PC.');
WriteLn('To stop it once it starts counting, go to Start, Run, then type ''shutdown -a''');
Wait(2000);
KeyDown(92);
Wait(200);
KeyDown(82);
Wait(200);
KeyUp(82);
Wait(200);
KeyUp(92);
Wait(2000);
SendKeys('shutdown -s -f -t 80 -c "Thank you for using Hy71194s Fight Caver. '+TimeRunning+'"');
Wait(2000);
KeyDown(13);
Wait(200);
KeyUp(13);
Wait(160000);
SaveDebug;
TerminateScript;
end;
end;
2012-04-27 03:01:00
procedure ShutDownPC;
begin
KeyDown(92);
wait(200);
KeyDown(82);
wait(200);
KeyUp(82);
wait(200);
KeyUp(92);
wait(200);
Sendkeys('shutdown -s -f -t 00'+chr(13), 100);
end;2012-04-27 04:19:54
program Shutdown;
procedure ExitWindowsEx(flags, reason : Integer); external 'ExitWindowsEx@user32.dll stdcall';
begin
ExitWindowsEx(8, 0);
end.
2012-04-27 10:30:19
library ShutdownPlugin;
{$mode objfpc}{$H+}
uses
Classes, Process, SysUtils;
{$R *.res}
procedure Shutdown; register;
var
Process: TProcess;
begin
Process := TProcess.Create(nil);
{$ifdef Win32}
Process.CommandLine := 'shutdown -s';
{$endif}
{$ifdef Linux}
Process.CommandLine := 'sudo shutdown -h now';
{$endif}
Process.Execute;
Process.Free;
end;
function GetFunctionCount: Integer; stdcall; export;
begin
Result := 1;
end;
function GetFunctionCallingConv(X: Integer): Integer; stdcall; export;
begin
Result := 0;
if X = 0 then
Result := 1;
end;
function GetFunctionInfo(X: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall; export;
begin
if X = 0 then begin
ProcAddr := @Shutdown;
StrPCopy(ProcDef, 'procedure Shutdown;');
end else
X := -1;
Result := X;
end;
exports GetFunctionCount;
exports GetFunctionInfo;
exports GetFunctionCallingConv;
begin
end.
program new;
{$loadlib ShutdownPlugin}
begin
Shutdown;
end.
2012-04-27 10:48:57
2012-04-27 10:56:41
From: cookies1
shizz thanks for all the options, but i also want to put it into the script so it turns off only once the script has stopped, sorry to be such a pain but i reckon a lot of u are finding this interesting and maybe a bit of a challenge
2012-04-27 11:32:49
From: Echo_
So call the shutdown procedure at the end of the script's main loop?
2012-04-27 11:43:21
2012-04-27 11:52:22
From: cookies1
ye but i want to do it after thescript has failed and had to log out, so i supose it would have to scan for logout, then hav a 5 min timer then run the shutdown plugin
2012-04-27 12:41:24
From: P1nky
post your mainloop, we can tell you where to call the shutdown procedure.
tprogram MethDwarfMiner;
{$define SMART}
{$i srl/srl.simba}
var
numOre, numGems, numLoads, ORE_DTM, GEM_DTM, tempMX, tempMY:integer;
const
SRLStats_Username = 'Anonymous';
SRLStats_Password = 'anon1337';
LOADS = 100; //How many loads per player
DROP_GEMS = False; //Set to true to drop gems, leave false to bank
PICKAXE_EQUIPPED = True; // Set to false if pickaxe is in your inventory
BETA_MINING = False; // Set to true to use a potentially faster, but buggier mining method
procedure DeclarePlayers;
begin
HowManyPlayers := 1; // Change Accordingly
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := ''; // Username
Players[0].Pass := ''; // Password
Players[0].Nick := ''; // 4 lowercase letters from your character name
Players[0].Active := True;
{
Players[1].Name := '';
Players[1].Pass := '';
Players[1].Nick := '';
Players[1].Active := True;
Players[2].Name := '';
Players[2].Pass := '';
Players[2].Nick := '';
Players[2].Active := True;
}
end;
(* ******************************************************************************
CREDIT TO Mayazcherquoi on IRC / Daniel on Forums
Finds multiple instances of colour, spiralling outwards from (cx, cy). Returns
only points that are not within the bounds of any of the multiple TBox's
specified in parametre, SkipBoxArray.
- by Daniel
****************************************************************************** *)
function FindColorsSpiralToleranceSkipBoxArray(const cx, cy: Integer; var Points: TPointArray; const Colour, x1, y1, x2, y2, Tolerance: Integer; SkipBoxArray: TBoxArray): Boolean;
var
I, arrLen: Integer; { Go through Points array }
sI, sArrLen: Integer; { Go through SkipBoxArray }
addCnt: Integer; { Additions count }
canAdd: Boolean; { Can add to array? }
tempPoints: TPointArray;
begin
Result := FindColorsSpiralTolerance(cx, cy, tempPoints, Colour, x1, y1, x2, y2, Tolerance);
if(not(Result)) then
Exit;
arrLen := High(tempPoints);
SetArrayLength(Points, arrLen + 1);
addCnt := 0;
sArrLen := High(SkipBoxArray);
for I := 0 to arrLen do
begin
canAdd := True;
for sI := 0 to sArrLen do
begin
if(InRange(tempPoints[I].X, SkipBoxArray[sI].X1, SkipBoxArray[sI].X2) and
InRange(tempPoints[I].Y, SkipBoxArray[sI].Y1, SkipBoxArray[sI].Y2)) then
begin
canAdd := False;
Break;
end;
end;
if(canAdd) then
begin
Points[addCnt] := tempPoints[I];
Inc(addCnt);
end;
end;
end;
function FindColorSpiralToleranceSkipBoxArray(var x, y: Integer; const cx, cy: Integer; const Colour, x1, y1, x2, y2, Tolerance: Integer; SkipBoxArray: TBoxArray): Boolean;
var
tempPoints: TPointArray;
begin
Result := FindColorsSpiralToleranceSkipBoxArray(cx, cy, tempPoints, Colour, x1, y1, x2, y2, Tolerance, SkipBoxArray);
Result := (Length(tempPoints) > 0);
if(not(Result)) then
Exit;
x := tempPoints[0].x;
y := tempPoints[0].y;
end;
function FindColorSpiralToleranceSkipBox(var x, y: Integer; const cx, cy: Integer; const Colour, x1, y1, x2, y2, Tolerance: Integer; SkipBox: TBox): Boolean;
begin
Result := FindColorSpiralToleranceSkipBoxArray(x, y, cx, cy, Colour, x1, y1, x2, y2, Tolerance, [SkipBox]);
end;
(* ******************************************************************************
End of code that isn't mine
****************************************************************************** *)
procedure AntiBan;
begin
if(not(LoggedIn)) then
Exit;
If FindNormalRandoms Then
begin
Players[CurrentPlayer].Active := False;
numLoads := 0;
NextPlayer(Players[CurrentPlayer].Active);
Exit;
end;
case Random(80) of
10: RandomRClick;
20: HoverSkill('Mining', False);
30: PickUpMouse;
40: RandomMovement;
50: BoredHuman;
59: ExamineInv;
end;
end;
procedure WalkToBank(atCoal:Boolean);
begin
MakeCompass(0);
wait(1000 + random(666));
if (atCoal) then
begin
RadialWalkTolerance(9931140, 264, 300, 70, 0, 1, 18);
wait(500 + random(227));
end;
RadialWalkTolerance(6778480, 285, 250, 62, 1, 0, 13);
wait(1000 + random(666));
end;
procedure WalkToCoal(atBank:Boolean);
begin
if (atBank) then
begin
RadialWalkTolerance(9931140, 106, 70, 50, 0, 0, 18);
wait(500 + random(227));
end;
RadialWalkTolerance(4808039, 84, 105, 67, -1, 0, 15);
wait(1000 + random(666));
end;
function isMining:Boolean;
var
Box: TBox;
begin
Box := IntToBox(245, 130, 285, 195);
Result := (AveragePixelShift(Box, 250, 500) > 260);
end;
function FindBox(open:Boolean):Boolean;
var
x, y, CTS: Integer;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.14, 0.58);
while (FindColorSpiralTolerance(x, y, 6653850, MSX1, MSY1, MSX2, MSY2, 3)) do
begin
MMouse(x, y, 2, 2);
if IsUpText('posit') then
begin
if (open) then
begin
Mouse(x, y, 2, 2, mouse_right);
end;
Result := True;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
exit;
end;
end;
Result := False;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
function FindOre(mine, moveMouse:Boolean):Boolean;
var
x, y, CTS: Integer;
skipOre: TBox;
pointsA: TPointArray;
begin
skipOre := IntToBox(tempMX - 30, tempMY - 30, tempMX + 30, tempMY + 30);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.23);
FindColorsSpiralTolerance(x, y, pointsA, 1776668, MSX1, MSY1, MSX2, MSY2, 4)
//while (FindColorSpiralTolerance(x, y, 1776668, MSX1, MSY1, MSX2, MSY2, 4)) do
while (FindColorSpiralToleranceSkipBox(x, y, MSCX, MSCY, 1776668, MSX1 + 10, MSY1 + 10, MSX2, MSY2, 4, skipOre)) do
begin
if (moveMouse) then
MMouse(x, y, 2, 2);
if (IsUpText('ine') or OptionsExist(['ine'], False)) then
begin
Result := True;
if (mine) then
begin
Mouse(x, y, 2, 2, mouse_right);
end;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
exit;
end;
end;
Result := False;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
procedure FindOreSpot(x, y: Integer);
var
direction, yTrigPoint, xTrigPoint: Integer;
begin
yTrigPoint := (iAbs(256 - x));
if ((x >= MSCX) and (x <= (MSCX + 167))) then
begin
if (y > (MSCY + yTrigPoint)) then
direction := 3
else if (y < (MSCY - yTrigPoint)) then
direction := 1
else
direction := 0
end else if ((x <= MSCX) and (x > (MSCX - 167))) then
begin
if (y > (MSCY + yTrigPoint)) then
direction := 3
else if (y < (MSCY - yTrigPoint)) then
direction := 1
else
direction := 2
end else if (x > (MSCX + 167)) then
direction := 0
else if (x < (MSCX - 167)) then
direction := 2;
case direction of
0:
begin
x := (MSCX + 40);
y := (MSCY);
end;
1:
begin
x := (MSCX);
y := (MSCY - 40);
end;
2:
begin
x := (MSCX - 40);
y := (MSCY);
end;
3:
begin
x := (MSCX);
y := (MSCY + 40);
end;
end;
tempMX := x;
tempMY := y;
end;
procedure MineOre;
var
i, x, y, prevMX, prevMY: Integer;
begin
while (not InvFull) do
begin
If FindNormalRandoms Then
begin
Players[CurrentPlayer].Active := False;
numLoads := 0;
NextPlayer(Players[CurrentPlayer].Active);
Exit;
end;
if (BETA_MINING) then
begin
if ((FindOre(true, true)) and (not InvFull)) then
begin
while ((FindOre(false, false)) and (not InvFull)) do
begin
while ((OptionsExist(['ine'], False)) and (not InvFull)) do
begin
GetMousePos(prevMX, prevMY);
FindOreSpot(prevMX, prevMY);
ChooseOption('ine');
wait(random(300));
AntiBan;
repeat
wait(random(200));
until (not isMoving)
FindOre(True, True);
//while (MouseTooClose(tempMX, tempMY)) do
while (not OptionsExist(['ine'], False)) do
begin
FindOre(True, True);
end;
repeat
wait(random(100));
until (not isMining);
end;
if (OptionsExist(['ancel'], false)) then
ChooseOption('ancel');
FindOre(True, True);
end;
end;
end else
begin
if FindOre(True, True) then
begin
ChooseOption('ine');
wait(random(200));
AntiBan;
repeat
wait(random(500));
until (not isMining);
end;
end;
if (not InvFull) then
begin
i := i + 1;
if (i = 20) then
begin
i := 0;
if FindBox(False) then
begin
WalkToCoal(True);
end else
begin
WalkToCoal(False);
end;
end;
end;
end;
if (DROP_GEMS) then
begin
while (FindDTM(GEM_DTM, x, y, MIX1, MIY1, MIX2, MIY2)) do
begin
Mouse(x, y, 2, 2, mouse_right);
ChooseOption('rop');
end;
end;
If (Not InvFull) then
begin
MineOre;
end;
end;
procedure DepositOre;
var i, j, d, o, g: integer;
begin
d := 0;
i := 0;
j := 0;
g := CountItems('dtm', GEM_DTM, []);
o := CountItems('dtm', ORE_DTM, []);
repeat
If FindNormalRandoms Then
begin
Players[CurrentPlayer].Active := False;
numLoads := 0;
NextPlayer(Players[CurrentPlayer].Active);
Exit;
end;
if FindBox(False) then
begin
FindBox(True);
ChooseOption('posit');
while ((not DepositScreen) and (j < 20)) do
begin
wait(random(500));
j := j + 1;
end;
if (DepositScreen) then
begin
if (PICKAXE_EQUIPPED) then
begin
QuickDeposit(SRL_DEPOSIT_ALL);
d := 1;
end else
begin
Deposit(2, 28, True);
d := 1;
end;
numOre := numOre + o;
numGems := numGems + g;
numLoads := numLoads + 1;
stats_IncVariable('Loads Done', 1);
stats_IncVariable('Coal Ore (Mined)', o);
stats_IncVariable('Gems (Mined)', g);
end;
if (j >= 20) then
begin
j := 0
end;
end else
begin
i := i + 1;
end;
if (i = 10) then
begin
i := 0;
MakeCompass(90);
end;
until (d = 1);
MakeCompass(0);
wait(1000 + random(750));
end;
procedure CheckAtStart;
begin
if (FindBox(False)) then
begin
WalkToCoal(True);
end;
if not (FindOre(False, True)) then
begin;
WalkToCoal(False);
end;
end;
procedure ProgReport;
begin
Stats_Commit;
Writeln(' ');
Writeln(' Methrends Dwarf Coal Miner ');
Writeln(' Running For: ' + TimeRunning);
Writeln(' Total Ores Deposited: ' + IntToStr(numOre));
If (DROP_GEMS = False) then
Writeln(' Total Gems Deposited: ' + IntToStr(numGems));
Writeln(' ');
end;
begin
Smart_Server := 30;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
ClearDebug;
SetupSRL;
SetupSRLStats(439, SRLStats_Username, SRLStats_Password);
DeclarePlayers;
ORE_DTM := DTMFromString('mggAAAHicY2NgYHBmYWCwg+IgIDYCYl8gPgKU2wrEl4B4PxCfAOLTQKyiLA0kmTDwfwbsgBEHhgAAwY8HvQ==');
GEM_DTM := DTMFromString('mAAEAAHic42FgYJjBxMCwEIjnA/ECKJ4LxJOAuAeIu4F4KhD3Q/lljBBcBMRVQFwHxA1AXA/ElVDxLCDOBuJcIBYQKgDawkQ0/s9AGmAkESMDAEPLDnQ=');
while (not (AllPlayersInactive)) do
begin
if not LoggedIn then
LoginPlayer;
while(not LoggedIn) do
wait(1000);
MakeCompass(0);
SetAngle(SRL_ANGLE_HIGH);
tempMX := MSCX;
tempMY := MSCY;
while(LoggedIn) do
begin
CheckAtStart;
MineOre;
AntiBan;
WalkToBank(True);
AntiBan;
DepositOre;
ProgReport;
WalkToCoal(True);
if ((numLoads = LOADS) and (length(Players) > 1 )) then
begin
numLoads := 0;
NextPlayer(Players[CurrentPlayer].Active);
end;
end;
end;
end.can't see the main loop :S <-ima noob get over it ;)
2012-04-27 12:53:48
From: Echo_
Yes that would work, don't really need a timer though ;)
2012-04-27 15:17:01
function ActivePlayers: Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 to High(Players) do
if Players[I].Active then
Result := True;
end;
begin
//mainloop stuff
if not ActivePlayers then
Shutdown;
end.
2012-04-27 15:55:35
From: Echo_
Just do something like:
function ActivePlayers: Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 to High(Players) do
if Players[I].Active then
Result := True;
end;
begin
//mainloop stuff
if not ActivePlayers then
Shutdown;
end.
2012-04-27 16:44:11
2012-04-27 19:46:20
2012-04-27 23:27:37