AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
tele_commandscript Class Reference
Inheritance diagram for tele_commandscript:
CommandScript ScriptObject

Public Member Functions

 tele_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleTeleAddCommand (ChatHandler *handler, std::string const &name)
 
static bool HandleTeleDelCommand (ChatHandler *handler, GameTele const *tele)
 
static bool DoNameTeleport (ChatHandler *handler, PlayerIdentifier player, uint32 mapId, Position const &pos, std::string const &locationName)
 
static bool HandleTeleNameCommand (ChatHandler *handler, Optional< PlayerIdentifier > player, Variant< GameTele const *, EXACT_SEQUENCE("$home")> where)
 
static bool HandleTeleGroupCommand (ChatHandler *handler, GameTele const *tele)
 
static bool HandleTeleCommand (ChatHandler *handler, GameTele const *tele)
 
static bool HandleTeleNameNpcIdCommand (ChatHandler *handler, PlayerIdentifier player, Variant< Hyperlink< creature_entry >, uint32 > creatureId)
 
static bool HandleTeleNameNpcSpawnIdCommand (ChatHandler *handler, PlayerIdentifier player, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
 
static bool HandleTeleNameNpcNameCommand (ChatHandler *handler, PlayerIdentifier player, Tail name)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ tele_commandscript()

tele_commandscript::tele_commandscript ( )
inline
39: CommandScript("tele_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ DoNameTeleport()

static bool tele_commandscript::DoNameTeleport ( ChatHandler handler,
PlayerIdentifier  player,
uint32  mapId,
Position const &  pos,
std::string const &  locationName 
)
inlinestatic
116 {
117 if (!MapMgr::IsValidMapCoord(mapId, pos) || sObjectMgr->IsTransportMap(mapId))
118 {
119 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, pos.GetPositionX(), pos.GetPositionY(), mapId);
120 return false;
121 }
122
123 if (Player* target = player.GetConnectedPlayer())
124 {
125 // check online security
126 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
127 return false;
128
129 std::string chrNameLink = handler->playerLink(target->GetName());
130
131 if (target->IsBeingTeleported())
132 {
133 handler->SendErrorMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
134 return false;
135 }
136
137 handler->PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink, "", locationName);
138 if (handler->needReportToTarget(target))
139 ChatHandler(target->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink());
140
141 // stop flight if need
142 if (target->IsInFlight())
143 {
144 target->GetMotionMaster()->MovementExpired();
145 target->CleanupAfterTaxiFlight();
146 }
147 else // save only in non-flight case
148 target->SaveRecallPosition();
149
150 target->TeleportTo({ mapId, pos });
151 }
152 else
153 {
154 // check offline security
155 if (handler->HasLowerSecurity(nullptr, player.GetGUID()))
156 return false;
157
158 std::string nameLink = handler->playerLink(player.GetName());
159
160 handler->PSendSysMessage(LANG_TELEPORTING_TO, nameLink, handler->GetAcoreString(LANG_OFFLINE), locationName);
161
162 Player::SavePositionInDB({ mapId, pos }, sMapMgr->GetZoneId(PHASEMASK_NORMAL, { mapId, pos }), player.GetGUID(), nullptr);
163 }
164
165 return true;
166 }
#define sMapMgr
Definition: MapMgr.h:221
#define sObjectMgr
Definition: ObjectMgr.h:1623
@ LANG_OFFLINE
Definition: Language.h:69
@ LANG_IS_TELEPORTED
Definition: Language.h:134
@ LANG_INVALID_TARGET_COORD
Definition: Language.h:308
@ LANG_TELEPORTED_TO_BY
Definition: Language.h:143
@ LANG_TELEPORTING_TO
Definition: Language.h:142
@ PHASEMASK_NORMAL
Definition: Object.h:59
Definition: Chat.h:39
virtual std::string GetNameLink() const
Definition: Chat.h:200
std::string playerLink(std::string const &name) const
Definition: Chat.h:233
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:213
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:43
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:218
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:866
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:59
ObjectGuid GetGUID() const
Definition: ChatCommandTags.h:180
std::string const & GetName() const
Definition: ChatCommandTags.h:179
Player * GetConnectedPlayer() const
Definition: ChatCommandTags.h:182
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
Definition: Player.h:1064
static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, ObjectGuid guid)
Definition: PlayerMisc.cpp:84
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition: MapMgr.h:91

References ObjectGuid::Empty, ChatHandler::GetAcoreString(), Acore::ChatCommands::PlayerIdentifier::GetConnectedPlayer(), Acore::ChatCommands::PlayerIdentifier::GetGUID(), Acore::ChatCommands::PlayerIdentifier::GetName(), ChatHandler::GetNameLink(), Position::GetPositionX(), Position::GetPositionY(), ChatHandler::HasLowerSecurity(), MapMgr::IsValidMapCoord(), LANG_INVALID_TARGET_COORD, LANG_IS_TELEPORTED, LANG_OFFLINE, LANG_TELEPORTED_TO_BY, LANG_TELEPORTING_TO, ChatHandler::needReportToTarget(), PHASEMASK_NORMAL, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), Player::SavePositionInDB(), ChatHandler::SendErrorMessage(), sMapMgr, and sObjectMgr.

Referenced by HandleTeleNameCommand(), HandleTeleNameNpcIdCommand(), HandleTeleNameNpcNameCommand(), and HandleTeleNameNpcSpawnIdCommand().

◆ GetCommands()

ChatCommandTable tele_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

42 {
43 static ChatCommandTable teleNameNpcCommandTable =
44 {
45 { "id", HandleTeleNameNpcIdCommand, SEC_GAMEMASTER, Console::Yes },
46 { "guid", HandleTeleNameNpcSpawnIdCommand, SEC_GAMEMASTER, Console::Yes },
47 { "name", HandleTeleNameNpcNameCommand, SEC_GAMEMASTER, Console::Yes },
48 };
49 static ChatCommandTable teleNameCommandTable =
50 {
51 { "npc", teleNameNpcCommandTable },
52 { "", HandleTeleNameCommand, SEC_GAMEMASTER, Console::Yes },
53 };
54 static ChatCommandTable teleCommandTable =
55 {
56 { "add", HandleTeleAddCommand, SEC_ADMINISTRATOR, Console::No },
57 { "del", HandleTeleDelCommand, SEC_ADMINISTRATOR, Console::Yes },
58 { "name", teleNameCommandTable },
59 { "group", HandleTeleGroupCommand, SEC_GAMEMASTER, Console::No },
60 { "", HandleTeleCommand, SEC_GAMEMASTER, Console::No }
61 };
62 static ChatCommandTable commandTable =
63 {
64 { "teleport", teleCommandTable }
65 };
66 return commandTable;
67 }
@ SEC_ADMINISTRATOR
Definition: Common.h:60
@ SEC_GAMEMASTER
Definition: Common.h:59
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
static bool HandleTeleNameNpcNameCommand(ChatHandler *handler, PlayerIdentifier player, Tail name)
Definition: cs_tele.cpp:355
static bool HandleTeleNameNpcIdCommand(ChatHandler *handler, PlayerIdentifier player, Variant< Hyperlink< creature_entry >, uint32 > creatureId)
Definition: cs_tele.cpp:313
static bool HandleTeleNameCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, Variant< GameTele const *, EXACT_SEQUENCE("$home")> where)
Definition: cs_tele.cpp:169
static bool HandleTeleNameNpcSpawnIdCommand(ChatHandler *handler, PlayerIdentifier player, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
Definition: cs_tele.cpp:341
static bool HandleTeleAddCommand(ChatHandler *handler, std::string const &name)
Definition: cs_tele.cpp:69
static bool HandleTeleCommand(ChatHandler *handler, GameTele const *tele)
Definition: cs_tele.cpp:278
static bool HandleTeleDelCommand(ChatHandler *handler, GameTele const *tele)
Definition: cs_tele.cpp:102
static bool HandleTeleGroupCommand(ChatHandler *handler, GameTele const *tele)
Definition: cs_tele.cpp:205

References HandleTeleAddCommand(), HandleTeleCommand(), HandleTeleDelCommand(), HandleTeleGroupCommand(), HandleTeleNameCommand(), HandleTeleNameNpcIdCommand(), HandleTeleNameNpcNameCommand(), HandleTeleNameNpcSpawnIdCommand(), SEC_ADMINISTRATOR, and SEC_GAMEMASTER.

◆ HandleTeleAddCommand()

static bool tele_commandscript::HandleTeleAddCommand ( ChatHandler handler,
std::string const &  name 
)
inlinestatic
70 {
71 Player* player = handler->GetSession()->GetPlayer();
72 if (!player)
73 return false;
74
75 if (sObjectMgr->GetGameTele(name))
76 {
78 return false;
79 }
80
81 GameTele tele;
82 tele.position_x = player->GetPositionX();
83 tele.position_y = player->GetPositionY();
84 tele.position_z = player->GetPositionZ();
85 tele.orientation = player->GetOrientation();
86 tele.mapId = player->GetMapId();
87 tele.name = name;
88
89 if (sObjectMgr->AddGameTele(tele))
90 {
92 }
93 else
94 {
96 return false;
97 }
98
99 return true;
100 }
@ LANG_COMMAND_TP_ALREADYEXIST
Definition: Language.h:494
@ LANG_COMMAND_TP_ADDEDERR
Definition: Language.h:496
@ LANG_COMMAND_TP_ADDED
Definition: Language.h:495
WorldSession * GetSession()
Definition: Chat.h:244
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:162
float GetPositionZ() const
Definition: Position.h:119
float GetOrientation() const
Definition: Position.h:120
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
uint32 GetMapId() const
Definition: Position.h:276
Definition: ObjectMgr.h:135
float position_y
Definition: ObjectMgr.h:137
float orientation
Definition: ObjectMgr.h:139
float position_x
Definition: ObjectMgr.h:136
uint32 mapId
Definition: ObjectMgr.h:140
std::string name
Definition: ObjectMgr.h:141
float position_z
Definition: ObjectMgr.h:138
Player * GetPlayer() const
Definition: WorldSession.h:362

References WorldLocation::GetMapId(), Position::GetOrientation(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::GetSession(), LANG_COMMAND_TP_ADDED, LANG_COMMAND_TP_ADDEDERR, LANG_COMMAND_TP_ALREADYEXIST, GameTele::mapId, GameTele::name, GameTele::orientation, GameTele::position_x, GameTele::position_y, GameTele::position_z, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleTeleCommand()

static bool tele_commandscript::HandleTeleCommand ( ChatHandler handler,
GameTele const *  tele 
)
inlinestatic
279 {
280 if (!tele)
281 {
283 return false;
284 }
285
286 Player* player = handler->GetSession()->GetPlayer();
287 if (player->IsInCombat())
288 {
290 return false;
291 }
292
293 MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
294 if (!map || (map->IsBattlegroundOrArena() && (player->GetMapId() != tele->mapId || !player->IsGameMaster())))
295 {
297 return false;
298 }
299
300 // stop flight if need
301 if (player->IsInFlight())
302 {
303 player->GetMotionMaster()->MovementExpired();
304 player->CleanupAfterTaxiFlight();
305 }
306 else // save only in non-flight case
307 player->SaveRecallPosition();
308
309 player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
310 return true;
311 }
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
@ LANG_YOU_IN_COMBAT
Definition: Language.h:55
@ LANG_COMMAND_TELE_NOTFOUND
Definition: Language.h:203
@ LANG_CANNOT_TELE_TO_BG
Definition: Language.h:704
void SaveRecallPosition()
Definition: Player.cpp:5647
bool IsGameMaster() const
Definition: Player.h:1158
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1330
void CleanupAfterTaxiFlight()
Definition: Player.cpp:10427
MotionMaster * GetMotionMaster()
Definition: Unit.h:1601
bool IsInFlight() const
Definition: Unit.h:1096
bool IsInCombat() const
Definition: Unit.h:820
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178
Definition: DBCStructure.h:1325
bool IsBattlegroundOrArena() const
Definition: DBCStructure.h:1357

References Player::CleanupAfterTaxiFlight(), WorldLocation::GetMapId(), Unit::GetMotionMaster(), WorldSession::GetPlayer(), ChatHandler::GetSession(), MapEntry::IsBattlegroundOrArena(), Player::IsGameMaster(), Unit::IsInCombat(), Unit::IsInFlight(), LANG_CANNOT_TELE_TO_BG, LANG_COMMAND_TELE_NOTFOUND, LANG_YOU_IN_COMBAT, GameTele::mapId, MotionMaster::MovementExpired(), GameTele::orientation, GameTele::position_x, GameTele::position_y, GameTele::position_z, Player::SaveRecallPosition(), ChatHandler::SendErrorMessage(), sMapStore, and Player::TeleportTo().

Referenced by GetCommands().

◆ HandleTeleDelCommand()

static bool tele_commandscript::HandleTeleDelCommand ( ChatHandler handler,
GameTele const *  tele 
)
inlinestatic
103 {
104 if (!tele)
105 {
107 return false;
108 }
109 std::string name = tele->name;
110 sObjectMgr->DeleteGameTele(name);
112 return true;
113 }
@ LANG_COMMAND_TP_DELETED
Definition: Language.h:497

References LANG_COMMAND_TELE_NOTFOUND, LANG_COMMAND_TP_DELETED, GameTele::name, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleTeleGroupCommand()

static bool tele_commandscript::HandleTeleGroupCommand ( ChatHandler handler,
GameTele const *  tele 
)
inlinestatic
206 {
207 if (!tele)
208 {
210 return false;
211 }
212
213 Player* target = handler->getSelectedPlayer();
214 if (!target)
215 {
217 return false;
218 }
219
220 // check online security
221 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
222 return false;
223
224 MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
225 if (!map || map->IsBattlegroundOrArena())
226 {
228 return false;
229 }
230
231 std::string nameLink = handler->GetNameLink(target);
232
233 Group* grp = target->GetGroup();
234 if (!grp)
235 {
236 handler->SendErrorMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
237 return false;
238 }
239
240 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
241 {
242 Player* player = itr->GetSource();
243
244 if (!player || !player->GetSession())
245 continue;
246
247 // check online security
248 if (handler->HasLowerSecurity(player, ObjectGuid::Empty))
249 return false;
250
251 std::string plNameLink = handler->GetNameLink(player);
252
253 if (player->IsBeingTeleported())
254 {
255 handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink);
256 continue;
257 }
258
259 handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name);
260 if (handler->needReportToTarget(player))
262
263 // stop flight if need
264 if (target->IsInFlight())
265 {
266 target->GetMotionMaster()->MovementExpired();
267 target->CleanupAfterTaxiFlight();
268 }
269 else // save only in non-flight case
270 target->SaveRecallPosition();
271
272 player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
273 }
274
275 return true;
276 }
@ LANG_NOT_IN_GROUP
Definition: Language.h:149
@ LANG_NO_CHAR_SELECTED
Definition: Language.h:148
Player * getSelectedPlayer() const
Definition: Chat.cpp:376
WorldSession * GetSession() const
Definition: Player.h:1978
Group * GetGroup()
Definition: Player.h:2448
bool IsBeingTeleported() const
Definition: Player.h:2070
Definition: Group.h:169
GroupReference * GetFirstMember()
Definition: Group.h:243
Definition: GroupReference.h:27
GroupReference * next()
Definition: GroupReference.h:36

References Player::CleanupAfterTaxiFlight(), ObjectGuid::Empty, Group::GetFirstMember(), Player::GetGroup(), Unit::GetMotionMaster(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), Player::GetSession(), ChatHandler::HasLowerSecurity(), MapEntry::IsBattlegroundOrArena(), Player::IsBeingTeleported(), Unit::IsInFlight(), LANG_CANNOT_TELE_TO_BG, LANG_COMMAND_TELE_NOTFOUND, LANG_IS_TELEPORTED, LANG_NO_CHAR_SELECTED, LANG_NOT_IN_GROUP, LANG_TELEPORTED_TO_BY, LANG_TELEPORTING_TO, GameTele::mapId, MotionMaster::MovementExpired(), GameTele::name, ChatHandler::needReportToTarget(), GroupReference::next(), GameTele::orientation, GameTele::position_x, GameTele::position_y, GameTele::position_z, ChatHandler::PSendSysMessage(), Player::SaveRecallPosition(), ChatHandler::SendErrorMessage(), sMapStore, and Player::TeleportTo().

Referenced by GetCommands().

◆ HandleTeleNameCommand()

static bool tele_commandscript::HandleTeleNameCommand ( ChatHandler handler,
Optional< PlayerIdentifier player,
Variant< GameTele const *, EXACT_SEQUENCE("$home")>  where 
)
inlinestatic
170 {
171 if (!player)
172 player = PlayerIdentifier::FromTargetOrSelf(handler);
173 if (!player)
174 return false;
175
176 if (where.index() == 1) // References target's homebind
177 {
178 if (Player* target = player->GetConnectedPlayer())
179 target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation());
180 else
181 {
183 stmt->SetData(0, player->GetGUID().GetCounter());
184 PreparedQueryResult resultDB = CharacterDatabase.Query(stmt);
185
186 if (resultDB)
187 {
188 Field* fieldsDB = resultDB->Fetch();
189 WorldLocation loc(fieldsDB[0].Get<uint16>(), fieldsDB[2].Get<float>(), fieldsDB[3].Get<float>(), fieldsDB[4].Get<float>(), 0.0f);
190 uint32 zoneId = fieldsDB[1].Get<uint16>();
191
192 Player::SavePositionInDB(loc, zoneId, player->GetGUID(), nullptr);
193 }
194 }
195
196 return true;
197 }
198
199 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
200 GameTele const* tele = where.get<GameTele const*>();
201 return DoNameTeleport(handler, *player, tele->mapId, { tele->position_x, tele->position_y, tele->position_z, tele->orientation }, tele->name);
202 }
std::uint32_t uint32
Definition: Define.h:107
std::uint16_t uint16
Definition: Define.h:108
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ CHAR_SEL_CHAR_HOMEBIND
Definition: CharacterDatabase.h:339
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: PreparedStatement.h:158
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:188
constexpr decltype(auto) get()
Definition: ChatCommandTags.h:288
Definition: Position.h:251
static bool DoNameTeleport(ChatHandler *handler, PlayerIdentifier player, uint32 mapId, Position const &pos, std::string const &locationName)
Definition: cs_tele.cpp:115

References CHAR_SEL_CHAR_HOMEBIND, CharacterDatabase, DoNameTeleport(), Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), Field::Get(), GameTele::mapId, GameTele::name, Player::SavePositionInDB(), and PreparedStatementBase::SetData().

Referenced by GetCommands().

◆ HandleTeleNameNpcIdCommand()

static bool tele_commandscript::HandleTeleNameNpcIdCommand ( ChatHandler handler,
PlayerIdentifier  player,
Variant< Hyperlink< creature_entry >, uint32 creatureId 
)
inlinestatic
314 {
315 CreatureData const* spawnpoint = nullptr;
316 for (auto const& pair : sObjectMgr->GetAllCreatureData())
317 {
318 if (pair.second.id1 != *creatureId)
319 continue;
320
321 if (!spawnpoint)
322 spawnpoint = &pair.second;
323 else
324 {
326 break;
327 }
328 }
329
330 if (!spawnpoint)
331 {
333 return false;
334 }
335
336 CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(*creatureId));
337
338 return DoNameTeleport(handler, player, spawnpoint->mapid, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, creatureTemplate->Name);
339 }
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:85
@ LANG_COMMAND_GOCREATNOTFOUND
Definition: Language.h:313
@ LANG_COMMAND_GOCREATMULTIPLE
Definition: Language.h:314
Definition: CreatureData.h:189
std::string Name
Definition: CreatureData.h:194
Definition: CreatureData.h:373
uint16 mapid
Definition: CreatureData.h:378

References ASSERT_NOTNULL, DoNameTeleport(), LANG_COMMAND_GOCREATMULTIPLE, LANG_COMMAND_GOCREATNOTFOUND, CreatureData::mapid, CreatureTemplate::Name, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleTeleNameNpcNameCommand()

static bool tele_commandscript::HandleTeleNameNpcNameCommand ( ChatHandler handler,
PlayerIdentifier  player,
Tail  name 
)
inlinestatic
356 {
357 std::string normalizedName(name);
358 WorldDatabase.EscapeString(normalizedName);
359
360 // May need work //PussyWizardEliteMalcrom
361 QueryResult result = WorldDatabase.Query("SELECT c.position_x, c.position_y, c.position_z, c.orientation, c.map, ct.name FROM creature c INNER JOIN creature_template ct ON c.id1 = ct.entry WHERE ct.name LIKE '{}'", normalizedName);
362 if (!result)
363 {
365 return false;
366 }
367
368 if (result->GetRowCount() > 1)
370
371 Field* fields = result->Fetch();
372 return DoNameTeleport(handler, player, fields[4].Get<uint16>(), { fields[0].Get<float>(), fields[1].Get<float>(), fields[2].Get<float>(), fields[3].Get<float>() }, fields[5].Get<std::string>());
373 }
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20

References DoNameTeleport(), Field::Get(), LANG_COMMAND_GOCREATMULTIPLE, LANG_COMMAND_GOCREATNOTFOUND, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), and WorldDatabase.

Referenced by GetCommands().

◆ HandleTeleNameNpcSpawnIdCommand()

static bool tele_commandscript::HandleTeleNameNpcSpawnIdCommand ( ChatHandler handler,
PlayerIdentifier  player,
Variant< Hyperlink< creature >, ObjectGuid::LowType spawnId 
)
inlinestatic
342 {
343 CreatureData const* spawnpoint = sObjectMgr->GetCreatureData(spawnId);
344 if (!spawnpoint)
345 {
347 return false;
348 }
349
350 CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(spawnpoint->id1));
351
352 return DoNameTeleport(handler, player, spawnpoint->mapid, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, creatureTemplate->Name);
353 }
uint32 id1
Definition: CreatureData.h:375

References ASSERT_NOTNULL, DoNameTeleport(), CreatureData::id1, LANG_COMMAND_GOCREATNOTFOUND, CreatureData::mapid, CreatureTemplate::Name, ChatHandler::SendErrorMessage(), and sObjectMgr.

Referenced by GetCommands().