randomguy_01
Well-known member
- Joined
- Jul 13, 2005
- RedCents
- 54¢
This is for the 2/23/2006 patch.
Rich (BB code):
// MQ2PlaceItem
// allows you to drop an item on a certain Y,X,Z location
// syntax: /placeitem <y x z>
// randomguy_01
#include "../MQ2Plugin.h"
PLUGIN_VERSION(1.1);
#ifdef PKT_UPDATE_POSITION
#undef PKT_UPDATE_POSITION
#endif
#define PKT_UPDATE_POSITION 0x7B59
#define PKT_DROP_ITEM 0x7668
PreSetup("MQ2PlaceItem");
VOID PlaceCmd(PSPAWNINFO pChar, PCHAR szLine)
{
float y, x, z;
char szBuf[MAX_STRING] = {0};
char szMsg[MAX_STRING] = {0};
GetArg(szBuf, szLine, 1);
y = (float)atof(szBuf);
GetArg(szBuf, szLine, 2);
x = (float)atof(szBuf);
GetArg(szBuf, szLine, 3);
z = (float)atof(szBuf);
// check for item on cursor
PCONTENTS pCursor = GetCharInfo2()->Cursor;
if (!pCursor) {
WriteChatf("You must have an item on your cursor.");
return;
}
if (szBuf[0] == 0) {
WriteChatf("You must specify a location");
return;
}
struct _MOVEPKT {
/*0000*/ unsigned short SpawnID;
/*0002*/ unsigned short TimeStamp;
/*0004*/ int DeltaHeading:16;
/*0006*/ int padding0020:16;
/*0008*/ float DeltaZ;
/*0012*/ float Y;
/*0016*/ int Animation:16;
/*0018*/ int Heading:16;
/*0020*/ float X;
/*0024*/ float DeltaY;
/*0028*/ float DeltaX;
/*0032*/ float Z;
} P;
ZeroMemory(&P, sizeof(P));
P.SpawnID = (unsigned short)pChar->SpawnID;
P.Heading = (unsigned int)(pChar->Heading * 4);
// jump to
P.Z = z;
P.Y = y;
P.X = x;
SendEQMessage(PKT_UPDATE_POSITION, &P, sizeof(P));
// drop
SendEQMessage(PKT_DROP_ITEM, "", 0);
DoCommand(pChar->pSpawn,"/drop");
// jump back
P.Z = pChar->Z;
P.Y = pChar->Y;
P.X = pChar->X;
SendEQMessage(PKT_UPDATE_POSITION, &P, sizeof(P));
sprintf(szMsg,"Attempting to drop %s at location %3.2f, %3.2f, %3.2f",pCursor->Item->Name, y, x, z);
WriteChatColor(szMsg);
}
PLUGIN_API VOID InitializePlugin(VOID)
{
AddCommand("/placeitem", PlaceCmd);
}
PLUGIN_API VOID ShutdownPlugin(VOID)
{
RemoveCommand("/placeitem");
}

