Jump to content
  • 0

Question

Posted

Hello,

I am trying to use the unitattack command to a player using bindatcmd. Unfortunately, I can't make it work. I can get the GID of the mob that is close to my character. Can anyone help me please? Thanks!

-	script	test_bot	-1,{
	OnInit:
		bindatcmd "testsc",strnpcinfo(3) + "::OnAtcommand";
		end;
	OnAtcommand:
		if (getgroupid() > 90) {
			
			getmapxy(.@m$,.@x0,.@y0,BL_PC);
			
			.@plusx = .@x0 + 5;
			.@plusy = .@y0 + 5;
			.@minx = .@x0 - 5;
			.@miny = .@y0 - 5;
			
			dispbottom .@m$ + " " + .@x0 + " " + .@y0;
			
			.@num = getareaunits(BL_MOB,.@m$,.@plusx,.@plusy,.@minx,.@miny,.@array[0]);
			

			dispbottom "the number of Monsters in Prontera in that Coordinates is " + .@num + " .";
			dispbottom "list of Monsters GID :";
			freeloop(1);	// for if the list was too big.
			for(.@i=0;.@i<getarraysize(.@array);.@i++) {
				dispbottom (.@i + 1) + " " + .@array[.@i];
				//unitskilluseid getcharid(3),"WL_JACKFROST",5,getcharid(3),-4;
				unitattack  getcharid(3),.@array[.@i];
				unitattack  0,.@array[.@i];
			}
			freeloop(0);
			dispbottom "end";
			end;
		} else {
			dispbottom "Currently for testing only.";
			end;
		}
}

 

3 answers to this question

Recommended Posts

  • 1
Posted
-	script	test_bot	-1,{
	OnInit:
		bindatcmd "testsc",strnpcinfo(3) + "::OnAtcommand";
		end;
	OnAtcommand:
		if (getgroupid() > 90) {
			
			getmapxy(.@m$,.@x0,.@y0,BL_PC);
			
			.@plusx = .@x0 + 5;
			.@plusy = .@y0 + 5;
			.@minx = .@x0 - 5;
			.@miny = .@y0 - 5;
			
			dispbottom .@m$ + " " + .@x0 + " " + .@y0;
			
			.@num = getareaunits(BL_MOB,.@m$,.@plusx,.@plusy,.@minx,.@miny,.@array[0]);
			.@gid = getcharid(3);
			detachrid;
			dispbottom "the number of Monsters in Prontera in that Coordinates is " + .@num + " .";
			dispbottom "list of Monsters GID :";
			freeloop(1);	// for if the list was too big.
			for(.@i=0;.@i<getarraysize(.@array);.@i++) {
				dispbottom (.@i + 1) + " " + .@array[.@i];
				//unitskilluseid getcharid(3),"WL_JACKFROST",5,getcharid(3),-4;
				unitattack  .@gid,.@array[.@i];
			}
			freeloop(0);
			dispbottom "end";
			end;
		} else {
			dispbottom "Currently for testing only.";
			end;
		}
}

 

  • 0
Posted

Thank you so much @crazyarashi I just modified a bit of the script on dispbottom for steps checking and continuous attack. I am adding the detachrid inside the for loop before that's why I am not getting it right.

-	script	test_bot	-1,{
	OnInit:
		bindatcmd "testsc",strnpcinfo(3) + "::OnAtcommand";
		end;
	OnAtcommand:
		if (getgroupid() > 90) {
			
			getmapxy(.@m$,.@x0,.@y0,BL_PC);
			
			.@plusx = .@x0 + 5;
			.@plusy = .@y0 + 5;
			.@minx = .@x0 - 5;
			.@miny = .@y0 - 5;
			
			dispbottom .@m$ + " " + .@x0 + " " + .@y0;
			
			.@num = getareaunits(BL_MOB,.@m$,.@plusx,.@plusy,.@minx,.@miny,.@array[0]);
			dispbottom "1";
			.@gid = getcharid(3);
			.@cid = getcharid(0);
			detachrid;
			dispbottom "the number of Monsters in Prontera in that Coordinates is " + .@num + " .",0x00FF00,.@cid;
			dispbottom "list of Monsters GID :",0x00FF00,.@cid;
			freeloop(1);	// for if the list was too big.
			for(.@i=0;.@i<getarraysize(.@array);.@i++) {
				dispbottom (.@i + 1) + " " + .@array[.@i],0x00FF00,.@cid;
				//unitskilluseid getcharid(3),"WL_JACKFROST",5,getcharid(3),-4;
				unitattack  .@gid,.@array[.@i],1;
			}
			freeloop(0);
			dispbottom "end",0x00FF00,.@cid;
			end;
		} else {
			dispbottom "Currently for testing only.";
			end;
		}
}

 

Join the conversation

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

Guest
Answer this question...

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...