PDA

View Full Version : The most useful GM command ever!



Alexeng
04-06-10, 05:30 AM
i did not make this! i just share it to all of you because its one of the best gm build commands that has ever been created!

Here is a GM command I wrote up some time ago named "warp"

Syntax: .warp direction value


direction = f, b, u, d, rotate
(forward, backward, up, down, rotate)


value: 1-360


This nifty little command will teleport your character (direction) (value).
Basically instead of manually inputting coordinates to get through objects, you can just type my command and you will port yourself though them.

This is EXTREMELY helpful for spawning things (especially game objects!)

Not sure why this has not been made an actual command already!

Installation is pretty self explanatory if you look at the code below. You just need to add three different parts to three different files and then compile your server like normal.



//Made by: Pwntzyou!
//DONT JACK THIS SHIT AND TAKE CREDIT FOR IT OR I WILL FIND AND KILL YOU

//ADD TO level3.cpp
//(In all honesty it really does not matter which levelX.cpp you put it unless you want to restrict that level of command

bool ChatHandler::HandleWarpCommand(const char* args, WorldSession *m_session)
{
char dir;
float value;

if(sscanf(args, "%f %c", &value, &dir) < 1) return false;

if(value > 360)
return false;

switch(tolower(dir))
{
//Made by: Pwntzyou!
case 'u':
{
m_session->GetPlayer()->SafeTeleport(m_session->GetPlayer()->GetMapId(), m_session->GetPlayer()->GetInstanceID(), m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ() + (float)value, m_session->GetPlayer()->GetOrientation());
}
break;

case 'd':
{
m_session->GetPlayer()->SafeTeleport(m_session->GetPlayer()->GetMapId(), m_session->GetPlayer()->GetInstanceID(), m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ() - (float)value, m_session->GetPlayer()->GetOrientation());
}
break;

case 'f':
{
float x = m_session->GetPlayer()->GetPositionX() + cosf(m_session->GetPlayer()->GetOrientation())*value;
float y = m_session->GetPlayer()->GetPositionY() + sinf(m_session->GetPlayer()->GetOrientation())*value;
m_session->GetPlayer()->SafeTeleport(m_session->GetPlayer()->GetMapId(), m_session->GetPlayer()->GetInstanceID(), x, y, m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetOrientation());
}
break;

case 'b':
{
//Made by: Pwntzyou!
float x = m_session->GetPlayer()->GetPositionX() - cosf(m_session->GetPlayer()->GetOrientation())*value;
float y = m_session->GetPlayer()->GetPositionY() - sinf(m_session->GetPlayer()->GetOrientation())*value;
m_session->GetPlayer()->SafeTeleport(m_session->GetPlayer()->GetMapId(), m_session->GetPlayer()->GetInstanceID(), x, y, m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetOrientation());
}
break;

case 'r':
{
//In degrees -> Radians (doesnt seem to work)
float radian = value * 180 / 3.14159265;
m_session->GetPlayer()->SafeTeleport(m_session->GetPlayer()->GetMapId(), m_session->GetPlayer()->GetInstanceID(), m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetOrientation() + radian);
}
break;



default:
RedSystemMessage(m_session, "Invalid Direction, Please use forward(f) backward(b) up(u) down(d)");
}
return true;
}






// Chat.cpp
//ADD TO BOTTOM OF "static ChatCommand commandTable[] ="
// {
// ...
// ...
// ...
// HERE
// ...
// }


{ "warp", 'm', &ChatHandler::HandleWarpCommand, "Warp the player (1-100) coordinates forward(f) backward(b) up(u) down(d).", NULL, 0, 0, 0 },







// Chat.h
// Add the following in Chat.h where similar things are
// Should looks something like this
// Level 0 Commands
// ...
// ...
// ...
// HERE

bool HandleWarpCommand(const char * args, WorldSession * m_session);


This *should* work with *most* emulators (Arcemu / Aspire / w.e) but if it does not, getting it to work will not be hard.