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
 

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)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ tele_commandscript()

tele_commandscript::tele_commandscript ( )
inline
40: CommandScript("tele_commandscript") { }
Definition: ScriptMgr.h:850

Member Function Documentation

◆ DoNameTeleport()

static bool tele_commandscript::DoNameTeleport ( ChatHandler handler,
PlayerIdentifier  player,
uint32  mapId,
Position const &  pos,
std::string const &  locationName 
)
inlinestatic
120 {
121 if (!MapMgr::IsValidMapCoord(mapId, pos) || sObjectMgr->IsTransportMap(mapId))
122 {
123 handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, pos.GetPositionX(), pos.GetPositionY(), mapId);
124 handler->SetSentErrorMessage(true);
125 return false;
126 }
127
128 if (Player* target = player.GetConnectedPlayer())
129 {
130 // check online security
131 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
132 return false;
133
134 std::string chrNameLink = handler->playerLink(target->GetName());
135
136 if (target->IsBeingTeleported())
137 {
138 handler->PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
139 handler->SetSentErrorMessage(true);
140 return false;
141 }
142
143 handler->PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(), "", locationName.c_str());
144 if (handler->needReportToTarget(target))
145 ChatHandler(target->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink().c_str());
146
147 // stop flight if need
148 if (target->IsInFlight())
149 {
150 target->GetMotionMaster()->MovementExpired();
151 target->CleanupAfterTaxiFlight();
152 }
153 else // save only in non-flight case
154 target->SaveRecallPosition();
155
156 target->TeleportTo({ mapId, pos });
157 }
158 else
159 {
160 // check offline security
161 if (handler->HasLowerSecurity(nullptr, player.GetGUID()))
162 return false;
163
164 std::string nameLink = handler->playerLink(player.GetName());
165
166 handler->PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), handler->GetAcoreString(LANG_OFFLINE), locationName.c_str());
167
168 Player::SavePositionInDB({ mapId, pos }, sMapMgr->GetZoneId(PHASEMASK_NORMAL, { mapId, pos }), player.GetGUID(), nullptr);
169 }
170
171 return true;
172 }
@ PHASEMASK_NORMAL
Definition: Object.h:56
#define sObjectMgr
Definition: ObjectMgr.h:1640
#define sMapMgr
Definition: MapMgr.h:221
@ 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
Definition: Chat.h:38
virtual std::string GetNameLink() const
Definition: Chat.h:84
std::string playerLink(std::string const &name) const
Definition: Chat.h:111
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:42
void SetSentErrorMessage(bool val)
Definition: Chat.h:118
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:776
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:53
ObjectGuid GetGUID() const
Definition: ChatCommandTags.h:181
std::string const & GetName() const
Definition: ChatCommandTags.h:180
Player * GetConnectedPlayer() const
Definition: ChatCommandTags.h:183
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
Definition: Player.h:1046
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::SetSentErrorMessage(), sMapMgr, and sObjectMgr.

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

◆ GetCommands()

ChatCommandTable tele_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

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

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
71 {
72 Player* player = handler->GetSession()->GetPlayer();
73 if (!player)
74 return false;
75
76 if (sObjectMgr->GetGameTele(name))
77 {
79 handler->SetSentErrorMessage(true);
80 return false;
81 }
82
83 GameTele tele;
84 tele.position_x = player->GetPositionX();
85 tele.position_y = player->GetPositionY();
86 tele.position_z = player->GetPositionZ();
87 tele.orientation = player->GetOrientation();
88 tele.mapId = player->GetMapId();
89 tele.name = name;
90
91 if (sObjectMgr->AddGameTele(tele))
92 {
94 }
95 else
96 {
98 handler->SetSentErrorMessage(true);
99 return false;
100 }
101
102 return true;
103 }
@ LANG_COMMAND_TP_ALREADYEXIST
Definition: Language.h:477
@ LANG_COMMAND_TP_ADDEDERR
Definition: Language.h:479
@ LANG_COMMAND_TP_ADDED
Definition: Language.h:478
WorldSession * GetSession()
Definition: Chat.h:122
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
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:361

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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleTeleCommand()

static bool tele_commandscript::HandleTeleCommand ( ChatHandler handler,
GameTele const *  tele 
)
inlinestatic
289 {
290 if (!tele)
291 {
293 handler->SetSentErrorMessage(true);
294 return false;
295 }
296
297 Player* player = handler->GetSession()->GetPlayer();
298 if (player->IsInCombat())
299 {
301 handler->SetSentErrorMessage(true);
302 return false;
303 }
304
305 MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
306 if (!map || (map->IsBattlegroundOrArena() && (player->GetMapId() != tele->mapId || !player->IsGameMaster())))
307 {
309 handler->SetSentErrorMessage(true);
310 return false;
311 }
312
313 // stop flight if need
314 if (player->IsInFlight())
315 {
316 player->GetMotionMaster()->MovementExpired();
317 player->CleanupAfterTaxiFlight();
318 }
319 else // save only in non-flight case
320 player->SaveRecallPosition();
321
322 player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
323 return true;
324 }
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:684
void SaveRecallPosition()
Definition: Player.cpp:5564
bool IsGameMaster() const
Definition: Player.h:1136
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1311
void CleanupAfterTaxiFlight()
Definition: Player.cpp:10325
MotionMaster * GetMotionMaster()
Definition: Unit.h:2262
bool IsInFlight() const
Definition: Unit.h:1676
bool IsInCombat() const
Definition: Unit.h:1688
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178
Definition: DBCStructure.h:1308
bool IsBattlegroundOrArena() const
Definition: DBCStructure.h:1340

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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), sMapStore, and Player::TeleportTo().

Referenced by GetCommands().

◆ HandleTeleDelCommand()

static bool tele_commandscript::HandleTeleDelCommand ( ChatHandler handler,
GameTele const *  tele 
)
inlinestatic
106 {
107 if (!tele)
108 {
110 handler->SetSentErrorMessage(true);
111 return false;
112 }
113 std::string name = tele->name;
114 sObjectMgr->DeleteGameTele(name);
116 return true;
117 }
@ LANG_COMMAND_TP_DELETED
Definition: Language.h:480

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

Referenced by GetCommands().

◆ HandleTeleGroupCommand()

static bool tele_commandscript::HandleTeleGroupCommand ( ChatHandler handler,
GameTele const *  tele 
)
inlinestatic
212 {
213 if (!tele)
214 {
216 handler->SetSentErrorMessage(true);
217 return false;
218 }
219
220 Player* target = handler->getSelectedPlayer();
221 if (!target)
222 {
224 handler->SetSentErrorMessage(true);
225 return false;
226 }
227
228 // check online security
229 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
230 return false;
231
232 MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
233 if (!map || map->IsBattlegroundOrArena())
234 {
236 handler->SetSentErrorMessage(true);
237 return false;
238 }
239
240 std::string nameLink = handler->GetNameLink(target);
241
242 Group* grp = target->GetGroup();
243 if (!grp)
244 {
245 handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
246 handler->SetSentErrorMessage(true);
247 return false;
248 }
249
250 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
251 {
252 Player* player = itr->GetSource();
253
254 if (!player || !player->GetSession())
255 continue;
256
257 // check online security
258 if (handler->HasLowerSecurity(player, ObjectGuid::Empty))
259 return false;
260
261 std::string plNameLink = handler->GetNameLink(player);
262
263 if (player->IsBeingTeleported())
264 {
265 handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
266 continue;
267 }
268
269 handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name.c_str());
270 if (handler->needReportToTarget(player))
271 ChatHandler(player->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());
272
273 // stop flight if need
274 if (target->IsInFlight())
275 {
276 target->GetMotionMaster()->MovementExpired();
277 target->CleanupAfterTaxiFlight();
278 }
279 else // save only in non-flight case
280 target->SaveRecallPosition();
281
282 player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
283 }
284
285 return true;
286 }
@ LANG_NOT_IN_GROUP
Definition: Language.h:149
@ LANG_NO_CHAR_SELECTED
Definition: Language.h:148
Player * getSelectedPlayer() const
Definition: Chat.cpp:301
WorldSession * GetSession() const
Definition: Player.h:1948
Group * GetGroup()
Definition: Player.h:2418
bool IsBeingTeleported() const
Definition: Player.h:2041
Definition: Group.h:168
GroupReference * GetFirstMember()
Definition: Group.h:242
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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), 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
176 {
177 if (!player)
178 player = PlayerIdentifier::FromTargetOrSelf(handler);
179 if (!player)
180 return false;
181
182 if (where.index() == 1) // References target's homebind
183 {
184 if (Player* target = player->GetConnectedPlayer())
185 target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->m_homebindO);
186 else
187 {
189 stmt->SetData(0, player->GetGUID().GetCounter());
190 PreparedQueryResult resultDB = CharacterDatabase.Query(stmt);
191
192 if (resultDB)
193 {
194 Field* fieldsDB = resultDB->Fetch();
195 WorldLocation loc(fieldsDB[0].Get<uint16>(), fieldsDB[2].Get<float>(), fieldsDB[3].Get<float>(), fieldsDB[4].Get<float>(), 0.0f);
196 uint32 zoneId = fieldsDB[1].Get<uint16>();
197
198 Player::SavePositionInDB(loc, zoneId, player->GetGUID(), nullptr);
199 }
200 }
201
202 return true;
203 }
204
205 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
206 GameTele const* tele = where.get<GameTele const*>();
207 return DoNameTeleport(handler, *player, tele->mapId, { tele->position_x, tele->position_y, tele->position_z, tele->orientation }, tele->name);
208 }
std::uint32_t uint32
Definition: Define.h:108
std::uint16_t uint16
Definition: Define.h:109
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ CHAR_SEL_CHAR_HOMEBIND
Definition: CharacterDatabase.h:339
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:189
constexpr decltype(auto) get()
Definition: ChatCommandTags.h:289
Definition: Position.h:251
static bool DoNameTeleport(ChatHandler *handler, PlayerIdentifier player, uint32 mapId, Position const &pos, std::string const &locationName)
Definition: cs_tele.cpp:119

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
327 {
328 CreatureData const* spawnpoint = nullptr;
329 for (auto const& pair : sObjectMgr->GetAllCreatureData())
330 {
331 if (pair.second.id1 != *creatureId)
332 continue;
333
334 if (!spawnpoint)
335 spawnpoint = &pair.second;
336 else
337 {
339 break;
340 }
341 }
342
343 if (!spawnpoint)
344 {
346 handler->SetSentErrorMessage(true);
347 return false;
348 }
349
350 CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(*creatureId));
351
352 return DoNameTeleport(handler, player, spawnpoint->mapid, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, creatureTemplate->Name);
353 }
#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:176
std::string Name
Definition: CreatureData.h:184
Definition: CreatureData.h:359
uint16 mapid
Definition: CreatureData.h:364

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

Referenced by GetCommands().

◆ HandleTeleNameNpcNameCommand()

static bool tele_commandscript::HandleTeleNameNpcNameCommand ( ChatHandler handler,
PlayerIdentifier  player,
Tail  name 
)
inlinestatic
371 {
372 std::string normalizedName(name);
373 WorldDatabase.EscapeString(normalizedName);
374
375 // May need work //PussyWizardEliteMalcrom
376 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);
377 if (!result)
378 {
380 handler->SetSentErrorMessage(true);
381 return false;
382 }
383
384 if (result->GetRowCount() > 1)
386
387 Field* fields = result->Fetch();
388 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>());
389 }
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28

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

Referenced by GetCommands().

◆ HandleTeleNameNpcSpawnIdCommand()

static bool tele_commandscript::HandleTeleNameNpcSpawnIdCommand ( ChatHandler handler,
PlayerIdentifier  player,
Variant< Hyperlink< creature >, ObjectGuid::LowType spawnId 
)
inlinestatic
356 {
357 CreatureData const* spawnpoint = sObjectMgr->GetCreatureData(spawnId);
358 if (!spawnpoint)
359 {
361 handler->SetSentErrorMessage(true);
362 return false;
363 }
364
365 CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(spawnpoint->id1));
366
367 return DoNameTeleport(handler, player, spawnpoint->mapid, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, creatureTemplate->Name);
368 }
uint32 id1
Definition: CreatureData.h:361

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

Referenced by GetCommands().