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
 
- 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
32: 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
109 {
110 if (!MapMgr::IsValidMapCoord(mapId, pos) || sObjectMgr->IsTransportMap(mapId))
111 {
112 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, pos.GetPositionX(), pos.GetPositionY(), mapId);
113 return false;
114 }
115
116 if (Player* target = player.GetConnectedPlayer())
117 {
118 // check online security
119 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
120 return false;
121
122 std::string chrNameLink = handler->playerLink(target->GetName());
123
124 if (target->IsBeingTeleported())
125 {
126 handler->SendErrorMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
127 return false;
128 }
129
130 handler->PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink, "", locationName);
131 if (handler->needReportToTarget(target))
132 ChatHandler(target->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink());
133
134 // stop flight if need
135 if (target->IsInFlight())
136 {
137 target->GetMotionMaster()->MovementExpired();
138 target->CleanupAfterTaxiFlight();
139 }
140 else // save only in non-flight case
141 target->SaveRecallPosition();
142
143 target->TeleportTo({ mapId, pos });
144 }
145 else
146 {
147 // check offline security
148 if (handler->HasLowerSecurity(nullptr, player.GetGUID()))
149 return false;
150
151 std::string nameLink = handler->playerLink(player.GetName());
152
153 handler->PSendSysMessage(LANG_TELEPORTING_TO, nameLink, handler->GetAcoreString(LANG_OFFLINE), locationName);
154
155 Player::SavePositionInDB({ mapId, pos }, sMapMgr->GetZoneId(PHASEMASK_NORMAL, { mapId, pos }), player.GetGUID(), nullptr);
156 }
157
158 return true;
159 }
@ LANG_OFFLINE
Definition Language.h:69
@ LANG_IS_TELEPORTED
Definition Language.h:135
@ LANG_INVALID_TARGET_COORD
Definition Language.h:309
@ LANG_TELEPORTED_TO_BY
Definition Language.h:144
@ LANG_TELEPORTING_TO
Definition Language.h:143
#define sMapMgr
Definition MapMgr.h:220
#define sObjectMgr
Definition ObjectMgr.h:1650
@ PHASEMASK_NORMAL
Definition Object.h:61
Definition Chat.h:37
virtual std::string GetNameLink() const
Definition Chat.h:198
std::string playerLink(std::string const &name) const
Definition Chat.h:231
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:216
virtual std::string GetAcoreString(uint32 entry) const
Definition Chat.cpp:41
virtual bool needReportToTarget(Player *chr) const
Definition Chat.cpp:864
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition Chat.cpp:57
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition MapMgr.h:90
static ObjectGuid const Empty
Definition ObjectGuid.h:120
Definition Player.h:1082
static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, ObjectGuid guid)
Definition PlayerMisc.cpp:84
ObjectGuid GetGUID() const
Definition ChatCommandTags.h:176
std::string const & GetName() const
Definition ChatCommandTags.h:175
Player * GetConnectedPlayer() const
Definition ChatCommandTags.h:178

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.

35 {
36 static ChatCommandTable teleNameNpcCommandTable =
37 {
38 { "id", HandleTeleNameNpcIdCommand, SEC_GAMEMASTER, Console::Yes },
39 { "guid", HandleTeleNameNpcSpawnIdCommand, SEC_GAMEMASTER, Console::Yes },
40 { "name", HandleTeleNameNpcNameCommand, SEC_GAMEMASTER, Console::Yes },
41 };
42 static ChatCommandTable teleNameCommandTable =
43 {
44 { "npc", teleNameNpcCommandTable },
45 { "", HandleTeleNameCommand, SEC_GAMEMASTER, Console::Yes },
46 };
47 static ChatCommandTable teleCommandTable =
48 {
49 { "add", HandleTeleAddCommand, SEC_ADMINISTRATOR, Console::No },
50 { "del", HandleTeleDelCommand, SEC_ADMINISTRATOR, Console::Yes },
51 { "name", teleNameCommandTable },
52 { "group", HandleTeleGroupCommand, SEC_GAMEMASTER, Console::No },
53 { "", HandleTeleCommand, SEC_GAMEMASTER, Console::No }
54 };
55 static ChatCommandTable commandTable =
56 {
57 { "teleport", teleCommandTable }
58 };
59 return commandTable;
60 }
@ SEC_ADMINISTRATOR
Definition Common.h:60
@ SEC_GAMEMASTER
Definition Common.h:59
static bool HandleTeleNameNpcNameCommand(ChatHandler *handler, PlayerIdentifier player, Tail name)
Definition cs_tele.cpp:348
static bool HandleTeleNameNpcIdCommand(ChatHandler *handler, PlayerIdentifier player, Variant< Hyperlink< creature_entry >, uint32 > creatureId)
Definition cs_tele.cpp:306
static bool HandleTeleNameCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, Variant< GameTele const *, EXACT_SEQUENCE("$home")> where)
Definition cs_tele.cpp:162
static bool HandleTeleNameNpcSpawnIdCommand(ChatHandler *handler, PlayerIdentifier player, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
Definition cs_tele.cpp:334
static bool HandleTeleAddCommand(ChatHandler *handler, std::string const &name)
Definition cs_tele.cpp:62
static bool HandleTeleCommand(ChatHandler *handler, GameTele const *tele)
Definition cs_tele.cpp:271
static bool HandleTeleDelCommand(ChatHandler *handler, GameTele const *tele)
Definition cs_tele.cpp:95
static bool HandleTeleGroupCommand(ChatHandler *handler, GameTele const *tele)
Definition cs_tele.cpp:198
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

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
63 {
64 Player* player = handler->GetSession()->GetPlayer();
65 if (!player)
66 return false;
67
68 if (sObjectMgr->GetGameTele(name, true))
69 {
71 return false;
72 }
73
74 GameTele tele;
75 tele.position_x = player->GetPositionX();
76 tele.position_y = player->GetPositionY();
77 tele.position_z = player->GetPositionZ();
78 tele.orientation = player->GetOrientation();
79 tele.mapId = player->GetMapId();
80 tele.name = name;
81
82 if (sObjectMgr->AddGameTele(tele))
83 {
85 }
86 else
87 {
89 return false;
90 }
91
92 return true;
93 }
@ LANG_COMMAND_TP_ALREADYEXIST
Definition Language.h:495
@ LANG_COMMAND_TP_ADDEDERR
Definition Language.h:497
@ LANG_COMMAND_TP_ADDED
Definition Language.h:496
WorldSession * GetSession()
Definition Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:160
uint32 GetMapId() const
Definition Position.h:280
Player * GetPlayer() const
Definition WorldSession.h:376
Definition ObjectMgr.h:132
float position_y
Definition ObjectMgr.h:134
float orientation
Definition ObjectMgr.h:136
float position_x
Definition ObjectMgr.h:133
uint32 mapId
Definition ObjectMgr.h:137
std::string name
Definition ObjectMgr.h:138
float position_z
Definition ObjectMgr.h:135
float GetPositionZ() const
Definition Position.h:123
float GetOrientation() const
Definition Position.h:124
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122

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
272 {
273 if (!tele)
274 {
276 return false;
277 }
278
279 Player* player = handler->GetSession()->GetPlayer();
280 if (player->IsInCombat())
281 {
283 return false;
284 }
285
286 MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
287 if (!map || (map->IsBattlegroundOrArena() && (player->GetMapId() != tele->mapId || !player->IsGameMaster())))
288 {
290 return false;
291 }
292
293 // stop flight if need
294 if (player->IsInFlight())
295 {
296 player->GetMotionMaster()->MovementExpired();
297 player->CleanupAfterTaxiFlight();
298 }
299 else // save only in non-flight case
300 player->SaveRecallPosition();
301
302 player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
303 return true;
304 }
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
@ LANG_YOU_IN_COMBAT
Definition Language.h:55
@ LANG_COMMAND_TELE_NOTFOUND
Definition Language.h:204
@ LANG_CANNOT_TELE_TO_BG
Definition Language.h:705
void MovementExpired(bool reset=true)
Definition MotionMaster.h:180
void SaveRecallPosition()
Definition Player.cpp:5667
bool IsGameMaster() const
Definition Player.h:1176
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1338
void CleanupAfterTaxiFlight()
Definition Player.cpp:10376
MotionMaster * GetMotionMaster()
Definition Unit.h:1664
bool IsInFlight() const
Definition Unit.h:1616
bool IsInCombat() const
Definition Unit.h:877
Definition DBCStructure.h:1326
bool IsBattlegroundOrArena() const
Definition DBCStructure.h:1358

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
96 {
97 if (!tele)
98 {
100 return false;
101 }
102 std::string name = tele->name;
103 sObjectMgr->DeleteGameTele(name);
105 return true;
106 }
@ LANG_COMMAND_TP_DELETED
Definition Language.h:498

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

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(), 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
163 {
164 if (!player)
165 player = PlayerIdentifier::FromTargetOrSelf(handler);
166 if (!player)
167 return false;
168
169 if (where.index() == 1) // References target's homebind
170 {
171 if (Player* target = player->GetConnectedPlayer())
172 target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation());
173 else
174 {
176 stmt->SetData(0, player->GetGUID().GetCounter());
177 PreparedQueryResult resultDB = CharacterDatabase.Query(stmt);
178
179 if (resultDB)
180 {
181 Field* fieldsDB = resultDB->Fetch();
182 WorldLocation loc(fieldsDB[0].Get<uint16>(), fieldsDB[2].Get<float>(), fieldsDB[3].Get<float>(), fieldsDB[4].Get<float>(), 0.0f);
183 uint32 zoneId = fieldsDB[1].Get<uint16>();
184
185 Player::SavePositionInDB(loc, zoneId, player->GetGUID(), nullptr);
186 }
187 }
188
189 return true;
190 }
191
192 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
193 GameTele const* tele = where.get<GameTele const*>();
194 return DoNameTeleport(handler, *player, tele->mapId, { tele->position_x, tele->position_y, tele->position_z, tele->orientation }, tele->name);
195 }
@ CHAR_SEL_CHAR_HOMEBIND
Definition CharacterDatabase.h:341
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
std::uint32_t uint32
Definition Define.h:107
std::uint16_t uint16
Definition Define.h:108
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
Definition Position.h:255
static bool DoNameTeleport(ChatHandler *handler, PlayerIdentifier player, uint32 mapId, Position const &pos, std::string const &locationName)
Definition cs_tele.cpp:108
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition ChatCommandTags.h:184
constexpr decltype(auto) get()
Definition ChatCommandTags.h:284

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
307 {
308 CreatureData const* spawnpoint = nullptr;
309 for (auto const& pair : sObjectMgr->GetAllCreatureData())
310 {
311 if (pair.second.id1 != *creatureId)
312 continue;
313
314 if (!spawnpoint)
315 spawnpoint = &pair.second;
316 else
317 {
319 break;
320 }
321 }
322
323 if (!spawnpoint)
324 {
326 return false;
327 }
328
329 CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(*creatureId));
330
331 return DoNameTeleport(handler, player, spawnpoint->mapid, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, creatureTemplate->Name);
332 }
#define ASSERT_NOTNULL(pointer)
Definition Errors.h:85
@ LANG_COMMAND_GOCREATNOTFOUND
Definition Language.h:314
@ LANG_COMMAND_GOCREATMULTIPLE
Definition Language.h:315
Definition CreatureData.h:370
uint16 mapid
Definition CreatureData.h:375
Definition CreatureData.h:186
std::string Name
Definition CreatureData.h:191

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
349 {
350 std::string normalizedName(name);
351 WorldDatabase.EscapeString(normalizedName);
352
353 // May need work //PussyWizardEliteMalcrom
354 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);
355 if (!result)
356 {
358 return false;
359 }
360
361 if (result->GetRowCount() > 1)
363
364 Field* fields = result->Fetch();
365 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>());
366 }
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
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
335 {
336 CreatureData const* spawnpoint = sObjectMgr->GetCreatureData(spawnId);
337 if (!spawnpoint)
338 {
340 return false;
341 }
342
343 CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(spawnpoint->id1));
344
345 return DoNameTeleport(handler, player, spawnpoint->mapid, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, creatureTemplate->Name);
346 }
uint32 id1
Definition CreatureData.h:372

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

Referenced by GetCommands().


The documentation for this class was generated from the following file: