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

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.

36 {
37 static ChatCommandTable teleNameNpcCommandTable =
38 {
42 };
43 static ChatCommandTable teleNameCommandTable =
44 {
45 { "npc", teleNameNpcCommandTable },
47 };
48 static ChatCommandTable teleCommandTable =
49 {
52 { "name", teleNameCommandTable },
55 };
56 static ChatCommandTable commandTable =
57 {
58 { "teleport", teleCommandTable }
59 };
60 return commandTable;
61 }
static bool HandleTeleNameNpcNameCommand(ChatHandler *handler, PlayerIdentifier player, Tail name)
Definition cs_tele.cpp:349
static bool HandleTeleNameNpcIdCommand(ChatHandler *handler, PlayerIdentifier player, Variant< Hyperlink< creature_entry >, uint32 > creatureId)
Definition cs_tele.cpp:307
static bool HandleTeleNameCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, Variant< GameTele const *, EXACT_SEQUENCE("$home")> where)
Definition cs_tele.cpp:163
static bool HandleTeleNameNpcSpawnIdCommand(ChatHandler *handler, PlayerIdentifier player, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
Definition cs_tele.cpp:335
static bool HandleTeleAddCommand(ChatHandler *handler, std::string const &name)
Definition cs_tele.cpp:63
static bool HandleTeleCommand(ChatHandler *handler, GameTele const *tele)
Definition cs_tele.cpp:272
static bool HandleTeleDelCommand(ChatHandler *handler, GameTele const *tele)
Definition cs_tele.cpp:96
static bool HandleTeleGroupCommand(ChatHandler *handler, GameTele const *tele)
Definition cs_tele.cpp:199
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_TELE_GROUP
Definition RBAC.h:568
@ RBAC_PERM_COMMAND_TELE_ADD
Definition RBAC.h:565
@ RBAC_PERM_COMMAND_TELE_NAME
Definition RBAC.h:567
@ RBAC_PERM_COMMAND_TELE
Definition RBAC.h:564
@ RBAC_PERM_COMMAND_TELE_DEL
Definition RBAC.h:566

References HandleTeleAddCommand(), HandleTeleCommand(), HandleTeleDelCommand(), HandleTeleGroupCommand(), HandleTeleNameCommand(), HandleTeleNameNpcIdCommand(), HandleTeleNameNpcNameCommand(), HandleTeleNameNpcSpawnIdCommand(), rbac::RBAC_PERM_COMMAND_TELE, rbac::RBAC_PERM_COMMAND_TELE_ADD, rbac::RBAC_PERM_COMMAND_TELE_DEL, rbac::RBAC_PERM_COMMAND_TELE_GROUP, and rbac::RBAC_PERM_COMMAND_TELE_NAME.

◆ HandleTeleAddCommand()

static bool tele_commandscript::HandleTeleAddCommand ( ChatHandler handler,
std::string const &  name 
)
inlinestatic
64 {
65 Player* player = handler->GetSession()->GetPlayer();
66 if (!player)
67 return false;
68
69 if (sObjectMgr->GetGameTele(name, true))
70 {
72 return false;
73 }
74
75 GameTele tele;
76 tele.position_x = player->GetPositionX();
77 tele.position_y = player->GetPositionY();
78 tele.position_z = player->GetPositionZ();
79 tele.orientation = player->GetOrientation();
80 tele.mapId = player->GetMapId();
81 tele.name = name;
82
83 if (sObjectMgr->AddGameTele(tele))
84 {
86 }
87 else
88 {
90 return false;
91 }
92
93 return true;
94 }
@ LANG_COMMAND_TP_ALREADYEXIST
Definition Language.h:503
@ LANG_COMMAND_TP_ADDEDERR
Definition Language.h:505
@ LANG_COMMAND_TP_ADDED
Definition Language.h:504
WorldSession * GetSession()
Definition Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168
uint32 GetMapId() const
Definition Position.h:281
Player * GetPlayer() const
Definition WorldSession.h:454
Definition ObjectMgr.h:133
float position_y
Definition ObjectMgr.h:135
float orientation
Definition ObjectMgr.h:137
float position_x
Definition ObjectMgr.h:134
uint32 mapId
Definition ObjectMgr.h:138
std::string name
Definition ObjectMgr.h:139
float position_z
Definition ObjectMgr.h:136
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
273 {
274 if (!tele)
275 {
277 return false;
278 }
279
280 Player* player = handler->GetSession()->GetPlayer();
281 if (player->IsInCombat())
282 {
284 return false;
285 }
286
287 MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
288 if (!map || (map->IsBattlegroundOrArena() && (player->GetMapId() != tele->mapId || !player->IsGameMaster())))
289 {
291 return false;
292 }
293
294 // stop flight if need
295 if (player->IsInFlight())
296 {
297 player->GetMotionMaster()->MovementExpired();
298 player->CleanupAfterTaxiFlight();
299 }
300 else // save only in non-flight case
301 player->SaveRecallPosition();
302
303 player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
304 return true;
305 }
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
@ LANG_YOU_IN_COMBAT
Definition Language.h:55
@ LANG_COMMAND_TELE_NOTFOUND
Definition Language.h:207
@ LANG_CANNOT_TELE_TO_BG
Definition Language.h:715
void MovementExpired(bool reset=true)
Definition MotionMaster.h:206
void SaveRecallPosition()
Definition Player.cpp:5660
bool IsGameMaster() const
Definition Player.h:1174
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1353
void CleanupAfterTaxiFlight()
Definition Player.cpp:10375
MotionMaster * GetMotionMaster()
Definition Unit.h:1759
bool IsInFlight() const
Definition Unit.h:1706
bool IsInCombat() const
Definition Unit.h:935
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
97 {
98 if (!tele)
99 {
101 return false;
102 }
103 std::string name = tele->name;
104 sObjectMgr->DeleteGameTele(name);
106 return true;
107 }
@ LANG_COMMAND_TP_DELETED
Definition Language.h:506

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

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
164 {
165 if (!player)
166 player = PlayerIdentifier::FromTargetOrSelf(handler);
167 if (!player)
168 return false;
169
170 if (where.index() == 1) // References target's homebind
171 {
172 if (Player* target = player->GetConnectedPlayer())
173 target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation());
174 else
175 {
177 stmt->SetData(0, player->GetGUID().GetCounter());
178 PreparedQueryResult resultDB = CharacterDatabase.Query(stmt);
179
180 if (resultDB)
181 {
182 Field* fieldsDB = resultDB->Fetch();
183 WorldLocation loc(fieldsDB[0].Get<uint16>(), fieldsDB[2].Get<float>(), fieldsDB[3].Get<float>(), fieldsDB[4].Get<float>(), 0.0f);
184 uint32 zoneId = fieldsDB[1].Get<uint16>();
185
186 Player::SavePositionInDB(loc, zoneId, player->GetGUID(), nullptr);
187 }
188 }
189
190 return true;
191 }
192
193 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
194 GameTele const* tele = where.get<GameTele const*>();
195 return DoNameTeleport(handler, *player, tele->mapId, { tele->position_x, tele->position_y, tele->position_z, tele->orientation }, tele->name);
196 }
@ CHAR_SEL_CHAR_HOMEBIND
Definition CharacterDatabase.h:343
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:256
static bool DoNameTeleport(ChatHandler *handler, PlayerIdentifier player, uint32 mapId, Position const &pos, std::string const &locationName)
Definition cs_tele.cpp:109
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition ChatCommandTags.h:189
constexpr decltype(auto) get()
Definition ChatCommandTags.h:289

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

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

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

Referenced by GetCommands().


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