Jump to content
Incommodious

Quick Scripting help? :)

Recommended Posts

I dont know if this is posted in the write spot in the forums but here it is.

I am making a script for a game called Endless Online and i have multiple scripts for it but i decided i want to make my own so ive been learning about scar (im using 3.36 newest) and im making my own scripts. I came to a stop when i was trying to make a little script that will press f2 then releas f2 after about half a second then click on a color that it finds. my error says: Type Mismatch but no idea what to do, somone help (if possible also fix it for proper indenting and such)? It works in Scar 3.12 but not in 3.36. I need it to work for 3.36 cause when this is done im going to turn it into a procedure and plug it into my other script.

 

This is my script:

 

Program Mage;

var

x, y, z, monster1: Integer;

begin

monster1:= 1638350;

z:=0;

repeat

if(FindColor(x, y, monster1,324,171,955,651))then

begin

keydown(113);

wait(550)

KeyUp(113);

clickmouse(x, y, true)

wait(850)

end

until(x = 5000000)

end.

Link to comment
Share on other sites

I have modified your code

 

Program Mage;
var
 x, y, z, monster1: Integer;
 Bln: Boolean;
begin
 monster1:= 1638350;
 z:=0;
 repeat 
   begin
     Bln := FindColor(x, y, monster1,324,171,955,651); 
     if ( Bln) then
     begin  
       PressVKeyEx(VK_F2, 550);
       clickmouse(x, y, true)
       wait(850)
     end    
   end
 until(x = 5000000)
end.

Edited by TroisVerites
Link to comment
Share on other sites

I've fixed your script. There's been several API changes in 3.35 that break most scripts from older versions. Usually updating them isn't all that hard though.

 

[scar]program Mage;

const

monster1 = 1638350;

var

x, y: Integer;

begin

repeat

if FindColor(x, y, monster1, 324, 171, 955, 651) then

begin

VKeyDown(113);

Wait(550);

VKeyUp(113);

ClickMouse(x, y, mbLeft);

Wait(850);

end;

until False;

end.[/scar]

 

I also made a few changes. Since monster1 never changes in your script aside from the initial assignment, I've made this a constant. I've made it loop infinitely, as I'm assuming that was the point of the "until x = 5000000".

 

EDIT: Looks like I was ninja'd for a change

Edited by Freddy
Link to comment
Share on other sites

that looks a lot cleaner thank you :) instead of using KeyUp or KeyDown has it been changed to VKeyUP and VKeyDown? and whats the difference between ClickMouse(x, y, bmLeft) and ClickMouse(x, y, true/false)?

 

KeyDown/KeyUp now take characters and send unicode input. For TSCARWindowClient, VKeyDown and VKeyUp are now essentially the same as the old KeyDown/KeyUp. ClickMouse is now defined with a TMouseButton parameter instead of a boolean for the last one. Before the boolean would be True for left clicking and False for right clicking, but now you have to pass mbLeft, mbRight or mbMiddle.

Link to comment
Share on other sites

oh sweet. Now one thing. For some scripts ive used in the past whenever i pressed play there would be a box that pops up and there would be stuff in the box that you can check or uncheck meaning on or off but is there a way for a box like that that will pop up and in the box the stuff you can change will be the const's for ex.

 

const

 

User='Username';

Pass='Password';

 

Character=1; //either 1 2 or 3

 

instead of changing the Username Password or number in the script you can change them in the box that appears

Link to comment
Share on other sites

Something like this: If you open this script in Scar 3.12 or something erlyer like that cause it hasnt been updated or anything, i got this a few years ago. but what im looking for is the pop up box like this script has but also another feature in the box where there is a spot for: Entering User+Pass, Character Number, and soon to be what f-key Mage is on and what f-key healing is on.

 

Code:

 

[scar]program Afk;

Var s,x,y,z,Px,Py,d:Integer; frmDesign : TForm;

CheckBox1, CheckBox2, CheckBox3, CheckBox4, CheckBox5, CheckBox6 : TCheckBox;

Button1 : TButton; RichEdit1 : TRichEdit; Block1,Block2,MonstB: TBox;

Ary:array[1..6]of Integer; Lockl,Lockr,Locku,Lockd,M,M1,M2,HitBool:Boolean;

const

HPC=44345;

Monst=1638350;

procedure ButtonClick(sender: TObject);

begin

If CheckBox1.Checked=True then Ary[1]:=1;

If CheckBox2.Checked=True then Ary[2]:=1;

If CheckBox3.Checked=True then Ary[3]:=1;

If CheckBox4.Checked=True then Ary[4]:=1;

If CheckBox5.Checked=True then Ary[5]:=1;

If CheckBox6.Checked=True then Ary[6]:=1;

frmDesign.ModalResult:= mrOk;

end;

 

procedure InitForm;

begin

frmDesign := CreateForm;

frmDesign.Left := 387;

frmDesign.Top := 267;

frmDesign.BorderIcons := [biSystemMenu];

frmDesign.BorderStyle := bsNone;

frmDesign.Caption := 'frmDesign';

frmDesign.ClientHeight := 193;

frmDesign.ClientWidth := 104;

frmDesign.Color := clMedGray;

frmDesign.Font.Color := clWindowText;

frmDesign.Font.Height := -11;

frmDesign.Font.Name := 'MS Sans Serif';

frmDesign.Font.Style := [];

frmDesign.Visible := False;

frmDesign.PixelsPerInch := 96;

CheckBox1 := TCheckBox.Create(frmDesign);

CheckBox1.Parent := frmDesign;

CheckBox1.Left := 4;

CheckBox1.Top := 4;

CheckBox1.Width := 97;

CheckBox1.Height := 17;

CheckBox1.Caption := 'Pick Up Items';

CheckBox1.TabOrder := 8;

CheckBox2 := TCheckBox.Create(frmDesign);

CheckBox2.Parent := frmDesign;

CheckBox2.Checked := True;

CheckBox2.Left := 4;

CheckBox2.Top := 19;

CheckBox2.Width := 97;

CheckBox2.Height := 17;

CheckBox2.Caption := 'AutoHeal/Pot';

CheckBox2.TabOrder := 9;

CheckBox3 := TCheckBox.Create(frmDesign);

CheckBox3.Parent := frmDesign;

CheckBox3.Checked := True;

CheckBox3.Left := 4;

CheckBox3.Top := 34;

CheckBox3.Width := 47;

CheckBox3.Height := 17;

CheckBox3.Caption := 'Left';

CheckBox3.TabOrder := 10;

CheckBox4 := TCheckBox.Create(frmDesign);

CheckBox4.Parent := frmDesign;

CheckBox4.Checked := True;

CheckBox4.Left := 4;

CheckBox4.Top := 49;

CheckBox4.Width := 47;

CheckBox4.Height := 17;

CheckBox4.Caption := 'Down';

CheckBox4.TabOrder := 11;

CheckBox5 := TCheckBox.Create(frmDesign);

CheckBox5.Parent := frmDesign;

CheckBox5.Checked := True;

CheckBox5.Left := 57;

CheckBox5.Top := 34;

CheckBox5.Width := 47;

CheckBox5.Height := 17;

CheckBox5.Caption := 'Up';

CheckBox5.TabOrder := 12;

CheckBox6 := TCheckBox.Create(frmDesign);

CheckBox6.Parent := frmDesign;

CheckBox6.Checked := True;

CheckBox6.Left := 57;

CheckBox6.Top := 49;

CheckBox6.Width := 47;

CheckBox6.Height := 17;

CheckBox6.Caption := 'Right';

CheckBox6.TabOrder := 13;

Button1 := TButton.Create(frmDesign);

Button1.Parent := frmDesign;

Button1.Left := 0;

Button1.Top := 65;

Button1.Width := 104;

Button1.Height := 33;

Button1.Caption := 'Start!';

Button1.TabOrder := 14;

Button1.OnClick := @ButtonClick;

RichEdit1 := TRichEdit.Create(frmDesign);

RichEdit1.Parent := frmDesign;

RichEdit1.Left := 0;

RichEdit1.Top := 97;

RichEdit1.Width := 104;

RichEdit1.Height := 96;

RichEdit1.Lines.Add('AltBot Created By Meekl For EoBots');

RichEdit1.Lines.Add('');

RichEdit1.Lines.Add('');

RichEdit1.Lines.Add('');

RichEdit1.Lines.Add('Scar 3.12');

RichEdit1.Lines.Add('EoBots-Online.com');

RichEdit1.TabOrder := 15;

end;

 

procedure SafeInitForm;

var

v: TVariantArray;

begin

setarraylength(V, 0);

ThreadSafeCall('InitForm', v);

end;

 

procedure ShowFormModal;

begin

frmDesign.ShowModal;

end;

 

procedure SafeShowFormModal;

var

v: TVariantArray;

begin

setarraylength(V, 0);

ThreadSafeCall('ShowFormModal', v);

end;

 

 

procedure Item;

begin

If (FindColorSpiral(x,y,8716032,241,153,822,465)) and (Not(FindColor(x,y,Monst,15,65,625,332))) then

begin

MoveMouse(x,y)

Wait(20)

ClickMouse(x,y,True)

Wait(1000)

end;

end;

 

procedure Pot;

begin

If (Not(GetColor(204,33)=HPC)) then

begin

If (Not(FindColor(x,y,Monst,15,65,625,332))) then

begin

KeyDown(119)

Repeat

Wait(10)

Until (FindColor(x,y,Monst,15,65,625,332)) or (GetColor(204,33)=HPC)

KeyUp(119)

Wait(1000)

end;

If (Not(GetColor(153,33)=HPC)) and (FindColor(Px,Py,33412,112,363,475,466)) then

begin

MoveMouse(Px,Py)

Wait(10)

ClickMouse(Px,Py,True)

Wait(100)

ClickMouse(Px,Py,True)

Wait(1000)

end else

begin

z:=1;

end;

If (Not(GetColor(153,33)=HPC)) and (z=1) then

begin

KeyDown(119)

Repeat

Wait(10)

Until GetColor(204,33)=HPC

KeyUp(119)

end;

end;

z:=0

end;

 

procedure UnLock;

begin

If (not(FindColorSpiral(x,y,Monst,15,65,625,332))) Then

begin

Lockl:=False; Locku:=False; Lockd:=False; Lockr:=False;

Block1:=IntToBox(0,0,0,0); Block2:=IntToBox(0,0,0,0);

end;

end;

 

procedure MBox;

begin

If FindColor(x,y,Monst,15,65,625,332) then

begin

If (FindColorSkipBox(x,y,Monst,x,y,x,y,MonstB)) and (FindColorSkipBox(x,y,Monst,x,y,x,y,Block1)) and (FindColorSkipBox(x,y,Monst,x,y,x,y,Block2)) Then

begin

M:=True;

end;

end;

end;

 

procedure MKsProc;

begin

d:=0;

If M1=False then

begin

Block1:=IntToBox(x-50,y-40,x+50,y+40);

M1:=True; M2:=False;

d:=1;

end;

If (M2=False) and (d=0) then

begin

Block2:=IntToBox(x-50,y-40,x+50,y+40);

M1:=False; M2:=True;

end;

end;

 

procedure Mage;

begin

M:=False;

MBox;

If (M=True) Then

begin

KeyDown(113)

Wait(20)

KeyUp(113)

MoveMouse(x,y)

Wait(20)

ClickMouse(x,y,True)

Wait(1800)

If GetColor(313,486)=0 then MKsProc;

end;

end;

 

procedure Hitl;

begin

If (FindColor(x,y,Monst,287,157,293,163)) and (Lockl=False) then

begin

If (not(s=1)) then

begin

KeyDown(37)

Wait(300)

KeyUp(37)

s:=1;

end;

Wait(300)

KeyDown(17)

repeat

Wait(200)

If GetColor(313,486)=0 then Lockl:=True;

Until (Not(FindColor(x,y,Monst,287,157,293,163))) or (Not(GetColor(153,33)=HPC)) or (Lockl=True)

KeyUp(17)

Wait(600)

HitBool:=True;

end;

Wait(50)

end;

 

procedure Hitu;

begin

If (FindColor(x,y,Monst,342,157,348,163)) and (Locku=False) then

begin

If (not(s=2)) then

begin

KeyDown(38)

Wait(300)

KeyUp(38)

s:=2;

end;

Wait(300)

KeyDown(17)

repeat

Wait(200)

If GetColor(313,486)=0 then Locku:=True;

Until (Not(FindColor(x,y,Monst,342,157,348,163))) or (Not(GetColor(153,33)=HPC)) or (Locku=True)

KeyUp(17)

Wait(600)

HitBool:=True;

end;

Wait(50)

end;

 

procedure Hitr;

begin

If (FindColor(x,y,Monst,342,188,348,194)) and (Lockr=False) then

begin

If (not(s=3)) then

begin

KeyDown(39)

Wait(300)

KeyUp(39)

s:=3;

end;

Wait(300)

KeyDown(17)

repeat

Wait(200)

If GetColor(313,486)=0 then Lockr:=True;

Until (Not(FindColor(x,y,Monst,342,188,348,194))) or (Not(GetColor(153,33)=HPC)) or (Lockr=True)

KeyUp(17)

Wait(600)

HitBool:=True;

end;

Wait(50)

end;

 

procedure Hitd;

begin

If (FindColor(x,y,Monst,287,188,293,194)) and (Lockd=False) then

begin

If (not(s=4)) then

begin

KeyDown(40)

Wait(300)

KeyUp(40)

s:=4;

end;

Wait(300)

KeyDown(17)

repeat

Wait(200)

If GetColor(313,486)=0 then LockD:=True;

Until (Not(FindColor(x,y,Monst,287,188,293,194))) or (Not(GetColor(153,33)=HPC)) or (Lockd=True)

KeyUp(17)

Wait(600)

HitBool:=True;

end;

Wait(50)

end;

 

procedure Print;

begin

Wait(2000);

ClearDebug;

WriteLn('AltBot.5')

WriteLn('Created by Denryuu of EoBots-Online')

Writeln('Maging On')

If (ary[1]=1)then Writeln('Items On') else Writeln('Items Off')

If (ary[2]=1)then Writeln('Healing On') else Writeln('Healing Off')

If (ary[3]=1)then Writeln('LHit On') else Writeln('LHit Off')

If (ary[5]=1)then Writeln('UHit On') else Writeln('UHit Off')

If (ary[6]=1)then Writeln('RHit On') else Writeln('RHit Off')

If (ary[4]=1)then Writeln('DHit On') else Writeln('DHit Off')

end;

 

procedure All;

begin

Mage;

UnLock;

If (ary[1]=1)then Item;

If (ary[2]=1)then Pot;

Repeat

HitBool:=False;

KeyDown(113)

Wait(20)

KeyUp(113)

If (ary[3]=1)then Hitl;

If (ary[5]=1)then Hitu;

If (ary[6]=1)then Hitr;

If (ary[4]=1)then Hitd;

until(HitBool=False)or(IsFKeyDown(9)=True)

Wait(20);

end;

 

begin

SafeInitForm;

SafeShowFormModal;

FreeForm(frmDesign);

ClearDebug;

WriteLn('- AltBot.5 Public -')

WriteLn('- Created by Denryuu of EoBots-Online -')

WriteLn('- With help from Console of EoBots-Online -')

WriteLn('- Enjoy -')

Print;

Block1:=IntToBox(0,0,0,0);

Block2:=IntToBox(0,0,0,0);

MonstB:=IntToBox(375,207,262,137);

FindWindow('Endless Online')

ActivateClient;

Wait(300);

ClickMouse(77,364,True)

Repeat

All;

Until(IsFKeyDown(9)=True)

end.[/scar]

Edited by Freddy
Link to comment
Share on other sites

You mean a form? That can get fairly complex to make if you don't have a lot of experience writing scripts yet. You can access the form designer in the tools menu, when you design the form, it will give you the ability to output it as a scar script which you cna integrate with your code. If you want to start out easier, you can try the ReadLn function.

Link to comment
Share on other sites

i never knew about that form thing before thats prety nifty haha if i make the whole design or whatever do i still have to write the code for it or does it do that automaticly?

 

It can generate the code to create the form and display it, but nothing more. You have to write the code to get data from it.

Link to comment
Share on other sites

Hmm, well here is the one for the script you posted:

 

vayC1.png

 

here is the code I ran just in case you're interested in it:

 

[scar]

program Afk;

Var s,x,y,z,Px,Py,d:Integer; frmDesign : TForm;

CheckBox1, CheckBox2, CheckBox3, CheckBox4, CheckBox5, CheckBox6 : TCheckBox;

Button1 : TButton; RichEdit1 : TRichEdit; Block1,Block2,MonstB: TBox;

Ary:array[1..6]of Integer; Lockl,Lockr,Locku,Lockd,M,M1,M2,HitBool:Boolean;

const

HPC=44345;

Monst=1638350;

procedure ButtonClick(sender: TObject);

begin

If CheckBox1.Checked=True then Ary[1]:=1;

If CheckBox2.Checked=True then Ary[2]:=1;

If CheckBox3.Checked=True then Ary[3]:=1;

If CheckBox4.Checked=True then Ary[4]:=1;

If CheckBox5.Checked=True then Ary[5]:=1;

If CheckBox6.Checked=True then Ary[6]:=1;

frmDesign.ModalResult:= mrOk;

end;

 

procedure InitForm;

begin

frmDesign := CreateForm;

frmDesign.Left := 387;

frmDesign.Top := 267;

frmDesign.BorderIcons := [biSystemMenu];

frmDesign.BorderStyle := bsNone;

frmDesign.Caption := 'frmDesign';

frmDesign.ClientHeight := 193;

frmDesign.ClientWidth := 104;

frmDesign.Color := clMedGray;

frmDesign.Font.Color := clWindowText;

frmDesign.Font.Height := -11;

frmDesign.Font.Name := 'MS Sans Serif';

frmDesign.Font.Style := [];

frmDesign.Visible := False;

frmDesign.PixelsPerInch := 96;

CheckBox1 := TCheckBox.Create(frmDesign);

CheckBox1.Parent := frmDesign;

CheckBox1.Left := 4;

CheckBox1.Top := 4;

CheckBox1.Width := 97;

CheckBox1.Height := 17;

CheckBox1.Caption := 'Pick Up Items';

CheckBox1.TabOrder := 8;

CheckBox2 := TCheckBox.Create(frmDesign);

CheckBox2.Parent := frmDesign;

CheckBox2.Checked := True;

CheckBox2.Left := 4;

CheckBox2.Top := 19;

CheckBox2.Width := 97;

CheckBox2.Height := 17;

CheckBox2.Caption := 'AutoHeal/Pot';

CheckBox2.TabOrder := 9;

CheckBox3 := TCheckBox.Create(frmDesign);

CheckBox3.Parent := frmDesign;

CheckBox3.Checked := True;

CheckBox3.Left := 4;

CheckBox3.Top := 34;

CheckBox3.Width := 47;

CheckBox3.Height := 17;

CheckBox3.Caption := 'Left';

CheckBox3.TabOrder := 10;

CheckBox4 := TCheckBox.Create(frmDesign);

CheckBox4.Parent := frmDesign;

CheckBox4.Checked := True;

CheckBox4.Left := 4;

CheckBox4.Top := 49;

CheckBox4.Width := 47;

CheckBox4.Height := 17;

CheckBox4.Caption := 'Down';

CheckBox4.TabOrder := 11;

CheckBox5 := TCheckBox.Create(frmDesign);

CheckBox5.Parent := frmDesign;

CheckBox5.Checked := True;

CheckBox5.Left := 57;

CheckBox5.Top := 34;

CheckBox5.Width := 47;

CheckBox5.Height := 17;

CheckBox5.Caption := 'Up';

CheckBox5.TabOrder := 12;

CheckBox6 := TCheckBox.Create(frmDesign);

CheckBox6.Parent := frmDesign;

CheckBox6.Checked := True;

CheckBox6.Left := 57;

CheckBox6.Top := 49;

CheckBox6.Width := 47;

CheckBox6.Height := 17;

CheckBox6.Caption := 'Right';

CheckBox6.TabOrder := 13;

Button1 := TButton.Create(frmDesign);

Button1.Parent := frmDesign;

Button1.Left := 0;

Button1.Top := 65;

Button1.Width := 104;

Button1.Height := 33;

Button1.Caption := 'Start!';

Button1.TabOrder := 14;

Button1.OnClick := @ButtonClick;

RichEdit1 := TRichEdit.Create(frmDesign);

RichEdit1.Parent := frmDesign;

RichEdit1.Left := 0;

RichEdit1.Top := 97;

RichEdit1.Width := 104;

RichEdit1.Height := 96;

RichEdit1.Lines.Add('AltBot Created By Meekl For EoBots');

RichEdit1.Lines.Add('');

RichEdit1.Lines.Add('');

RichEdit1.Lines.Add('');

RichEdit1.Lines.Add('Scar 3.12');

RichEdit1.Lines.Add('EoBots-Online.com');

RichEdit1.TabOrder := 15;

end;

 

procedure SafeInitForm;

var

v: TVariantArray;

begin

setarraylength(V, 0);

ThreadSafeCall('InitForm', v);

end;

 

procedure ShowFormModal;

begin

frmDesign.ShowModal;

end;

 

procedure SafeShowFormModal;

var

v: TVariantArray;

begin

setarraylength(V, 0);

ThreadSafeCall('ShowFormModal', v);

end;

 

 

begin

SafeInitForm;

SafeShowFormModal;

FreeForm(frmDesign);

ClearDebug;

WriteLn('- AltBot.5 Public -')

WriteLn('- Created by Denryuu of EoBots-Online -')

WriteLn('- With help from Console of EoBots-Online -')

WriteLn('- Enjoy -')

end.

[/scar]

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...