How to /echo target location in a plugin?

Need help running MacroQuest2? Ask your questions about how to get things to work on your computer.

Moderator: MacroQuest Developers

User avatar
ieatacid
Developer
Developer
Posts: 2727
Joined: Wed Sep 03, 2003 7:44 pm

How to /echo target location in a plugin?

Post by ieatacid » Wed Feb 11, 2004 8:08 pm

I'm trying to get my plugin to /echo my target's x, y, and z coordinates but can't seem to get it to work right.

Basically I want it to:

/echo $target(x)
/echo $target(y)
/echo $target(z)

...either in 3 consecutive lines or, preferrably, all on one line. I tried using "WriteChatColor" but that just prints those variables as text.

Any help is appreciated.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Wed Feb 11, 2004 8:11 pm

Try:

DoCommand("/echo $target(x)")

No clue if its going to work...

Or..

DoCommand("/echo $target(y) $target(x) $target(z)")

*note.. the order is y,x,z in game.

User avatar
ieatacid
Developer
Developer
Posts: 2727
Joined: Wed Sep 03, 2003 7:44 pm

Post by ieatacid » Wed Feb 11, 2004 8:35 pm

Thanks for the response, but that gets me this on build:

warning C4003: not enough actual parameters for macro 'DoCommand'

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Wed Feb 11, 2004 8:38 pm

Hmm ok try:

DoCommand(pChar,"/echo $target(x)");

User avatar
ieatacid
Developer
Developer
Posts: 2727
Joined: Wed Sep 03, 2003 7:44 pm

Post by ieatacid » Wed Feb 11, 2004 8:50 pm

Thanks, that did it.

DoCommand(pChar,"/echo $target(y) $target(x) $target(z)");

anOrcPawn00
a lesser mummy
a lesser mummy
Posts: 41
Joined: Sat May 10, 2003 6:15 am

Post by anOrcPawn00 » Wed Feb 11, 2004 10:30 pm

Off the top of my head it's something along the lines of:

Code: Select all

char szTemp[MAX_STRING];

if (psTarget) {
  sprintf(szTemp, "Target location: %f %f %f", psTarget->x, psTarget->y, psTarget->z);
   WriteChatColor(szTemp, USERCOLOR_DEFAULT);
} else {
   WriteChatColor("No Target!", USERCOLOR_DEFAULT);
}
I'm not sure offhand that psTarget is the correct one, but there are a few variables named ppTarget, pTarget and psTarget. I think psTarget is the one which points to the PSPAWNINFO of the target.