2 * Copyright (C) 2005,2006 MaNGOS <http://www.mangosproject.org/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
24 #include "ObjectMgr.h"
29 #include "MapManager.h"
30 #include "ObjectAccessor.h"
32 #include "RedZoneDistrict.h"
33 #include "Transports.h"
35 bool ChatHandler::HandleAnnounceCommand(const char* args
)
44 sprintf((char*)pAnnounce
, LANG_BROADCAST
, args
);
45 sWorld
.SendWorldText(pAnnounce
);
50 bool ChatHandler::HandleGMOnCommand(const char* args
)
52 m_session
->GetPlayer()->SetGameMaster(true);
53 m_session
->GetPlayer()->CombatStop();
58 bool ChatHandler::HandleGMOffCommand(const char* args
)
60 m_session
->GetPlayer()->SetGameMaster(false);
65 bool ChatHandler::HandleVisibleCommand(const char* args
)
67 int option
= atoi((char*)args
);
69 if (option
!= 0 && option
!= 1 || !*args
)
71 SendSysMessage(LANG_USE_BOL
);
72 PSendSysMessage("Your are: %s", m_session
->GetPlayer()->isGMVisible() ? "visible" : "invisible");
78 SendSysMessage( LANG_INVISIBLE_VISIBLE
);
79 m_session
->GetPlayer()->SetGMVisible(true);
83 if(m_session
->GetPlayer()->GetGuildId())
85 SendSysMessage( LANG_INVISIBLE_GUILD
);
89 SendSysMessage( LANG_INVISIBLE_INVISIBLE
);
90 m_session
->GetPlayer()->SetGMVisible(false);
96 bool ChatHandler::HandleGPSCommand(const char* args
)
98 Object
*obj
= getSelectedUnit();
102 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
106 CellPair cell_val
= MaNGOS::ComputeCellPair(obj
->GetPositionX(), obj
->GetPositionY());
107 Cell cell
= RedZone::GetZone(cell_val
);
109 PSendSysMultilineMessage(LANG_MAP_POSITION
,
110 obj
->GetMapId(), obj
->GetZoneId(), obj
->GetPositionX(), obj
->GetPositionY(), obj
->GetPositionZ(),
111 obj
->GetOrientation(),cell
.GridX(), cell
.GridY(), cell
.CellX(), cell
.CellY());
113 sLog
.outDebug("Player %s GPS call %s %u " LANG_MAP_POSITION
, m_session
->GetPlayer()->GetName(),
114 (obj
->GetTypeId() == TYPEID_PLAYER
? "player" : "creature"), obj
->GetGUIDLow(),
115 obj
->GetMapId(), obj
->GetZoneId(), obj
->GetPositionX(), obj
->GetPositionY(), obj
->GetPositionZ(),
116 obj
->GetOrientation(), cell
.GridX(), cell
.GridY(), cell
.CellX(), cell
.CellY());
121 bool ChatHandler::HandleNamegoCommand(const char* args
)
123 if(m_session
->GetPlayer()->isInFlight())
125 SendSysMessage(LANG_YOU_IN_FLIGHT
);
134 std::string name
= args
;
135 normalizePlayerName(name
);
136 sDatabase
.escape_string(name
); // prevent SQL injection - normal name don't must changed by this call
138 Player
*chr
= objmgr
.GetPlayer(name
.c_str());
142 if(chr
->IsBeingTeleported()==true)
144 PSendSysMessage(LANG_IS_TELEPORTED
, chr
->GetName());
148 if(chr
->isInFlight())
150 PSendSysMessage(LANG_CHAR_IN_FLIGHT
,chr
->GetName());
154 PSendSysMessage(LANG_SUMMONING
, chr
->GetName(),"");
157 snprintf((char*)buf0
,256,LANG_SUMMONED_BY
, m_session
->GetPlayer()->GetName());
158 FillSystemMessageData(&data
, m_session
, buf0
);
159 chr
->GetSession()->SendPacket( &data
);
161 chr
->TeleportTo(m_session
->GetPlayer()->GetMapId(),
162 m_session
->GetPlayer()->GetPositionX(),
163 m_session
->GetPlayer()->GetPositionY(),
164 m_session
->GetPlayer()->GetPositionZ(),
165 chr
->GetOrientation());
167 else if (uint64 guid
= objmgr
.GetPlayerGUIDByName(name
.c_str()))
169 PSendSysMessage(LANG_SUMMONING
, name
.c_str()," (offline)");
171 Player::SavePositionInDB(m_session
->GetPlayer()->GetMapId(),
172 m_session
->GetPlayer()->GetPositionX(),
173 m_session
->GetPlayer()->GetPositionY(),
174 m_session
->GetPlayer()->GetPositionZ(),m_session
->GetPlayer()->GetOrientation(),guid
);
177 PSendSysMessage(LANG_NO_PLAYER
, args
);
182 bool ChatHandler::HandleGonameCommand(const char* args
)
184 if(m_session
->GetPlayer()->isInFlight())
186 SendSysMessage(LANG_YOU_IN_FLIGHT
);
193 std::string name
= args
;
194 normalizePlayerName(name
);
195 sDatabase
.escape_string(name
); // prevent SQL injection - normal name don't must changed by this call
197 Player
*chr
= objmgr
.GetPlayer(name
.c_str());
200 PSendSysMessage(LANG_APPEARING_AT
, chr
->GetName());
202 if (m_session
->GetPlayer()->isVisibleFor(chr
))
205 sprintf((char*)buf0
,LANG_APPEARING_TO
, m_session
->GetPlayer()->GetName());
208 FillSystemMessageData(&data
, m_session
, buf0
);
209 chr
->GetSession()->SendPacket(&data
);
212 m_session
->GetPlayer()->TeleportTo(chr
->GetMapId(), chr
->GetPositionX(), chr
->GetPositionY(), chr
->GetPositionZ(),m_session
->GetPlayer()->GetOrientation());
216 if (uint64 guid
= objmgr
.GetPlayerGUIDByName(name
.c_str()))
218 PSendSysMessage(LANG_APPEARING_AT
, name
.c_str());
222 if(Player::LoadPositionFromDB(map
,x
,y
,z
,o
,guid
))
224 m_session
->GetPlayer()->TeleportTo(map
, x
, y
, z
,m_session
->GetPlayer()->GetOrientation());
229 PSendSysMessage(LANG_NO_PLAYER
, args
);
234 bool ChatHandler::HandleRecallCommand(const char* args
)
239 if(m_session
->GetPlayer()->isInFlight())
241 SendSysMessage(LANG_YOU_IN_FLIGHT
);
245 if (strncmp((char*)args
,"sunr",5)==0)
246 m_session
->GetPlayer()->TeleportTo(1, -180.949f
, -296.467f
, 11.5384f
,0.0f
);
247 else if (strncmp((char*)args
,"thun",5)==0)
248 m_session
->GetPlayer()->TeleportTo(1, -1196.22f
, 29.0941f
, 176.949f
,0.0f
);
249 else if (strncmp((char*)args
,"cross",6)==0)
250 m_session
->GetPlayer()->TeleportTo(1, -443.128f
, -2598.87f
, 96.2114f
,0.0f
);
251 else if (strncmp((char*)args
,"orgr",5)==0)
252 m_session
->GetPlayer()->TeleportTo(1, 1676.21f
, -4315.29f
, 61.5293f
,0.0f
);
253 else if (strncmp((char*)args
,"neth",5)==0)
254 m_session
->GetPlayer()->TeleportTo(0, -10996.9f
, -3427.67f
, 61.996f
,0.0f
);
255 else if (strncmp((char*)args
,"thel",5)==0)
256 m_session
->GetPlayer()->TeleportTo(0, -5395.57f
, -3015.79f
, 327.58f
,0.0f
);
257 else if (strncmp((char*)args
,"storm",6)==0)
258 m_session
->GetPlayer()->TeleportTo(0, -8913.23f
, 554.633f
, 93.7944f
,0.0f
);
259 else if (strncmp((char*)args
,"iron",5)==0)
260 m_session
->GetPlayer()->TeleportTo(0, -4981.25f
, -881.542f
, 501.66f
,0.0f
);
261 else if (strncmp((char*)args
,"under",6)==0)
262 m_session
->GetPlayer()->TeleportTo(0, 1586.48f
, 239.562f
, -52.149f
,0.0f
);
263 else if (strncmp((char*)args
,"darn",5)==0)
264 m_session
->GetPlayer()->TeleportTo(1, 10037.6f
, 2496.8f
, 1318.4f
,0.0f
);
265 else if (strncmp((char*)args
,"gm",5)==0)
266 m_session
->GetPlayer()->TeleportTo(1, 16202.5, 16205, 1,1.15);
267 else if (strncmp((char*)args
,"g",2)==0)
268 m_session
->GetPlayer()->TeleportTo(1, 1335.3f
, -4646.8f
, 53.54f
, 3.6909f
);
275 bool ChatHandler::HandleModifyHPCommand(const char* args
)
279 // char* pHp = strtok((char*)args, " ");
283 // char* pHpMax = strtok(NULL, " ");
287 // int32 hpm = atoi(pHpMax);
288 // int32 hp = atoi(pHp);
290 int32 hp
= atoi((char*)args
);
291 int32 hpm
= atoi((char*)args
);
293 if (hp
<= 0 || hpm
<= 0 || hpm
< hp
)
295 SendSysMessage(LANG_BAD_VALUE
);
299 Player
*chr
= getSelectedPlayer();
302 SendSysMessage(LANG_NO_CHAR_SELECTED
);
306 PSendSysMessage(LANG_YOU_CHANGE_HP
, hp
, hpm
, chr
->GetName());
309 sprintf((char*)buf
,LANG_YOURS_HP_CHANGED
, m_session
->GetPlayer()->GetName(), hp
, hpm
);
310 FillSystemMessageData(&data
, m_session
, buf
);
312 chr
->GetSession()->SendPacket(&data
);
314 chr
->SetMaxHealth( hpm
);
315 chr
->SetHealth( hp
);
320 bool ChatHandler::HandleModifyManaCommand(const char* args
)
324 // char* pmana = strtok((char*)args, " ");
328 // char* pmanaMax = strtok(NULL, " ");
332 // int32 manam = atoi(pmanaMax);
333 // int32 mana = atoi(pmana);
334 int32 mana
= atoi((char*)args
);
335 int32 manam
= atoi((char*)args
);
337 if (mana
<= 0 || manam
<= 0 || manam
< mana
)
339 SendSysMessage(LANG_BAD_VALUE
);
343 Player
*chr
= getSelectedPlayer();
346 SendSysMessage(LANG_NO_CHAR_SELECTED
);
350 PSendSysMessage(LANG_YOU_CHANGE_MANA
, mana
, manam
, chr
->GetName());
353 sprintf((char*)buf
,LANG_YOURS_MANA_CHANGED
, m_session
->GetPlayer()->GetName(), mana
, manam
);
354 FillSystemMessageData(&data
, m_session
, buf
);
356 chr
->GetSession()->SendPacket(&data
);
358 chr
->SetMaxPower(POWER_MANA
,manam
);
359 chr
->SetPower(POWER_MANA
, mana
);
364 bool ChatHandler::HandleModifyEnergyCommand(const char* args
)
368 // char* pmana = strtok((char*)args, " ");
372 // char* pmanaMax = strtok(NULL, " ");
376 // int32 manam = atoi(pmanaMax);
377 // int32 mana = atoi(pmana);
378 int32 mana
= atoi((char*)args
)*10;
379 int32 manam
= atoi((char*)args
)*10;
381 if (mana
<= 0 || manam
<= 0 || manam
< mana
)
383 SendSysMessage(LANG_BAD_VALUE
);
387 Player
*chr
= getSelectedPlayer();
390 PSendSysMessage(LANG_NO_CHAR_SELECTED
);
394 PSendSysMessage(LANG_YOU_CHANGE_ENERGY
, mana
/10, manam
/10, chr
->GetName());
397 sprintf((char*)buf
,LANG_YOURS_ENERGY_CHANGED
, m_session
->GetPlayer()->GetName(), mana
/10, manam
/10);
398 FillSystemMessageData(&data
, m_session
, buf
);
400 chr
->GetSession()->SendPacket(&data
);
402 chr
->SetMaxPower(POWER_ENERGY
,manam
);
403 chr
->SetPower(POWER_ENERGY
, mana
);
405 sLog
.outDetail(LANG_CURRENT_ENERGY
,chr
->GetMaxPower(POWER_ENERGY
));
410 bool ChatHandler::HandleModifyRageCommand(const char* args
)
414 // char* pmana = strtok((char*)args, " ");
418 // char* pmanaMax = strtok(NULL, " ");
422 // int32 manam = atoi(pmanaMax);
423 // int32 mana = atoi(pmana);
424 int32 mana
= atoi((char*)args
)*10;
425 int32 manam
= atoi((char*)args
)*10;
427 if (mana
<= 0 || manam
<= 0 || manam
< mana
)
429 SendSysMessage(LANG_BAD_VALUE
);
433 Player
*chr
= getSelectedPlayer();
436 SendSysMessage(LANG_NO_CHAR_SELECTED
);
440 PSendSysMessage(LANG_YOU_CHANGE_RAGE
, mana
/10, manam
/10, chr
->GetName());
443 sprintf((char*)buf
,LANG_YOURS_RAGE_CHANGED
, m_session
->GetPlayer()->GetName(), mana
/10, manam
/10);
444 FillSystemMessageData(&data
, m_session
, buf
);
446 chr
->GetSession()->SendPacket(&data
);
448 chr
->SetMaxPower(POWER_RAGE
,manam
);
449 chr
->SetPower(POWER_RAGE
, mana
);
454 bool ChatHandler::HandleModifyFactionCommand(const char* args
)
462 char* pfactionid
= strtok((char*)args
, " ");
464 Unit
* chr
= getSelectedCreature();
467 SendSysMessage(LANG_SELECT_CREATURE
);
475 factionid
= chr
->getFaction();
476 flag
= chr
->GetUInt32Value(UNIT_FIELD_FLAGS
);
477 npcflag
= chr
->GetUInt32Value(UNIT_NPC_FLAGS
);
478 dyflag
= chr
->GetUInt32Value(UNIT_DYNAMIC_FLAGS
);
479 PSendSysMessage(LANG_CURRENT_FACTION
,chr
->GetGUIDLow(),factionid
,flag
,npcflag
,dyflag
);
486 SendSysMessage(LANG_NO_CHAR_SELECTED
);
490 factionid
= atoi(pfactionid
);
492 char* pflag
= strtok(NULL
, " ");
494 flag
= chr
->GetUInt32Value(UNIT_FIELD_FLAGS
);
498 char* pnpcflag
= strtok(NULL
, " ");
500 npcflag
= chr
->GetUInt32Value(UNIT_NPC_FLAGS
);
502 npcflag
= atoi(pnpcflag
);
504 char* pdyflag
= strtok(NULL
, " ");
506 dyflag
= chr
->GetUInt32Value(UNIT_DYNAMIC_FLAGS
);
508 dyflag
= atoi(pdyflag
);
510 if(!sFactionTemplateStore
.LookupEntry(factionid
))
512 PSendSysMessage(LANG_WRONG_FACTION
, factionid
);
516 PSendSysMessage(LANG_YOU_CHANGE_FACTION
, chr
->GetGUIDLow(),factionid
,flag
,npcflag
,dyflag
);
518 //sprintf((char*)buf,"%s changed your Faction to %i.", m_session->GetPlayer()->GetName(), factionid);
519 //FillSystemMessageData(&data, m_session, buf);
521 //chr->GetSession()->SendPacket(&data);
523 chr
->setFaction(factionid
);
524 chr
->SetUInt32Value(UNIT_FIELD_FLAGS
,flag
);
525 chr
->SetUInt32Value(UNIT_NPC_FLAGS
,npcflag
);
526 chr
->SetUInt32Value(UNIT_DYNAMIC_FLAGS
,dyflag
);
531 bool ChatHandler::HandleModifySpellCommand(const char* args
)
536 char* pspellflatid
= strtok((char*)args
, " ");
540 char* pop
= strtok(NULL
, " ");
544 char* pval
= strtok(NULL
, " ");
550 char* pmark
= strtok(NULL
, " ");
552 uint8 spellflatid
= atoi(pspellflatid
);
553 uint8 op
= atoi(pop
);
554 uint16 val
= atoi(pval
);
560 Player
*chr
= getSelectedPlayer();
563 SendSysMessage(LANG_NO_CHAR_SELECTED
);
567 PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID
, spellflatid
, val
, mark
, chr
->GetName());
570 sprintf((char*)buf
,LANG_YOURS_SPELLFLATID_CHANGED
, m_session
->GetPlayer()->GetName(), spellflatid
, val
, mark
);
571 FillSystemMessageData(&data
, m_session
, buf
);
573 chr
->GetSession()->SendPacket(&data
);
575 data
.Initialize(SMSG_SET_FLAT_SPELL_MODIFIER
);
576 data
<< uint8(spellflatid
);
579 data
<< uint16(mark
);
580 chr
->GetSession()->SendPacket(&data
);
585 bool ChatHandler::HandleModifyTalentCommand (const char* args
)
587 int tp
= atoi((char*)args
);
590 Player
* player
= m_session
->GetPlayer();
593 SendSysMessage(LANG_NO_CHAR_SELECTED
);
596 player
->SetUInt32Value(PLAYER_CHARACTER_POINTS1
, tp
);
602 bool ChatHandler::HandleTaxiCheatCommand(const char* args
)
609 int flag
= atoi((char*)args
);
611 Player
*chr
= getSelectedPlayer();
614 SendSysMessage(LANG_NO_CHAR_SELECTED
);
620 chr
->SetTaxiCheater(true);
621 PSendSysMessage(LANG_YOU_GIVE_TAXIS
, chr
->GetName());
623 if(chr
!= m_session
->GetPlayer())
627 sprintf((char*)buf
,LANG_YOURS_TAXIS_ADDED
, m_session
->GetPlayer()->GetName());
628 FillSystemMessageData(&data
, m_session
, buf
);
629 chr
->GetSession()->SendPacket(&data
);
634 chr
->SetTaxiCheater(false);
635 PSendSysMessage(LANG_YOU_REMOVE_TAXIS
, chr
->GetName());
637 if(chr
!= m_session
->GetPlayer())
641 sprintf((char*)buf
,LANG_YOURS_TAXIS_REMOVED
, m_session
->GetPlayer()->GetName());
642 FillSystemMessageData(&data
, m_session
, buf
);
643 chr
->GetSession()->SendPacket(&data
);
650 bool ChatHandler::HandleModifyASpeedCommand(const char* args
)
657 float ASpeed
= (float)atof((char*)args
);
659 if (ASpeed
> 50 || ASpeed
<= 0)
661 SendSysMessage(LANG_BAD_VALUE
);
665 Player
*chr
= getSelectedPlayer();
668 SendSysMessage(LANG_NO_CHAR_SELECTED
);
672 PSendSysMessage(LANG_YOU_CHANGE_ASPEED
, ASpeed
, chr
->GetName());
675 sprintf((char*)buf
,LANG_YOURS_ASPEED_CHANGED
, m_session
->GetPlayer()->GetName(), ASpeed
);
676 FillSystemMessageData(&data
, m_session
, buf
);
678 chr
->GetSession()->SendPacket(&data
);
680 data
.Initialize( SMSG_FORCE_RUN_SPEED_CHANGE
);
681 data
.append(chr
->GetPackGUID());
683 data
<< (float)ASpeed
;
684 chr
->SendMessageToSet( &data
, true );
686 data
.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE
);
687 data
.append(chr
->GetPackGUID());
689 data
<< (float)ASpeed
;
690 chr
->SendMessageToSet( &data
, true );
691 data
.Initialize( SMSG_FORCE_RUN_BACK_SPEED_CHANGE
);
692 data
.append(chr
->GetPackGUID());
694 data
<< (float)ASpeed
;
695 chr
->SendMessageToSet( &data
, true );
699 bool ChatHandler::HandleModifySpeedCommand(const char* args
)
706 float Speed
= (float)atof((char*)args
);
708 if (Speed
> 50 || Speed
<= 0)
710 SendSysMessage(LANG_BAD_VALUE
);
714 Player
*chr
= getSelectedPlayer();
717 SendSysMessage(LANG_NO_CHAR_SELECTED
);
721 PSendSysMessage(LANG_YOU_CHANGE_SPEED
, Speed
, chr
->GetName());
724 sprintf((char*)buf
,LANG_YOURS_SPEED_CHANGED
, m_session
->GetPlayer()->GetName(), Speed
);
725 FillSystemMessageData(&data
, m_session
, buf
);
727 chr
->GetSession()->SendPacket(&data
);
729 data
.Initialize( SMSG_FORCE_RUN_SPEED_CHANGE
);
730 data
.append(chr
->GetPackGUID());
732 data
<< (float)Speed
; //4
734 chr
->SendMessageToSet( &data
, true );
739 bool ChatHandler::HandleModifySwimCommand(const char* args
)
746 float Swim
= (float)atof((char*)args
);
748 if (Swim
> 50 || Swim
<= 0)
750 SendSysMessage(LANG_BAD_VALUE
);
754 Player
*chr
= getSelectedPlayer();
757 SendSysMessage(LANG_NO_CHAR_SELECTED
);
761 PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED
, Swim
, chr
->GetName());
764 sprintf((char*)buf
,LANG_YOURS_SWIM_SPEED_CHANGED
, m_session
->GetPlayer()->GetName(), Swim
);
765 FillSystemMessageData(&data
, m_session
, buf
);
767 chr
->GetSession()->SendPacket(&data
);
769 data
.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE
);
770 data
.append(chr
->GetPackGUID());
773 chr
->SendMessageToSet( &data
, true );
778 bool ChatHandler::HandleModifyBWalkCommand(const char* args
)
785 float BSpeed
= (float)atof((char*)args
);
787 if (BSpeed
> 50 || BSpeed
<= 0)
789 SendSysMessage(LANG_BAD_VALUE
);
793 Player
*chr
= getSelectedPlayer();
796 SendSysMessage(LANG_NO_CHAR_SELECTED
);
800 PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED
, BSpeed
, chr
->GetName());
803 sprintf((char*)buf
,LANG_YOURS_BACK_SPEED_CHANGED
, m_session
->GetPlayer()->GetName(), BSpeed
);
804 FillSystemMessageData(&data
, m_session
, buf
);
806 chr
->GetSession()->SendPacket(&data
);
808 data
.Initialize( SMSG_FORCE_RUN_BACK_SPEED_CHANGE
);
809 data
.append(chr
->GetPackGUID());
811 data
<< (float)BSpeed
;
812 chr
->SendMessageToSet( &data
, true );
817 bool ChatHandler::HandleModifyScaleCommand(const char* args
)
824 float Scale
= (float)atof((char*)args
);
825 if (Scale
> 3 || Scale
<= 0)
827 SendSysMessage(LANG_BAD_VALUE
);
831 Player
*chr
= getSelectedPlayer();
834 SendSysMessage(LANG_NO_CHAR_SELECTED
);
838 PSendSysMessage(LANG_YOU_CHANGE_SIZE
, Scale
, chr
->GetName());
841 sprintf((char*)buf
,LANG_YOURS_SIZE_CHANGED
, m_session
->GetPlayer()->GetName(), Scale
);
842 FillSystemMessageData(&data
, m_session
, buf
);
844 chr
->GetSession()->SendPacket(&data
);
846 chr
->SetFloatValue(OBJECT_FIELD_SCALE_X
, Scale
);
851 bool ChatHandler::HandleModifyMountCommand(const char* args
)
859 float speed
= (float)15;
862 num
= atoi((char*)args
);
1073 SendSysMessage(LANG_NO_MOUNT
);
1077 Player
*chr
= getSelectedPlayer();
1080 SendSysMessage(LANG_NO_CHAR_SELECTED
);
1084 PSendSysMessage(LANG_YOU_GIVE_MOUNT
, chr
->GetName());
1087 sprintf((char*)buf
,LANG_MOUNT_GIVED
, m_session
->GetPlayer()->GetName());
1088 FillSystemMessageData(&data
, m_session
, buf
);
1090 chr
->GetSession()->SendPacket(&data
);
1092 chr
->SetUInt32Value( UNIT_FIELD_FLAGS
, 0x001000 );
1095 data
.Initialize( SMSG_FORCE_RUN_SPEED_CHANGE
);
1096 data
.append(chr
->GetPackGUID());
1098 data
<< float(speed
);
1099 chr
->SendMessageToSet( &data
, true );
1101 data
.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE
);
1102 data
.append(chr
->GetPackGUID());
1104 data
<< float(speed
);
1105 chr
->SendMessageToSet( &data
, true );
1110 bool ChatHandler::HandleModifyMoneyCommand(const char* args
)
1117 Player
*chr
= getSelectedPlayer();
1120 SendSysMessage(LANG_NO_CHAR_SELECTED
);
1124 int32 addmoney
= atoi((char*)args
);
1126 uint32 moneyuser
= m_session
->GetPlayer()->GetMoney();
1130 int32 newmoney
= moneyuser
+ addmoney
;
1132 sLog
.outDetail(LANG_CURRENT_MONEY
, moneyuser
, addmoney
, newmoney
);
1136 PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY
, chr
->GetName());
1139 sprintf((char*)buf
,LANG_YOURS_ALL_MONEY_GONE
, m_session
->GetPlayer()->GetName());
1140 FillSystemMessageData(&data
, m_session
, buf
);
1141 chr
->GetSession()->SendPacket(&data
);
1148 PSendSysMessage(LANG_YOU_TAKE_MONEY
, abs(addmoney
), chr
->GetName());
1151 sprintf((char*)buf
,LANG_YOURS_MONEY_TAKEN
, m_session
->GetPlayer()->GetName(), abs(addmoney
));
1152 FillSystemMessageData(&data
, m_session
, buf
);
1153 chr
->GetSession()->SendPacket(&data
);
1155 chr
->SetMoney( newmoney
);
1161 PSendSysMessage(LANG_YOU_GIVE_MONEY
, addmoney
, chr
->GetName());
1164 sprintf((char*)buf
,LANG_YOURS_MONEY_GIVEN
, m_session
->GetPlayer()->GetName(), addmoney
);
1165 FillSystemMessageData(&data
, m_session
, buf
);
1166 chr
->GetSession()->SendPacket(&data
);
1168 chr
->ModifyMoney( addmoney
);
1171 sLog
.outDetail(LANG_NEW_MONEY
, moneyuser
, addmoney
, chr
->GetMoney() );
1176 bool ChatHandler::HandleModifyBitCommand(const char* args
)
1178 Player
*chr
= getSelectedPlayer();
1181 SendSysMessage(LANG_NO_CHAR_SELECTED
);
1185 char* pField
= strtok((char*)args
, " ");
1189 char* pBit
= strtok(NULL
, " ");
1193 uint16 field
= atoi(pField
);
1194 uint32 bit
= atoi(pBit
);
1196 if (field
< 1 || field
>= PLAYER_END
)
1198 SendSysMessage(LANG_BAD_VALUE
);
1202 if (bit
< 1 || bit
> 32)
1204 SendSysMessage(LANG_BAD_VALUE
);
1208 if ( chr
->HasFlag( field
, (1<<(bit
-1)) ) )
1210 chr
->RemoveFlag( field
, (1<<(bit
-1)) );
1211 PSendSysMessage(LANG_REMOVE_BIT
, bit
, field
);
1215 chr
->SetFlag( field
, (1<<(bit
-1)) );
1216 PSendSysMessage(LANG_SET_BIT
, bit
, field
);
1222 bool ChatHandler::HandleTeleCommand(const char * args
)
1224 if(m_session
->GetPlayer()->isInFlight())
1226 SendSysMessage(LANG_YOU_IN_FLIGHT
);
1230 QueryResult
*result
;
1233 result
= sDatabase
.Query("SELECT `name` FROM `game_tele`");
1236 SendSysMessage("Teleport location table is empty!");
1239 std::string reply
="Valid locations are:";
1240 for (uint64 i
=0; i
< result
->GetRowCount(); i
++)
1242 Field
*fields
= result
->Fetch();
1244 reply
+= fields
[0].GetCppString();
1247 SendSysMessage(reply
.c_str());
1251 std::string name
= args
;
1252 sDatabase
.escape_string(name
);
1253 result
= sDatabase
.PQuery("SELECT `position_x`,`position_y`,`position_z`,`orientation`,`map` FROM `game_tele` WHERE `name` = '%s'",name
.c_str());
1256 SendSysMessage("Teleport location not found!");
1259 Field
*fields
= result
->Fetch();
1260 float x
= fields
[0].GetFloat();
1261 float y
= fields
[1].GetFloat();
1262 float z
= fields
[2].GetFloat();
1263 float ort
= fields
[3].GetFloat();
1264 int mapid
= fields
[4].GetUInt16();
1267 if(!MapManager::ExistMAP(mapid
,x
,y
))
1269 PSendSysMessage(".tele target map not exist (X: %f Y: %f MapId:%u)",x
,y
,mapid
);
1273 m_session
->GetPlayer()->TeleportTo(mapid
, x
, y
, z
, ort
);
1277 bool ChatHandler::HandleSearchTeleCommand(const char * args
)
1279 QueryResult
*result
;
1282 SendSysMessage("Requires search parameter.");
1285 char const* str
= strtok((char*)args
, " ");
1289 std::string namepart
= str
;
1290 sDatabase
.escape_string(namepart
);
1291 result
= sDatabase
.PQuery("SELECT `name` FROM `game_tele` WHERE `name` LIKE '%%%s%%'",namepart
.c_str());
1294 SendSysMessage("There are no teleport locations matching your request.");
1298 for (uint64 i
=0; i
< result
->GetRowCount(); i
++)
1300 Field
*fields
= result
->Fetch();
1302 reply
+= fields
[0].GetCppString();
1309 SendSysMessage("None locations found.");
1312 reply
= "Locations found are:\n" + reply
;
1313 SendSysMultilineMessage(reply
.c_str());
1318 bool ChatHandler::HandleWhispersCommand(const char* args
)
1320 char* px
= strtok((char*)args
, " ");
1325 PSendSysMessage("Whispers accepting: %s", m_session
->GetPlayer()->isAcceptWhispers() ? "on" : "off");
1330 if(strncmp(px
,"on",3) == 0)
1332 m_session
->GetPlayer()->SetAcceptWhispers(true);
1333 SendSysMessage("Whispers accepting: on");
1338 if(strncmp(px
,"off",4) == 0)
1340 m_session
->GetPlayer()->SetAcceptWhispers(false);
1341 SendSysMessage("Whispers accepting: off");
1348 bool ChatHandler::HandlePlaySoundCommand(const char* args
)
1350 // USAGE: .playsound #soundid
1351 // #soundid - ID decimal number from SoundEntries.dbc (1 column)
1352 // this file have about 5000 sounds.
1353 // In this realisation only caller can hear this sound.
1356 int dwSoundId
= atoi((char*)args
);
1357 if( dwSoundId
>= 0 )
1360 data
.Initialize(SMSG_PLAY_OBJECT_SOUND
);
1361 data
<< uint32(dwSoundId
) << m_session
->GetPlayer()->GetGUID();
1362 m_session
->SendPacket(&data
);
1364 sLog
.outDebug("Player %s use command .playsound with #soundid=%u", m_session
->GetPlayer()->GetName(), dwSoundId
);
1365 PSendSysMessage(LANG_YOU_HEAR_SOUND
, dwSoundId
);
1370 SendSysMessage(LANG_BAD_VALUE
);
1374 bool ChatHandler::HandleSaveAllCommand(const char* args
)
1376 ObjectAccessor::Instance().SaveAllPlayers();
1377 SendSysMessage(LANG_PLAYERS_SAVED
);