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

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:62
@ SEC_GAMEMASTER
Definition: Common.h:61
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
static bool HandleTeleNameNpcNameCommand(ChatHandler *handler, PlayerIdentifier player, Tail name)
Definition: cs_tele.cpp:356
static bool HandleTeleNameNpcIdCommand(ChatHandler *handler, PlayerIdentifier player, Variant< Hyperlink< creature_entry >, uint32 > creatureId)
Definition: cs_tele.cpp:314
static bool HandleTeleNameCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, Variant< GameTele const *, EXACT_SEQUENCE("$home")> where)
Definition: cs_tele.cpp:170
static bool HandleTeleNameNpcSpawnIdCommand(ChatHandler *handler, PlayerIdentifier player, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
Definition: cs_tele.cpp:342
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:279
static bool HandleTeleDelCommand(ChatHandler *handler, GameTele const *tele)
Definition: cs_tele.cpp:103
static bool HandleTeleGroupCommand(ChatHandler *handler, GameTele const *tele)
Definition: cs_tele.cpp:206

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 return false;
80 }
81
82 GameTele tele;
83 tele.position_x = player->GetPositionX();
84 tele.position_y = player->GetPositionY();
85 tele.position_z = player->GetPositionZ();
86 tele.orientation = player->GetOrientation();
87 tele.mapId = player->GetMapId();
88 tele.name = name;
89
90 if (sObjectMgr->AddGameTele(tele))
91 {
93 }
94 else
95 {
97 return false;
98 }
99
100 return true;
101 }
@ 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:139
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:101
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:364

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
280 {
281 if (!tele)
282 {
284 return false;
285 }
286
287 Player* player = handler->GetSession()->GetPlayer();
288 if (player->IsInCombat())
289 {
291 return false;
292 }
293
294 MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
295 if (!map || (map->IsBattlegroundOrArena() && (player->GetMapId() != tele->mapId || !player->IsGameMaster())))
296 {
298 return false;
299 }
300
301 // stop flight if need
302 if (player->IsInFlight())
303 {
304 player->GetMotionMaster()->MovementExpired();
305 player->CleanupAfterTaxiFlight();
306 }
307 else // save only in non-flight case
308 player->SaveRecallPosition();
309
310 player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
311 return true;
312 }
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:687
void SaveRecallPosition()
Definition: Player.cpp:5577
bool IsGameMaster() const
Definition: Player.h:1148
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1314
void CleanupAfterTaxiFlight()
Definition: Player.cpp:10346
MotionMaster * GetMotionMaster()
Definition: Unit.h:2276
bool IsInFlight() const
Definition: Unit.h:1690
bool IsInCombat() const
Definition: Unit.h:1702
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178
Definition: DBCStructure.h:1323
bool IsBattlegroundOrArena() const
Definition: DBCStructure.h:1355

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
104 {
105 if (!tele)
106 {
108 return false;
109 }
110 std::string name = tele->name;
111 sObjectMgr->DeleteGameTele(name);
113 return true;
114 }
@ LANG_COMMAND_TP_DELETED
Definition: Language.h:480

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
207 {
208 if (!tele)
209 {
211 return false;
212 }
213
214 Player* target = handler->getSelectedPlayer();
215 if (!target)
216 {
218 return false;
219 }
220
221 // check online security
222 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
223 return false;
224
225 MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
226 if (!map || map->IsBattlegroundOrArena())
227 {
229 return false;
230 }
231
232 std::string nameLink = handler->GetNameLink(target);
233
234 Group* grp = target->GetGroup();
235 if (!grp)
236 {
237 handler->SendErrorMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
238 return false;
239 }
240
241 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
242 {
243 Player* player = itr->GetSource();
244
245 if (!player || !player->GetSession())
246 continue;
247
248 // check online security
249 if (handler->HasLowerSecurity(player, ObjectGuid::Empty))
250 return false;
251
252 std::string plNameLink = handler->GetNameLink(player);
253
254 if (player->IsBeingTeleported())
255 {
256 handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
257 continue;
258 }
259
260 handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name.c_str());
261 if (handler->needReportToTarget(player))
262 ChatHandler(player->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());
263
264 // stop flight if need
265 if (target->IsInFlight())
266 {
267 target->GetMotionMaster()->MovementExpired();
268 target->CleanupAfterTaxiFlight();
269 }
270 else // save only in non-flight case
271 target->SaveRecallPosition();
272
273 player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
274 }
275
276 return true;
277 }
@ LANG_NOT_IN_GROUP
Definition: Language.h:149
@ LANG_NO_CHAR_SELECTED
Definition: Language.h:148
Player * getSelectedPlayer() const
Definition: Chat.cpp:310
WorldSession * GetSession() const
Definition: Player.h:1961
Group * GetGroup()
Definition: Player.h:2431
bool IsBeingTeleported() const
Definition: Player.h:2054
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
171 {
172 if (!player)
173 player = PlayerIdentifier::FromTargetOrSelf(handler);
174 if (!player)
175 return false;
176
177 if (where.index() == 1) // References target's homebind
178 {
179 if (Player* target = player->GetConnectedPlayer())
180 target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->m_homebindO);
181 else
182 {
184 stmt->SetData(0, player->GetGUID().GetCounter());
185 PreparedQueryResult resultDB = CharacterDatabase.Query(stmt);
186
187 if (resultDB)
188 {
189 Field* fieldsDB = resultDB->Fetch();
190 WorldLocation loc(fieldsDB[0].Get<uint16>(), fieldsDB[2].Get<float>(), fieldsDB[3].Get<float>(), fieldsDB[4].Get<float>(), 0.0f);
191 uint32 zoneId = fieldsDB[1].Get<uint16>();
192
193 Player::SavePositionInDB(loc, zoneId, player->GetGUID(), nullptr);
194 }
195 }
196
197 return true;
198 }
199
200 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
201 GameTele const* tele = where.get<GameTele const*>();
202 return DoNameTeleport(handler, *player, tele->mapId, { tele->position_x, tele->position_y, tele->position_z, tele->orientation }, tele->name);
203 }
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: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:116

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
315 {
316 CreatureData const* spawnpoint = nullptr;
317 for (auto const& pair : sObjectMgr->GetAllCreatureData())
318 {
319 if (pair.second.id1 != *creatureId)
320 continue;
321
322 if (!spawnpoint)
323 spawnpoint = &pair.second;
324 else
325 {
327 break;
328 }
329 }
330
331 if (!spawnpoint)
332 {
334 return false;
335 }
336
337 CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(*creatureId));
338
339 return DoNameTeleport(handler, player, spawnpoint->mapid, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, creatureTemplate->Name);
340 }
#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::SendErrorMessage(), ChatHandler::SendSysMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleTeleNameNpcNameCommand()

static bool tele_commandscript::HandleTeleNameNpcNameCommand ( ChatHandler handler,
PlayerIdentifier  player,
Tail  name 
)
inlinestatic
357 {
358 std::string normalizedName(name);
359 WorldDatabase.EscapeString(normalizedName);
360
361 // May need work //PussyWizardEliteMalcrom
362 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);
363 if (!result)
364 {
366 return false;
367 }
368
369 if (result->GetRowCount() > 1)
371
372 Field* fields = result->Fetch();
373 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>());
374 }
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::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
343 {
344 CreatureData const* spawnpoint = sObjectMgr->GetCreatureData(spawnId);
345 if (!spawnpoint)
346 {
348 return false;
349 }
350
351 CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(spawnpoint->id1));
352
353 return DoNameTeleport(handler, player, spawnpoint->mapid, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, creatureTemplate->Name);
354 }
uint32 id1
Definition: CreatureData.h:361

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

Referenced by GetCommands().