I got bored last nite and decided to code this
i did test it and it worked and i havent experienced any crashes with the code
not asking for it to be in SVN but if its useful then go ahead.
What the code does is pretty simple. It just announces who is being kicked and
who is doing the kicking and why they are getting kicked.
***Updated for 6523***
Fixed SQL Errors
And Command Bugs
**Updated for 6529***
Updated command table
Fix C++ Bugs
C++ Code:
Index: src/game/Language.h
===================================================================
--- src/game/Language.h (revision 6529)
+++ src/game/Language.h (working copy)
@@ -24,6 +24,16 @@
// for chat commands
LANG_SELECT_CHAR_OR_CREATURE = 1,
LANG_SELECT_CREATURE = 2,
+ LANG_ANNOUNCE_KICK = 1000, //Seleceted Player Kick
+ LANG_ANNOUNCE_KICK1 = 1001, //.kick Command
// level 0 chat
LANG_SYSTEMMESSAGE = 3,
Index: src/game/Level2.cpp
===================================================================
--- src/game/Level2.cpp (revision 6529)
+++ src/game/Level2.cpp (working copy)
@@ -1712,6 +1712,10 @@
bool ChatHandler::HandleKickPlayerCommand(const char *args)
{
char* kickName = strtok((char*)args, " ");
+ char* reason = strtok(NULL,"");
+ if(!reason)
+ return false;
+ char str[1024];
if (!kickName)
{
Player* player = getSelectedPlayer();
@@ -1722,15 +1726,15 @@
SetSentErrorMessage(true);
return false;
}
-
if(player==m_session->GetPlayer())
{
SendSysMessage(LANG_COMMAND_KICKSELF);
SetSentErrorMessage(true);
return false;
}
-
player->GetSession()->KickPlayer();
+ sprintf(str, GetMangosString(LANG_ANNOUNCE_KICK), player->GetName(), m_session->GetPlayer()->GetName());
+ sWorld.SendWorldText(str, NULL);
}
else
{
@@ -1748,10 +1752,11 @@
SetSentErrorMessage(true);
return false;
}
-
if(sWorld.KickPlayer(name))
{
PSendSysMessage(LANG_COMMAND_KICKMESSAGE,name.c_str());
+ sprintf(str, GetMangosString(LANG_ANNOUNCE_KICK1), name.c_str(), m_session->GetPlayer()->GetName(), reason);
+ sWorld.SendWorldText(str, NULL);
}
else
PSendSysMessage(LANG_COMMAND_KICKNOTFOUNDPLAYER,name.c_str());
SQL Code:
INSERT INTO mangos_string (entry, content_default, content_loc1, content_loc2, content_loc3, content_loc4, content_loc5, content_loc6, content_loc7) VALUES
(1001, '|cFF00FF00[server]|cFF00FF00|r|cffff0000 %s has been kicked from the server by %s.|cffff0000|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(1002, '|cFF00FF00[server]|cFF00FF00|r|cffff0000 %s has been kicked from the server by %s Reason: %s|cffff0000|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
Update `Command` Table
UPDATE command SET `help`='Syntax: .kick [$charactername] [$reason]
Kick the given character name from the world. If no character name is provided then the selected player (except for yourself) will be kicked.' WHERE name='kick'