PDA

View Full Version : [Money Making] SpawnPK Thiever



Citrus
04-02-2018, 11:16 PM
As requested.

program SpawnPKThiever;
//for best results, face camera south and zoom in a bit
const
STOP_KEY = 130; //choose a key to stop the script

MOUSE_MOVE = 3;
MSX1 = 8;
MSY1 = 33;
MSX2 = 518;
MSY2 = 366;
MSBOX: TBox = [MSX1, MSY1, MSX2, MSY2];
MSCX = (MSX2 - MSX1) div 2;
MSCY = (MSY2 - MSY1) div 2;
MSCP: TPoint = [MSCX, MSCY];

var
_w, _h, Level: Int32;
CashTimer: UInt32;

function FindColors(var TPA: TPointArray; Color: Int32; b: TBox): Boolean; Overload;
begin
Result := FindColors(TPA, Color, b.x1, b.y1, b.x2, b.y2);
end;

function FindColors(var TPA: TPointArray; Color: Int32): Boolean; Overload;
var
w, h: Int32;
begin
GetClientDimensions(w, h);
Result := FindColors(TPA, Color, 0, 0, w-1, h-1);
end;

procedure Wait(w1, w2: Int32); Overload;
begin
Wait(Random(w1, w2));
end;

procedure FastClick(Button: Byte);
var
x, y: integer;
begin
GetMousePos(x, y);
HoldMouse(x, y, Button);
Wait(80, 100);
ReleaseMouse(x, y, Button);
end;

procedure Mouse(P: TPoint; Button: Byte);
begin
MoveMouse(P.X, P.Y);
if (Button = MOUSE_MOVE) then Exit;
Wait(20, 30);
FastClick(Button);
end;

procedure Mouse(X, Y: Int32; Button: Byte); Overload;
begin
Mouse(Point(X, Y), Button);
end;

procedure MouseBox(const B: TBox; Button: Byte);
begin
Mouse(Point(B.X1 + Random(B.X2 - B.X1), B.Y1 + Random(B.Y2 - B.Y1)), Button);
end;

procedure Setup();
var
i: Int32;
PP: TSysProcArr;
begin
PP := GetProcesses();
for i := 0 to High(PP) do
begin
if (Pos('SpawnPK', PP[i].Title) > 0) then
begin
if (Pos('Simba', PP[i].Title) > 0) then Continue;
SetTarget(PP[i]);
GetClientDimensions(_w, _h);
if (_w > 800) then
begin
Mouse(750, 44, MOUSE_LEFT);
Wait(234);
GetClientDimensions(_w, _h);
if (_w > 800) then
begin
WriteLn('Please minimize the side panel.');
TerminateScript();
end else Exit;
end else Exit;
end;
end;
WriteLn('Error: Didn''t setup client.');
TerminateScript();
end;

//https://github.com/SRL/SRL/blob/master/shared/text.simba#L18
function FindTextIn(var Matches: TPointArray; const Text, Font: String; const Color: Int32; const B: TBox): Boolean;
var
w, h: Int32;
TPA, TextTPA: TPointArray;
begin
if FindColors(TPA, Color, B.X1, B.Y1, B.X2, B.Y2) then
begin
SetLength(Matches, 0);
TextTPA := TPAFromText(Text, Font, w, h);
Result := FindTextTPAinTPA(h-1, TextTPA, TPA, Matches);
end;
end;

function WaitFunc(Func: function: Boolean; WaitTime, WaitInterval: Int32; Condition: Boolean = True): Boolean;
var
t: UInt32;
begin
t := GetTickCount() + WaitTime;
repeat
Result := Func();
if (Result = Condition) then Exit(True);
Wait(WaitInterval);
until (GetTickCount() > t);
Result := False;
end;

function IsWalking(): boolean;
var
BMPA, BMPB, w, h: Int32;
begin
try
BMPA := BitmapFromClient(MSX1, MSY1, MSX2, MSY2);
Wait(69);
BMPB := BitmapFromClient(MSX1, MSY1, MSX2, MSY2);
GetBitmapSize(BMPA, w, h);
Result := (CalculatePixelShift(BMPA, BMPB, [0, 0, w-1, h-1]) > 50000);
finally
if BitmapExists(BMPA) then FreeBitmap(BMPA);
if BitmapExists(BMPB) then FreeBitmap(BMPB);
end;
end;

function GetUpText(): String;
const
COL = $006699;
var
BMP, w, h, OldT, NewT: Int32;
B: TBox;
TPA: TPointArray;
begin
if FindColors(TPA, 16777215, 12, 34, 500, 54) then
begin
OldT := GetImageTarget();
B := GetTPABounds(TPA);
BMP := BitmapFromClient(B.X1, B.Y1, B.X2+1, B.Y2+1);

FastReplaceColor(BMP, $FFFFFF, COL); //white
FastReplaceColor(BMP, $FFFF00, COL); //cyan
FastReplaceColor(BMP, $00FF00, COL); //green

GetBitmapSize(BMP, w, h);

try
SetTargetBitmap(BMP);
Result := GetTextAtEx(0, 0, w-1, h-1, 0, 4, 4, COL, 0, 'UpChars07');
finally
NewT := GetImageTarget();
SetImageTarget(OldT);
FreeTarget(NewT);
if BitmapExists(BMP) then FreeBitmap(BMP);
end;
end;
end;

function IsUpText(const S: String): Boolean;
begin
Result := (Pos(S, GetUpText()) > 0);
end;

function IsUpText(const SS: TStringArray): Boolean; Overload;
begin
Result := IsArrInStr(SS, GetUpText());
end;

function WaitUpText(const S: String; const WaitTime: UInt32): Boolean;
var
t: UInt32;
begin
t := GetTickCount() + WaitTime;
repeat
Result := IsUpText(S);
if Result then Exit;
Wait(44);
until (GetTickCount() > t);
end;

function WaitUpText(const SS: TStringArray; const WaitTime: UInt32): Boolean; Overload;
var
t: UInt32;
begin
t := GetTickCount() + WaitTime;
repeat
Result := IsUpText(SS);
if Result then Exit;
Wait(44);
until (GetTickCount() > t);
end;

function GetTabBox(const Tab: Int32): TBox;
begin
if (not InRange(Tab, 1, 7)) then Exit;
Result.X1 := 499 + (Tab * 33);
Result.X2 := Result.X1 + 32;
Result.Y1 := 196;
Result.Y2 := 232;
end;

function IsTabActive(const Tab: Int32): Boolean;
const
COLOR = 1515095;
TOL = 30;
var
B: TBox;
begin
if (not InRange(Tab, 1, 7)) then Exit;
B := GetTabBox(Tab);
Result := (CountColorTolerance(COLOR, B.X1, B.Y1, B.X2, B.Y2, TOL) > 200);
end;

function ClickTab(const Tab: Int32): Boolean;
var
t: UInt32;
begin
if IsTabActive(Tab) then Exit(True);
MouseBox(GetTabBox(Tab), MOUSE_LEFT);
t := GetTickCount() + 100;
repeat
Result := IsTabActive(Tab);
if Result then Exit;
Wait(20);
until (GetTickCount() > t);
end;

function IsMoneyMakingScreen(): Boolean;
var
TPA: TPointArray;
begin
Result := FindTextIn(TPA, 'Money Making', 'UpChars07', 45311, MSBOX);
end;

function ClickThieving(): Boolean;
var
c: Int32;
TPA: TPointArray;
begin
repeat
if FindTextIn(TPA, 'Thieving', 'StatChars07', $FFFFFF, MSBOX) then Exit(True);
if FindTextIn(TPA, 'Thieving', 'StatChars07', 2070783, MSBOX) then
begin
OffsetTPA(TPA, Point(4, 4));
Mouse(TPA[0], MOUSE_LEFT);
Wait(234);
end;
until (Inc(c) > 4);
end;

function ClickTeleport(): Boolean;
var
TPA: TPointArray;
begin
if FindTextIn(TPA, 'Teleport', 'StatChars07', 39935, MSBOX) then
begin
OffsetTPA(TPA, Point(4, 4));
Mouse(TPA[0], MOUSE_LEFT);
Result := WaitFunc(@IsMoneyMakingScreen, 2345, 234, False);
end;
end;

function Teleport(): Boolean;
const
B: TBox = [591, 273, 610, 292];
begin
if IsMoneyMakingScreen() then
begin
if ClickTeleport() then
begin
Wait(4567, 5678);
Exit(True);
end;
end;
if ClickTab(7) then
begin
Wait(121, 212);
MouseBox(B, MOUSE_LEFT);
if WaitFunc(@IsMoneyMakingScreen, 3456, 234, True) then
begin
if ClickThieving() then
begin
if ClickTeleport() then
begin
Wait(4567, 5678);
Result := True;
end;
end;
end;
end;
end;

function GetThievingLevel(): Int32;
const
B: TBox = [630, 350, 655, 365];
var
TPA: TPointArray;
begin
if ClickTab(2) then
if FindColors(TPA, $00FFFF, B.X1, B.Y1, B.X2, B.Y2) then
Result := StrToIntDef(GetTextATPA(ClusterTPA(TPA, 1), 5, 'StatChars07'), -1);
end;

function GetStallNumber(const TL: Int32): Int32;
begin
case TL of
01..24: Result := 1;
25..49: Result := 2;
50..74: Result := 3;
75..98: Result := 4;
99: Result := 5;
end;
end;

function GetStallText(const Stall: Int32): String;
begin
case Stall of
1: Result := '250';
2: Result := '350';
3: Result := '450';
4: Result := '650';
5: Result := '850';
end;
end;

function Thieve(): Boolean;
const
TABLE_COLOR = 2708852;
TABLE_TOL = 2;
var
i, Stall: Int32;
B: TBox;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if (Level <> 99) then Level := GetThievingLevel();
Stall := GetStallNumber(Level);
if (not IsUpText(GetStallText(Stall))) then
begin
if FindColorsTolerance(TPA, TABLE_COLOR, MSX1, MSY1, MSX2, MSY2, TABLE_TOL) then
begin
ATPA := ClusterTPA(TPA, 1);
FilterTPAsBetween(ATPA, 0, 100);
FilterTPAsBetween(ATPA, 1000, 1000000);
if (Length(ATPA) < 1) then Exit;
if (Level < 50) then
SortATPAFromMidPoint(ATPA, Point(200, MSY1)) else
SortATPAFromMidPoint(ATPA, Point(200, MSY2));
for i := 0 to High(ATPA) do
begin
Mouse(MedianTPA(ATPA[i]), MOUSE_MOVE);
if WaitUpText(GetStallText(Stall), 300) then Break;
end;
if (i = Length(ATPA)) then Exit;
end else Exit;
end;
FastClick(MOUSE_LEFT);
Wait(2450, 2500);
Result := True;
end;

function FindChooseOption(out B: TBox): Boolean;
const
COLOR = 4674653;
var
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if FindColors(TPA, COLOR) then
begin
ATPA := ClusterTPA(TPA, 4);
SortATPASize(ATPA, True);
B := GetTPABounds(ATPA[0]);
Result := True;
end;
end;

function ChooseOption(const S: String): Boolean;
var
B: TBox;
TPA: TPointArray;
begin
if FindChooseOption(B) then
begin
if FindTextIn(TPA, S, 'UpChars07', $FFFFFF, B) then
begin
OffsetTPA(TPA, [9, 4]);
Mouse(MedianTPA(TPA), MOUSE_LEFT);
Result := True;
end;
end;
end;

function CashBags(): Boolean;
const
B: TBox = [553, 238, 738, 488];
GREEN_CASH = $80FF00;
var
x, y: Int32;
TPA: TPointArray;
begin
if (GetTickCount() < CashTimer) then Exit;
CashTimer := GetTickCount() + 1000000;
if ClickTab(4) then
begin
Wait(121);
if FindColor(x, y, GREEN_CASH, B.X1, B.Y1, B.X2, B.Y2) then
begin
Mouse(x + 9, y + 9, MOUSE_RIGHT);
Wait(121);
Result := ChooseOption('exchange');
end;
end;
end;

procedure Mainloop();
begin
if IsKeyDown(STOP_KEY) then TerminateScript();
CashBags();
if (not Thieve()) then
begin
if WaitFunc(@IsWalking, 2345, 345, True) then
begin
while IsWalking() do Wait(444);
end else
begin
Teleport();
end;
end;
end;

begin
ClearDebug();
Setup();
ActivateClient();
CashTimer := GetTickCount() + 1000000;
while True do Mainloop();
end.

imalama101
04-03-2018, 01:29 AM
No why you make this public? : (

Citrus
04-03-2018, 02:26 AM
No why you make this public? : (

I could have posted it in a higher board, but then you wouldn't be able to see it :spot:
I made this so others could look at it and hopefully learn something and write their own scripts. I don't know why you think you deserve to leech this exclusively.

Eyoo
05-04-2018, 09:55 PM
Getting this error: Error: You passed a wrong xe to a finder function: 762. The client has a width of 620, thus the xe is out of bounds. at line 225

Citrus
05-05-2018, 01:28 AM
Getting this error: Error: You passed a wrong xe to a finder function: 762. The client has a width of 620, thus the xe is out of bounds. at line 225

I don't remember that ever happening to me. :confused:
Is your OS not at 100% scale? Simba scripts won't work at anything other than 100%.
Is the client resizable? If so, then leave it at the default size with the side panel minimized.
That's all I can think of off the top of my head.

Eyoo
05-05-2018, 07:17 PM
I don't remember that ever happening to me. :confused:
Is your OS not at 100% scale? Simba scripts won't work at anything other than 100%.
Is the client resizable? If so, then leave it at the default size with the side panel minimized.
That's all I can think of off the top of my head.

My OS is at 100% scale, and the Client is not resizable

JSmooth
05-06-2018, 08:55 AM
My OS is at 100% scale, and the Client is not resizable

Did you select the right window pane for the client?

Eyoo
05-06-2018, 07:35 PM
Did you select the right window pane for the client?

Yeah

rencom
05-14-2018, 04:11 AM
Hey I seem to be having this issue.

"Variable "i" not used at line 50, column 19
Variable "x" not used at line 50, column 19
Variable "y" not used at line 50, column 19
Error: Can't assign "Int32" to "(False=0, True=1)" at line 175
Compiling failed."

Citrus
05-14-2018, 05:51 AM
Hey I seem to be having this issue.

"Variable "i" not used at line 50, column 19
Variable "x" not used at line 50, column 19
Variable "y" not used at line 50, column 19
Error: Can't assign "Int32" to "(False=0, True=1)" at line 175
Compiling failed."

That's because you're using Simba 1.2, and 1.1 is the default unless otherwise specified. But anyway, I edited the script.

rencom
05-14-2018, 06:31 AM
That's because you're using Simba 1.2, and 1.1 is the default unless otherwise specified. But anyway, I edited the script.

Oh I see, thanks for the quick reply!

rencom
05-14-2018, 06:48 AM
So did a little testing and what seems to happen is that, when the mouse cursor is on the stall it would auto click, but when it is not on a stall it will just keep using the teleport spell back to the stalls. Is there a line I'm missing where you enter what stall for the cursor to move too or is it a bug?

Citrus
05-14-2018, 12:58 PM
So did a little testing and what seems to happen is that, when the mouse cursor is on the stall it would auto click, but when it is not on a stall it will just keep using the teleport spell back to the stalls. Is there a line I'm missing where you enter what stall for the cursor to move too or is it a bug?

It will choose the stall based on your thieving level. It could be that the colors are wrong and that's why it isn't mousing over the stalls. Try updating the stall color in the script and see if that works.

shiftlid
05-20-2018, 12:55 AM
Going to try this out soon, thanks for the share

Eyoo
05-28-2018, 03:52 PM
Would be really Nice if you could explain to me what everything in the script is doing. would help me alot for sure :)

Citrus
05-28-2018, 04:52 PM
Would be really Nice if you could explain to me what everything in the script is doing. would help me alot for sure :)

Which parts are confusing? At a quick glance I didn't see any terribly named functions or anything difficult to read.

Eyoo
05-29-2018, 02:44 PM
im having problems With the script. its hovering over the stalls, but not clicking any of the stalls. just hovering over them, tele, checking Level tab, hovering over stalls and repeats.

duration
06-08-2018, 09:31 AM
This script is really cool could you please add me on discord I want to implement an add on but im lost trying to find some of the logic of the script thanks
ryan#8929

Citrus
06-08-2018, 02:40 PM
This script is really cool could you please add me on discord I want to implement an add on but im lost trying to find some of the logic of the script thanks
ryan#8929

I won't have a lot of free time for the next few days at least, so for now this thread is the best place for me to respond. I'll try to get on Discord when I can, but in the meantime just post any questions you have here and I'll answer if I have a minute.

vilius123
06-08-2018, 04:56 PM
I don't know anything about scripting but how do i make this work on spawnpk?

P1nky
06-08-2018, 04:59 PM
I don't know anything about scripting but how do i make this work on spawnpk?

Have you gone through this guide?:
https://villavu.com/forum/showthread.php?t=118223&p=1391739#post1391739

And if you have, tell us what the issue is by posting the error message or a description of what's going wrong.

vilius123
06-08-2018, 05:07 PM
how do i add spawnpk to simba?

Citrus
06-08-2018, 05:08 PM
Have you gone through this guide?:
https://villavu.com/forum/showthread.php?t=118223&p=1391739#post1391739

And if you have, tell us what the issue is by posting the error message or a description of what's going wrong.

That guide has nothing to do with this script... If anything you're doing more harm than good sending him there.

Vilius, you should be able to just copy the script into Simba and run it. You'll need to be logged into SpawnPK, and it might help to follow the instructions at the top of the script. I haven't tested this in months, so no idea how/if it still works.

vilius123
06-08-2018, 05:14 PM
Ok, let me ask you a question when i play the bot does my mouse have to be always in the region of the client? because every time i run it i can't move my mouse otherwise the bot will stop

Citrus
06-08-2018, 05:37 PM
Ok, let me ask you a question when i play the bot does my mouse have to be always in the region of the client? because every time i run it i can't move my mouse otherwise the bot will stop

The script will "take over" your mouse, as it uses Simba's default mouse functions. If you want to use your computer while running the script, you'll have to use a VM, RDP, or something similar.

RatIRL
06-13-2018, 12:19 AM
i dont understand how to use simba or the script i copy pasted like one dude said but it just clicks north then stops working anyway someone can add me on discord or something and help me run the script (discord name is:Gone Inside#7428)

RatIRL
06-14-2018, 05:21 PM
can you help me set it up when i copy and paste it into simba it just clicks north on the mini map and i dont know how to get it to work would really like it if you helped me sort of my issue

rencom
06-24-2018, 06:43 PM
Great script! It's also fantastic material to learn off of.

Thank you Citrus!

Wu-Tang Clan
07-02-2018, 09:04 PM
Sorry to ask but what exactly does the script do? I'm interested in trying this rsps out but I'm not sure about any of the money making methods

Citrus
07-03-2018, 01:57 AM
Sorry to ask but what exactly does the script do? I'm interested in trying this rsps out but I'm not sure about any of the money making methods

It thieves from the stalls next to the Edgeville bank.

rencom
07-05-2018, 07:23 AM
Hi Citrus,

So I seem to be having this issue with the script where when it tried to convert the money to cash bags it drops it instead.

So this is the part of your code that deals with that. I'm trying to figure out why it's doing that. If you could help me fix this or even better yet explain how you did it, that would be fantastic thanks!


function CashBags(): Boolean;
const
B: TBox = [553, 238, 738, 488];
GREEN_CASH = $80FF00;
var
x, y: Int32;
TPA: TPointArray;
begin
if (GetTickCount() < CashTimer) then Exit;
CashTimer := GetTickCount() + 1000000;
if ClickTab(4) then
begin
Wait(121);
if FindColor(x, y, GREEN_CASH, B.X1, B.Y1, B.X2, B.Y2) then
begin
Mouse(x + 9, y + 9, MOUSE_RIGHT);
Wait(121);
Result := ChooseOption('exchange');
end;
end;
end;

Citrus
07-05-2018, 01:27 PM
Hi Citrus,

So I seem to be having this issue with the script where when it tried to convert the money to cash bags it drops it instead.

So this is the part of your code that deals with that. I'm trying to figure out why it's doing that. If you could help me fix this or even better yet explain how you did it, that would be fantastic thanks!


function CashBags(): Boolean;
const
B: TBox = [553, 238, 738, 488];
GREEN_CASH = $80FF00;
var
x, y: Int32;
TPA: TPointArray;
begin
if (GetTickCount() < CashTimer) then Exit;
CashTimer := GetTickCount() + 1000000;
if ClickTab(4) then
begin
Wait(121);
if FindColor(x, y, GREEN_CASH, B.X1, B.Y1, B.X2, B.Y2) then
begin
Mouse(x + 9, y + 9, MOUSE_RIGHT);
Wait(121);
Result := ChooseOption('exchange');
end;
end;
end;

My best guess is that the ChooseOption function is the problem. Maybe some offset is wrong.

rencom
07-05-2018, 04:40 PM
My best guess is that the ChooseOption function is the problem. Maybe some offset is wrong.


Okay so aside from just fixing the script. How do I find offset values for the right click option interface thing (When you right click and choose the options, including drop, examine, etc.).

Also for the find color part, it's just to find the money bag in the inventory correct? and has nothing to do with choosing the option when right clicking.

RatIRL
07-08-2018, 09:35 PM
i cant seem to get your thieve script to work and ive left multiple comments on the forum post but i haven't gotten a response while others have? if there is anyway you can help me add my discord sksksksksksksksksk#7428 please and thanks

Citrus
07-09-2018, 01:01 AM
i cant seem to get your thieve script to work and ive left multiple comments on the forum post but i haven't gotten a response while others have? if there is anyway you can help me add my discord sksksksksksksksksk#7428 please and thanks

Sorry, I'm not maintaining this script anymore. If you don't know how to use Simba, there is a help/tutorial section of the forum.

RatIRL
07-20-2018, 04:13 AM
Sorry, I'm not maintaining this script anymore. If you don't know how to use Simba, there is a help/tutorial section of the forum.

i was told to copy paste the script and it did not work the tutorials arent much help either

rj
07-28-2018, 06:30 PM
i was told to copy paste the script and it did not work the tutorials arent much help either

your just gonna have to accept that you won't be botting on spawnpk

pkbotter
09-10-2018, 12:19 AM
Im having trouble trying to make it run more than once? how do i make it reloop the code a set number of times? I also have another script that i cant seem to figure out how to loop the code.

KeepBotting
09-10-2018, 01:03 AM
Im having trouble trying to make it run more than once? how do i make it reloop the code a set number of times? I also have another script that i cant seem to figure out how to loop the code.

Hi,

Loops are pretty simple. The FPC docs have a good page on them, http://wiki.freepascal.org/For

Here's an example of a simple loop


program new;
begin
while (true) do
begin
writeLn('This is a loop');
end;
end.