Jump to content
BryceTheCoder

Is it possible to draw on an OSI Runescape Script?

Recommended Posts

wanted ive been messing with this for a week, ive tried everything, it always leads back to an access error on this line SMART_Canvas.canvas.handle := SmartGetDC; ive tried a hundred different ways of setting the handle ive tried writeln the DC and inputting it that way (i know they are non static but they do stay the same for a little while), could it just be scar and smart since the new version arnt clicking?

Link to comment
Share on other sites

Is the SMART_Canvas object actually created before doing this?

 

I don't know if this is part of OSI or anything... But before you can actually use SMART_Canvas, it needs to be assigned a canvas object:

SMART_Canvas := TCanvas.Create(nil);

 

Before the script terminates it also has to be destroyed with:

SMART_Canvas.Free;

 

If the object wasn't initialized, that could be the reason for your error.

 

EDIT: Actually, now that I look closer, what is SMART_Canvas? it isn't a TCanvas object because then it wouldn't have a canvas field of it's own...

Link to comment
Share on other sites

Is the SMART_Canvas object actually created before doing this?

 

I don't know if this is part of OSI or anything... But before you can actually use SMART_Canvas, it needs to be assigned a canvas object:

SMART_Canvas := TCanvas.Create(nil);

 

Before the script terminates it also has to be destroyed with:

SMART_Canvas.Free;

 

If the object wasn't initialized, that could be the reason for your error.

 

EDIT: Actually, now that I look closer, what is SMART_Canvas? it isn't a TCanvas object because then it wouldn't have a canvas field of it's own...

 

yes it is declarded as a Tbitmap, heres the code:

(This complies jsut fine but when it runs it gets a read access violation in scar.exe)

var
 SMART_Canvas: TBitmap;
 SMART_DebugSetup: Boolean;

procedure SMART_SetupDebug();
begin
 SmartSetDebug(True);
 SMART_Canvas := TBitmap.Create;
 SMART_Canvas.canvas.handle := SmartGetDC;
 SMART_DebugSetup := true;
end; 

 

ive tried doing this 100 different ways just in seting up the handle, not only in the method, ive tried tcanvas but get the same error.

 

---------- Post added at 05:15 AM ---------- Previous post was at 05:12 AM ----------

 

I guess I'll come out with a RS2\Misc\SMARTDebug.scar

 

i can handle the drawing and ect i just need the object to draw on, this is the problem. i cant get the handle of the direct content or DC which is the windows api address or something like that, basically the address of the window. i have tried writeln the address and i do get a number from it and manualy entering that number does nothing but give me the same error.. =/ i can make a debug window and draw on it, just cant draw on smarts canvas

Link to comment
Share on other sites

i can handle the drawing and ect i just need the object to draw on, this is the problem. i cant get the handle of the direct content or DC which is the windows api address or something like that, basically the address of the window. i have tried writeln the address and i do get a number from it and manualy entering that number does nothing but give me the same error.. =/ i can make a debug window and draw on it, just cant draw on smarts canvas
That's as far as I got as well before throwing up my hands and walking away. I have all the code for doing the drawing from old scripts, which I was trying to adapt to SCAR, but without the ability to get the object to draw on you're hooped.
Link to comment
Share on other sites

I think he misses the point: Code that should work (and does work with Simba) generates an access violation in SCAR. Using SMART with SCAR is different than using SMART with Simba somehow.

 

That's incorrect, you guys just don't know how to do it. I've drawn on SMART plenty of times, so have many others... long before simba existed.

Link to comment
Share on other sites

Agree w/ wanted. god there are MANY MANY examples out there. why is everyone having such problems. yet then again who even wants to spend that much effort on a bot like that. what are you producing 1 bot every 2 months ? Have to think about what your intentions are. making it look pretty or making it work well.

 

If you try to do both your in for a very good bot, but expect high maintenance in the long run.

 

Me, I make sure the bots work 100% and maybe maybe put a gui screen on em.

Link to comment
Share on other sites

can you help me with this wanted please:

under varialbes: Canvas: TCanvas;

 

and my code:

 

Canvas := GetBitmapCanvas(TempBMP);

Canvas.Brush.Style := bsSolid;

Canvas.Brush.Color := clBlack;

Canvas.Pen.Color := clBlack;

Canvas.Rectangle(309, 197, 422, 255);

 

I get an error on my "TempBMP"

Wut do i put TempBMP as? a variable of somesort ooorrr wuut?:/

Link to comment
Share on other sites

program New;
var
 bmp: Integer;
 canvas: TCanvas;
begin
 bmp := BitmapFromString(50, 50, '');
 Canvas := TCanvas.Create;
 Canvas := GetBitmapCanvas(bmp);
 Canvas.Brush.Color := clRed;
 Canvas.Rectangle(25, 25, 45, 45);
 DisplayDebugImgWindow(50, 50);
 DebugBitmap(bmp);
end.

I know you had good intentions but displaying a debug window is not the same thing as drawing on the SMART canvas. Displaying the debug window is easy and not what is being asked here.

 

That's incorrect, you guys just don't know how to do it. I've drawn on SMART plenty of times, so have many others... long before simba existed.
So have I. Unfortunately I don't have those scripts around anymore. The examples I can find generate access violations using the latest version of SCAR and SMART.

 

I mean this in the nicest possible way when I say "put up or shut up". :P

 

People are looking for a working example of how to get the SMART canvas and work with it. What they are getting instead is a lot of people saying "It's easy really but I'm not going to show you how to do it." Small wonder they are getting frustrated.

Link to comment
Share on other sites

Agree w/ wanted. god there are MANY MANY examples out there. why is everyone having such problems. yet then again who even wants to spend that much effort on a bot like that. what are you producing 1 bot every 2 months ? Have to think about what your intentions are. making it look pretty or making it work well.

 

If you try to do both your in for a very good bot, but expect high maintenance in the long run.

 

Me, I make sure the bots work 100% and maybe maybe put a gui screen on em.

 

This is incorrect as there are only about 3 ways to assign a handle to an object, either by locating the bitmap onscreen, using some function made for it(eg. GetSmartDc) or by windows size i think?

 

And drawing on the canvas has many good possibilities as you can debug actively while running the script, print boxes around colors, show Tboxs ect alot of good useful information that in the long run can make a script that runs better with less downtime

 

---------- Post added at 05:10 PM ---------- Previous post was at 05:08 PM ----------

 

That's incorrect, you guys just don't know how to do it. I've drawn on SMART plenty of times, so have many others... long before simba existed.

 

ive drawn on smart to back in the day, but it doesnt work anymore, we dont need lessons for drawing on it, we just need the canvas, I can draw on debug windows all day, but cant get the canvas handle for smart. This must require some weird way of getting other then the conventional way because the conventional ways report access errors within scar

 

---------- Post added at 05:14 PM ---------- Previous post was at 05:10 PM ----------

 

I think he misses the point: Code that should work (and does work with Simba) generates an access violation in SCAR. Using SMART with SCAR is different than using SMART with Simba somehow.

 

i think everyone is missing the point, everyone keeps say oh its easy! a million ways to do it! but i dont see one person posting anything useful but comments on how its so easy.. lmao..

Link to comment
Share on other sites

Look, here's ancient 2 year old pre-simba code Timer wrote for POMS that with removing obvious things to make it work with OSI is STILL AFTER 2 YEARS working beautifully

 

http://srlpoms.googlecode.com/svn/trunk/Includes/Debug.scar

 

program New;

{$DEFINE RS2}
{$DEFINE OSI_Color_Anti_Randoms}
{$DEFINE SMART}                   // Comment out to disable SMART

{$I OSI\OSI.scar}
{$I OSI\Divi\Misc\Debug.scar}

procedure ScriptTerminate;
begin
 FreeOSI;
end;

//By Timer

var
 POMS_SCRIPT: string;
 POMS_VARIABLES: TStringArray;

{$DEFINE POMS_DEBUG}

procedure POMS_DebugLine(_text: string);
begin
 {$IFNDEF LIMIT_TEXT}
   WriteLn('[' + STimeRunning + '] : ' + _text);
 {$ENDIF}
end;

procedure ClearSMARTCanvas;
var
 SCanvas, Canvas: TCanvas;
 BMP, BMP2, I, II, III: Integer;
 TPA: TPointArray;
begin
 try
   POMS_DEBUGLINE('Clearing SMART Canvas....');
   BMP := BitmapFromString(765, 503, '');
   SCanvas := GetBitmapCanvas(BMP);
   SCanvas.handle := SmartGetDebugDC;
   BMP2 := BitmapFromString(765, 503, '');
   TPA := LoadTextTPA('POMS rev' + IntToStr(1), StatChars);
   for I := 0 to High(TPA) do
     FastSetPixel(BMP2, TPA[i].x + 25, TPA[i].y + 35, clWhite);
   TPA := LoadTextTPA(POMS_SCRIPT, StatChars);
   for I := 0 to High(TPA) do
     FastSetPixel(BMP2, TPA[i].x + 25, TPA[i].y + 45, clWhite);
   for II := 0 to High(POMS_VARIABLES) do
   begin
     TPA := LoadTextTPA(POMS_VARIABLES[iI], StatChars);
     for III := 0 to High(TPA) do
       FastSetPixel(BMP2, TPA[iII].x + 25, TPA[iII].y + 35 + ((II + 3) * 10), clWhite);
   end;
   Canvas := GetBitmapCanvas(BMP2);
   CopyCanvas(Canvas, SCanvas, 0, 0, 765, 503, 0, 0, 765, 503);
   FreeBitmap(BMP);
   FreeBitmap(BMP2);
   POMS_DEBUGLINE('Cleared SMART Canvas!!');
 except end;
end;

procedure DebugTPA2(TPA: TPointArray);
var
 SCanvas, Canvas: TCanvas;
 BMP, BMP2, I, Usless, II, III: Integer;
 TPAA: TPointArray;
begin
 try
   POMS_DEBUGLINE('Found ' + IntToStr(Length(TPA)) + ' colours!');
   POMS_DEBUGLINE('Debugging TPA!');
   BMP := BitmapFromString(765, 503, '');
   SCanvas := GetBitmapCanvas(BMP);
   SCanvas.handle := SmartGetDebugDC;
   BMP2 := BitmapFromString(765, 503, '');
   for I := 0 to High(TPA) do
     FastSetPixel(BMP2, TPA[i].x, TPA[i].y, clRed);
   TPAA := LoadTextTPA('POMS rev' + IntToStr(1), StatChars);
   for I := 0 to High(TPAA) do
     FastSetPixel(BMP2, TPAA[i].x + 25, TPAA[i].y + 35, clWhite);
   TPAA := LoadTextTPA(POMS_SCRIPT, StatChars);
   for I := 0 to High(TPAA) do
     FastSetPixel(BMP2, TPAA[i].x + 25, TPAA[i].y + 45, clWhite);
   for II := 0 to High(POMS_VARIABLES) do
   begin
     TPAA := LoadTextTPA(POMS_VARIABLES[iI], StatChars);
     for III := 0 to High(TPAA) do
       FastSetPixel(BMP2, TPAA[iII].x + 25, TPAA[iII].y + 35 + ((II + 3) * 10), clWhite);
   end;
   Canvas := GetBitmapCanvas(BMP2);
   CopyCanvas(Canvas, SCanvas, 0, 0, 765, 503, 0, 0, 765, 503);
   FreeBitmap(BMP);
   FreeBitmap(BMP2);
   POMS_DEBUGLINE('Debuged TPA Successfully!');
 except
 end;
end;

begin
 SetUpOSI;
 ClearSMARTCanvas;
 DebugTPA2(TPAFromBox(Box(0, 0, 100, 100)));
end.

 

(Make sure your smart says 'disable debug' and not 'enable debug' because otherwise you won't see anything)

 

Have ye ole leader some faith

Link to comment
Share on other sites

Look, here's ancient 2 year old pre-simba code Timer wrote for POMS that with removing obvious things to make it work with OSI is STILL AFTER 2 YEARS working beautifully

 

http://srlpoms.googlecode.com/svn/trunk/Includes/Debug.scar

 

program New;

{$DEFINE RS2}
{$DEFINE OSI_Color_Anti_Randoms}
{$DEFINE SMART}                   // Comment out to disable SMART

{$I OSI\OSI.scar}
{$I OSI\Divi\Misc\Debug.scar}

procedure ScriptTerminate;
begin
 FreeOSI;
end;

//By Timer

var
 POMS_SCRIPT: string;
 POMS_VARIABLES: TStringArray;

{$DEFINE POMS_DEBUG}

procedure POMS_DebugLine(_text: string);
begin
 {$IFNDEF LIMIT_TEXT}
   WriteLn('[' + STimeRunning + '] : ' + _text);
 {$ENDIF}
end;

procedure ClearSMARTCanvas;
var
 SCanvas, Canvas: TCanvas;
 BMP, BMP2, I, II, III: Integer;
 TPA: TPointArray;
begin
 try
   POMS_DEBUGLINE('Clearing SMART Canvas....');
   BMP := BitmapFromString(765, 503, '');
   SCanvas := GetBitmapCanvas(BMP);
   SCanvas.handle := SmartGetDebugDC;
   BMP2 := BitmapFromString(765, 503, '');
   TPA := LoadTextTPA('POMS rev' + IntToStr(1), StatChars);
   for I := 0 to High(TPA) do
     FastSetPixel(BMP2, TPA[i].x + 25, TPA[i].y + 35, clWhite);
   TPA := LoadTextTPA(POMS_SCRIPT, StatChars);
   for I := 0 to High(TPA) do
     FastSetPixel(BMP2, TPA[i].x + 25, TPA[i].y + 45, clWhite);
   for II := 0 to High(POMS_VARIABLES) do
   begin
     TPA := LoadTextTPA(POMS_VARIABLES[iI], StatChars);
     for III := 0 to High(TPA) do
       FastSetPixel(BMP2, TPA[iII].x + 25, TPA[iII].y + 35 + ((II + 3) * 10), clWhite);
   end;
   Canvas := GetBitmapCanvas(BMP2);
   CopyCanvas(Canvas, SCanvas, 0, 0, 765, 503, 0, 0, 765, 503);
   FreeBitmap(BMP);
   FreeBitmap(BMP2);
   POMS_DEBUGLINE('Cleared SMART Canvas!!');
 except end;
end;

procedure DebugTPA2(TPA: TPointArray);
var
 SCanvas, Canvas: TCanvas;
 BMP, BMP2, I, Usless, II, III: Integer;
 TPAA: TPointArray;
begin
 try
   POMS_DEBUGLINE('Found ' + IntToStr(Length(TPA)) + ' colours!');
   POMS_DEBUGLINE('Debugging TPA!');
   BMP := BitmapFromString(765, 503, '');
   SCanvas := GetBitmapCanvas(BMP);
   SCanvas.handle := SmartGetDebugDC;
   BMP2 := BitmapFromString(765, 503, '');
   for I := 0 to High(TPA) do
     FastSetPixel(BMP2, TPA[i].x, TPA[i].y, clRed);
   TPAA := LoadTextTPA('POMS rev' + IntToStr(1), StatChars);
   for I := 0 to High(TPAA) do
     FastSetPixel(BMP2, TPAA[i].x + 25, TPAA[i].y + 35, clWhite);
   TPAA := LoadTextTPA(POMS_SCRIPT, StatChars);
   for I := 0 to High(TPAA) do
     FastSetPixel(BMP2, TPAA[i].x + 25, TPAA[i].y + 45, clWhite);
   for II := 0 to High(POMS_VARIABLES) do
   begin
     TPAA := LoadTextTPA(POMS_VARIABLES[iI], StatChars);
     for III := 0 to High(TPAA) do
       FastSetPixel(BMP2, TPAA[iII].x + 25, TPAA[iII].y + 35 + ((II + 3) * 10), clWhite);
   end;
   Canvas := GetBitmapCanvas(BMP2);
   CopyCanvas(Canvas, SCanvas, 0, 0, 765, 503, 0, 0, 765, 503);
   FreeBitmap(BMP);
   FreeBitmap(BMP2);
   POMS_DEBUGLINE('Debuged TPA Successfully!');
 except
 end;
end;

begin
 SetUpOSI;
 ClearSMARTCanvas;
 DebugTPA2(TPAFromBox(Box(0, 0, 100, 100)));
end.

 

(Make sure your smart says 'disable debug' and not 'enable debug' because otherwise you won't see anything)

 

Have ye ole leader some faith

 

You are the Fucking man! (Sorry had to make it clear your the shit, a fellow Texan ;) Now i think i see what you were doing is using the GetSmartDebugDC for the handle instead of GetSmartDc... which i think is where everyone problem lied. Thanks Man, i will be kicking back and playing with this for the rest of the weekend!

Link to comment
Share on other sites

yeah i guess but its all good now, and im loving this =) so much useful info can can be printed actively not to include make things look a little better =)look the road colors lit up like some thing .. lol you can clearly see where its finding active colors ect. this is an awesome addition!

[ATTACH=CONFIG]230[/ATTACH]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...