Page 1 of 1

How to /echo target location in a plugin?

Posted: Wed Feb 11, 2004 8:08 pm
by ieatacid
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.

Posted: Wed Feb 11, 2004 8:11 pm
by ml2517
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.

Posted: Wed Feb 11, 2004 8:35 pm
by ieatacid
Thanks for the response, but that gets me this on build:

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

Posted: Wed Feb 11, 2004 8:38 pm
by ml2517
Hmm ok try:

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

Posted: Wed Feb 11, 2004 8:50 pm
by ieatacid
Thanks, that did it.

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

Posted: Wed Feb 11, 2004 10:30 pm
by anOrcPawn00
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.