Working now! 100%
bool ChatHandler::HandleWarpCommand(char* args)
{
// Based on a concept by Pwntzyou
if (!*args)
return false;
Player* _player = m_session->GetPlayer();
char* arg1 = strtok((char*)args, " ");
char* arg2 = strtok(NULL, " ");
if (! arg1)
return false;
if (! arg2)
return false;
char dir = arg1[0];
int value = (int)atoi(arg2);
float x = _player->GetPositionX();
float y = _player->GetPositionY();
float z = _player->GetPositionZ();
float o = _player->GetOrientation();
uint32 mapid = _player->GetMapId();
PSendSysMessage("Value is: %i",value);
switch (dir)
{
case 'x':
{
float xx = x + cosf(o)*value;
float xy = y + sinf(o)*value;
_player->TeleportTo(mapid, xx, xy, z, o);
}
break;
case 'y':
{
float yx = x + cos(o-(M_PI/2))*value;
float yy = y + sin(o-(M_PI/2))*value;
_player->TeleportTo(mapid, yx, yy, z, o);
}
break;
case 'z':
{
_player->TeleportTo(mapid, x, y, z + value, o);
}
break;
case 'o':
{
o = o - (value * M_PI / 180.0f);
if (o < 0.0f) o += value * M_PI;
else if (o > 2* M_PI) o -= value * M_PI;
_player->TeleportTo(mapid,x,y,z,o);
}
break;
}
return true;
}