Jump to content

[patch] Kick Broadcast


Guest Sora23
 Share

Recommended Posts

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'

Link to comment
Share on other sites

  • 1 year later...

Can someone finish cleaning this please? Not too savvy with it. I think the Language.h part is good, just need level2.cpp fixed. Mangos rev. 9849.

Index: src/game/Language.h
===================================================================
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -24,6 +24,16 @@ enum MangosStrings
   // for chat commands
   LANG_SELECT_CHAR_OR_CREATURE        = 1,
   LANG_SELECT_CREATURE                = 2,
+    LANG_ANNOUNCE_KICK                  = 70,               //Selected Player Kick
+    LANG_ANNOUNCE_KICK1                 = 71,               //.kick Command

   // level 0 chat
   LANG_SYSTEMMESSAGE                  = 3,
   LANG_EVENTMESSAGE                   = 4,
Index: src/game/Level2.cpp
===================================================================
--- src/game/Level2.cpp
+++ src/game/Level2.cpp
@@ -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());

Link to comment
Share on other sites

Wow. Talk about digging up bones!

Still there are many such interesting or useful patches that have been allowed to rot in the dustbin of time. Glad to see someone is trying to update at least one. Let's hope it becomes a trend. :)

Maybe a useful new feature for this patch would be to bestow a title upon the kicked or banned player's characters, such as "The Scoundrel" or "The Booted Hind", which they must bear until such time it is judged they have proven themselves worthy of having the label lifted by a GM.

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use