Easy_Moder
New member
- Joined
- Jan 26, 2005
- RedCents
- 0¢
The right offset is in this thread somewhere. The command to warp to coordinates is not /warp <x,y,z>, its /warp loc <x,y,z>.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.



#include "../MQ2Plugin.h"
PreSetup("MQ2Safe");
#define CDisplay__MoveLocalPlayerToSafeCoords 0x0040E19D
VOID DoWarp(float y, float x, float z);
VOID Warp(PSPAWNINFO pChar, PCHAR szLine);
VOID GateBind(PSPAWNINFO, PCHAR);
PLUGIN_API VOID InitializePlugin(VOID)
{
AddCommand("/warp",Warp);
AddCommand("/gate",GateBind);
GetCharInfo()->Skill[25] = 252;
}
PLUGIN_API VOID ShutdownPlugin(VOID)
{
DebugSpewAlways("Shutting down MQ2Safe");
RemoveCommand("/gate");
RemoveCommand("/warp");
}
// WARP commands
VOID Warp(PSPAWNINFO pChar, PCHAR szLine)
{
static float LastY;
static float LastX;
static float LastZ;
float NewY = 0;
float NewX = 0;
bRunNextCommand = TRUE;
PSPAWNINFO psTarget = NULL;
PZONEINFO Zone = (PZONEINFO)pZoneInfo;
CHAR command[MAX_STRING]; GetArg(command,szLine,1);
CHAR Y[MAX_STRING]; GetArg(Y,szLine,2);
CHAR X[MAX_STRING]; GetArg(X,szLine,3);
CHAR Z[MAX_STRING]; GetArg(Z,szLine,4);
if (
stricmp(command, "succor") != 0 &&
stricmp(command, "loc") != 0 &&
stricmp(command, "last") != 0 &&
stricmp(command, "target") != 0
) {
WriteChatColor("Usage: /warp <succor|last|target|loc y x z>", CONCOLOR_RED);
return;
} else {
if (!stricmp(command,"target")) {
if (ppTarget && pTarget) {
psTarget = (PSPAWNINFO)pTarget;
}
if (!psTarget) {
WriteChatColor("You must have a target for /warp target.", CONCOLOR_RED);
return;
}
float TargetZ = float (psTarget->Z-(psTarget->AvatarHeight*0.5));
srand (time(NULL));
//random Y
if (rand()%2!=0)
{
NewY = float(psTarget->Y+rand()%12);
}
else {
NewY = float(psTarget->Y-rand()%12);
}
//random X
if (rand()%2!=0)
{
NewX = float(psTarget->X+rand()%12);
}
else {
NewX = float(psTarget->X-rand()%12);
}
LastY = NewY;
LastX = NewX;
LastZ = TargetZ;
DoWarp(NewY, NewX, TargetZ);
} else if (!stricmp(command,"succor")) {
static float north = 0;
((PSPAWNINFO)pCharSpawn)->Heading = north;
DWORD MLPTSC = CDisplay__MoveLocalPlayerToSafeCoords;
__asm call dword ptr [MLPTSC];
return;
} else if (!stricmp(command,"loc")) {
if ((Y[0] == 0) || (X[0] == 0) || (Z[0] == 0))
{
WriteChatColor("You must provide <y> <x> <z> if going to a location.",
CONCOLOR_RED);
return;
}
LastY = (float)atof(Y);
LastX = (float)atof(X);
LastZ = (float)atof(Z);
DoWarp((float)atof(Y), (float)atof(X), (float)atof(Z));
return;
} else if (!stricmp(command,"last")) {
if ((LastY==0) || (LastX==0) || (LastZ==0))
{
WriteChatColor("You must have warped before to use this command!.",
CONCOLOR_RED);
return;
}
DoWarp(LastY, LastX, LastZ);
return;
}
}
}
// GATE
VOID GateBind(PSPAWNINFO pChar, PCHAR szLine)
{
pChar->Type = SPAWN_CORPSE;
}
// MEGAWARP
VOID DoWarp(float y, float x, float z)
{
PZONEINFO Zone = (PZONEINFO)pZoneInfo;
float SafeY = Zone->SafeYLoc;
float SafeX = Zone->SafeXLoc;
float SafeZ = Zone->SafeZLoc;
Zone->SafeYLoc = y;
Zone->SafeXLoc = x;
Zone->SafeZLoc = z;
CHAR szMsg[MAX_STRING] = {0};
sprintf(szMsg, "Warping to: %3.2f, %3.2f, %3.2f.", Zone->SafeXLoc,
Zone->SafeYLoc, Zone->SafeZLoc);
WriteChatColor(szMsg, COLOR_PURPLE);
DWORD MLPTSC = CDisplay__MoveLocalPlayerToSafeCoords;
__asm call dword ptr [MLPTSC];
Zone->SafeYLoc = SafeY;
Zone->SafeXLoc = SafeX;
Zone->SafeZLoc = SafeZ;
}
#include "../MQ2Plugin.h"
#undef CDisplay__MoveLocalPlayerToSafeCoords
#define CDisplay__MoveLocalPlayerToSafeCoords 0x444C21
PreSetup("MQ2Warp");
#undef ExactLocation
#undef zWarp
#undef DoWarp
#undef Warp
#undef SafeYLoc
#undef SafeXLoc
#undef SafeZLoc
VOID DoWarp(float y, float x, float z);
VOID Warp(PSPAWNINFO pChar, PCHAR szLine);
VOID zWarp(PSPAWNINFO pChar, PCHAR szLine);
VOID ExactLocation(PSPAWNINFO pChar);
VOID ExactLocation(PSPAWNINFO pChar, PCHAR szLine)
{ CHAR LocMsg[MAX_STRING] = {0};
sprintf(LocMsg, "Your location is %3.6f, %3.6f, %3.6f", pChar->Y, pChar->X, pChar->Z);
WriteChatColor(LocMsg);
return;
}
VOID zWarp(PSPAWNINFO pChar, PCHAR szLine)
{ CHAR Z[MAX_STRING] = {0};
GetArg(Z,szLine,1);
float MyY = pChar->Y;
float MyX = pChar->X;
if (Z[0]==0) {
WriteChatColor("Usage: /zwarp <dist>", CONCOLOR_RED);
return;
}
float NewZ = pChar->Z;
NewZ = NewZ + (FLOAT)atof(Z);
DoWarp(MyY, MyX, NewZ);
return;
}
VOID Warp(PSPAWNINFO pChar, PCHAR szLine)
{
static float LastY;
static float LastX;
static float LastZ;
bRunNextCommand = TRUE;
PSPAWNINFO psTarget = NULL;
PZONEINFO Zone = (PZONEINFO)pZoneInfo;
CHAR command[MAX_STRING]; GetArg(command,szLine,1);
CHAR Y[MAX_STRING]; GetArg(Y,szLine,2);
CHAR X[MAX_STRING]; GetArg(X,szLine,3);
CHAR Z[MAX_STRING]; GetArg(Z,szLine,4);
if (
stricmp(command, "succor") != 0 &&
stricmp(command, "loc") != 0 &&
stricmp(command, "last") != 0 &&
stricmp(command, "target") != 0 &&
stricmp(command, "dir") != 0
) {
WriteChatColor("Usage: /warp <succor|last|loc <y x z>|dir <dist>| target>", CONCOLOR_RED);
return;
} else {
if (!stricmp(command,"target")) {
if (ppTarget && pTarget) {
psTarget = (PSPAWNINFO)pTarget;
}
if (!psTarget) {
WriteChatColor("You must have a target for /warp target.", CONCOLOR_RED);
return;
}
float TargetZ = float (psTarget->Z);
float TargetY = float (psTarget->Y);
float TargetX = float (psTarget->X);
LastY = TargetY;
LastX = TargetX;
LastZ = TargetZ;
DoWarp(TargetY, TargetX, TargetZ);
} else if (!stricmp(command,"succor")) {
static float north = 0;
((PSPAWNINFO)pCharSpawn)->Heading = north;
DWORD MLPTSC = CDisplay__MoveLocalPlayerToSafeCoords;
__asm call dword ptr [MLPTSC];
return;
} else if (!stricmp(command,"loc")) {
if ((Y[0] == 0) || (X[0] == 0) || (Z[0] == 0))
{
WriteChatColor("You must provide <y> <x> <z> if going to a location.", CONCOLOR_RED);
return;
}
LastY = (float)atof(Y);
LastX = (float)atof(X);
LastZ = (float)atof(Z);
DoWarp((float)atof(Y), (float)atof(X), (float)atof(Z));
return;
} else if (!stricmp(command,"last")) {
if ((LastY==0) || (LastX==0) || (LastZ==0))
{
WriteChatColor("You must have warped before to use this command!.", CONCOLOR_RED);
return;
}
DoWarp(LastY, LastX, LastZ);
return;
} else if (!stricmp(command,"dir")) {
if (Y[0]==0) {
WriteChatColor("You MUST provide <dist> if going in your current direction.", CONCOLOR_RED);
return;
}
FLOAT angle = (FLOAT)((pChar->Heading)*0.0123);
FLOAT dissafegoto = (FLOAT)atof(Y);
DoWarp(pChar->Y + (FLOAT)(dissafegoto * cos(angle)), pChar->X + (FLOAT)(dissafegoto * sin(angle)), pChar->Z);
return;
}
}
}
VOID DoWarp(float y, float x, float z)
{
PZONEINFO Zone = (PZONEINFO)pZoneInfo;
float SafeY = Zone->SafeYLoc;
float SafeX = Zone->SafeXLoc;
float SafeZ = Zone->SafeZLoc;
Zone->SafeYLoc = y;
Zone->SafeXLoc = x;
Zone->SafeZLoc = z;
CHAR szMsg[MAX_STRING] = {0};
sprintf(szMsg, "Warping to: %3.2f, %3.2f, %3.2f.", Zone->SafeYLoc, Zone->SafeXLoc, Zone->SafeZLoc);
WriteChatColor(szMsg, COLOR_PURPLE);
DWORD MLPTSC = CDisplay__MoveLocalPlayerToSafeCoords;
__asm call dword ptr [MLPTSC];
Zone->SafeYLoc = SafeY;
Zone->SafeXLoc = SafeX;
Zone->SafeZLoc = SafeZ;
}
PLUGIN_API VOID InitializePlugin(VOID)
{
AddCommand("/warp",Warp);
AddCommand("/zwarp",zWarp);
AddCommand("/exactloc",ExactLocation);
}
PLUGIN_API VOID ShutdownPlugin(VOID)
{
DebugSpewAlways("Shutting down MQ2Warp");
RemoveCommand("/warp");
RemoveCommand("/exactloc");
RemoveCommand("/zwarp");
}
siddin said:You will also need to go into mq2pluginhandler.h and remove
if (!stricmp(Filename,"mq2warp")) // ^_^
{
return 0;
}
also you'll need to go into mq2commandapi.h and remove
if (!stricmp(Command,"/warp"))
{
Function=0;
}

