This script is supposed to:
Check if player is GM Level D1
then open a code input
(Player inputs Tplayer name)
Checks if Tplayer is a valid character
Checks if Tplayer is online
Checks if Tplayer is in same party as player
then teleports to Tplayer.
Does my script do all that or does it no check to see if player is in the same party?
Code:
#include "StdAfx.h"
#include "Setup.h"
#ifdef WIN32
#pragma warning(disable:4305) // warning C4305: 'argument' : truncation from 'double' to 'float'
#endif
#define ITEM_ID 123456
#define GM_LEVEL 'D1'
class SCRIPT_DECL GMPorter : public GossipScript
{
public:
void GossipHello(Object* pObject, Player* Plr, bool AutoSend);
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char* Code);
void GossipEnd(Object* pObject, Player* Plr);
void Destroy()
{
delete this;
}
};
void GMPorter::GossipHello(Object* pObject, Player* Plr, bool AutoSend)
{
GossipMenu* Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
//Check to see if the player has the appropriate GM level
if(Plr->GetSession()->CanUseCommand(GM_LEVEL))
Menu->AddItem(0, "Port To Player", 1, 1);
Menu->AddItem(0, "[Exit]", 0);
if(AutoSend)
Menu->SendTo(Plr);
}
void GMPorter::GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char* Code)
{
GossipMenu* Menu;
switch(IntId)
{
case 0: //End Gossip
Plr->Gossip_Complete();
break;
case 1: //Port to Player
{
//No name entered
if(!Code)
{
Plr->BroadcastMessage("%s You have not entered a name to port to!", MSG_COLOR_RED);
Plr->Gossip_Complete();
}
Player* pPlayer = objmgr.GetPlayer(Code, false);
//Can't find the player entered
if(!pPlayer)
{
Plr->BroadcastMessage("%s Player is not online or could not be found.", MSG_COLOR_RED);
Plr->Gossip_Complete();
}
//If player has a group
if(pPlayer->GetGroup() != NULL)
{
Plr->BroadcastMessage("%s Player has a group, thus you cannot teleport to him.", MSG_COLOR_RED);
Plr->Gossip_Complete();
}
else
{
float XLoc = pPlayer->GetPositionX();
float YLoc = pPlayer->GetPositionY();
float ZLoc = pPlayer->GetPositionZ();
float OLoc = pPlayer->GetOrientation();
uint32 Map = pPlayer->GetMapId();
Plr->EventTeleport(Map, XLoc, YLoc, ZLoc);
Plr->SetOrientation(OLoc);
Plr->BroadcastMessage("%s You have been successfully teleported to %s .", MSG_COLOR_RED, pPlayer->GetName());
Plr->Gossip_Complete();
}
}break;
}
};
void GMPorter::GossipEnd(Object* pObject, Player* Plr)
{
GossipScript::GossipEnd(pObject, Plr);
};
void SetupGMPorter(ScriptMgr* mgr)
{
GossipScript* gs = (GossipScript*) new GMPorter();
mgr->register_item_gossip_script(ITEM_ID, gs);
};