Jump to content

[Question] Announce Kick


Recommended Posts

Simple mode

diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index 2da8326..0d6bb37 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -5383,9 +5383,15 @@ bool ChatHandler::HandleBanHelper(BanMode mode, const char* args)
    {
        case BAN_SUCCESS:
            if(atoi(duration)>0)
+            {
                PSendSysMessage(LANG_BAN_YOUBANNED,nameOrIP.c_str(),secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason);
+                sWorld.SendWorldText(408,nameOrIP.c_str(),secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason);
+            }
            else
+            {
                PSendSysMessage(LANG_BAN_YOUPERMBANNED,nameOrIP.c_str(),reason);
+                sWorld.SendWorldText(409,nameOrIP.c_str(),reason);
+            }
            break;
        case BAN_SYNTAX_ERROR:
            return false;

Color mode + two channels for that

http://getmangos.eu/community/viewtopic.php?id=7953&highlight=ban+announce

Link to comment
Share on other sites

  • 39 years later...

Here is a patch from Darky88 which allows you to send an announce to the server if you kick someone with the GM's name and a reason

Language.h :

-// Room for more level 2              348-399 not used
+    LANG_KICK_WORLD_ANNOUNCE                = 348,
+// Room for more level 2  

Level2.cpp :

#include <fstream>
#include <map>
#include "GlobalEvents.h"
+#include "WorldPacket.h"
+#include "WorldSession.h"
+#include "PlayerDump.h"
+#include "Log.h"
+#include "Guild.h"
+#include "ScriptCalls.h"
+#include "GridNotifiersImpl.h"
+#include "CellImpl.h"
+#include "Weather.h"
+#include "PointMovementGenerator.h"
+#include "SkillDiscovery.h"
+#include "SkillExtraItems.h"
+#include "SystemConfig.h"
+#include "Config/ConfigEnv.h"
+#include "ItemEnchantmentMgr.h"
+#include "BattleGroundMgr.h"
+#include "InstanceSaveMgr.h"
+#include "InstanceData.h"
+#include "CreatureEventAIMgr.h" 

Level2.cpp

//kick player
bool ChatHandler::HandleKickPlayerCommand(const char *args)
{
+    if (!*args)
+        return false;
+
+    char* cnameOrIP = strtok ((char*)args, " ");
+    if (!cnameOrIP)
+        return false;
+
+    std::string nameOrIP = cnameOrIP;
+
+    char* reason = strtok (NULL,"");
+    if(!reason)
+        return false;
+
   Player* target;
   if(!extractPlayerTarget((char*)args,&target))
       return false;

   if (m_session && target==m_session->GetPlayer())
   {
       SendSysMessage(LANG_COMMAND_KICKSELF);
       SetSentErrorMessage(true);
       return false;
   }

   // check online security
   if (HasLowerSecurity(target, 0))
       return false;

   // send before target pointer invalidate
   PSendSysMessage(LANG_COMMAND_KICKMESSAGE,GetNameLink(target).c_str());
+   sWorld.SendWorldText(LANG_KICK_WORLD_ANNOUNCE,nameOrIP.c_str(),m_session ? m_session->GetPlayerName() : "CONSOLE",reason);
   target->GetSession()->KickPlayer();
   return true;
}  

SQL Code :

DELETE FROM `mangos_string` WHERE `entry`='348';
INSERT INTO `mangos_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) values('348','|cffffffff%s |cffffffffwas kicked by %s. (%s)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); 

Ingame command :

.kick PLAYERNAME REASON 

Link to comment
Share on other sites

Add

sWorld.SendWorldText(LANG_COMMAND_ANNOUNCEKICK,GetNameLink(target).c_str());

instead of your method

                              sWorld.SendWorldText(LANG_COMMAND_ANNOUNCEKICK,arg  s);                      

SQL:

INSERT INTO `mangos_string` (`entry`,`content_default`) VALUES
('283','Player %s kicked from the Server.');

I hope it works, i didn't test it!

Link to comment
Share on other sites

Awesome that worked, thank you =).

So if i want to add now the one who kicked the player and a reason then it should be like

sWorld.SendWorldText(LANG_COMMAND_ANNOUNCEKICK,nameOrIP.c_str(),GetNameLink(target).c_str(),reason);

right?:mellow:

EDIT: I compiled it with this and I got 2 errors, nameOrIP.c_str & reason are not defined :S. Any ideas?=)

Link to comment
Share on other sites

Simpre mode yello msg (i dont test it)

Level2.cpp

//kick player
bool ChatHandler::HandleKickPlayerCommand(const char *args)
{
   Player* target;
   if(!extractPlayerTarget((char*)args,&target))
       return false;

   if (m_session && target==m_session->GetPlayer())
   {
       SendSysMessage(LANG_COMMAND_KICKSELF);
       SetSentErrorMessage(true);
       return false;
   }

   // check online security
   if (HasLowerSecurity(target, 0))
       return false;

   // send before target pointer invalidate
   PSendSysMessage(LANG_COMMAND_KICKMESSAGE,GetNameLink(target).c_str());
+   sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE,GetNameLink(target).c_str());
   target->GetSession()->KickPlayer();
   return true;
}

Link to comment
Share on other sites

That's same code as xirror123's, i need

+ sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE,GetNameLink(target).c_str());

with target name & the my name so like

%s was kicked by %s.

in the ban helper

,nameOrIP.c_str()

was used i think but thats not defined in level2.cpp :S, someone knows how to do that? :confused:

EDIT: Is there maybe ' GetNameLink(target) ' with (me) instead of (target) ?

Link to comment
Share on other sites

Language.h

-// Room for more level 2              348-399 not used
+    LANG_KICK_WORLD_ANNOUNCE                = 348,
+// Room for more level 2              349-399 not used

Level2.cpp

//kick player
bool ChatHandler::HandleKickPlayerCommand(const char *args)
{
   Player* target;
   if(!extractPlayerTarget((char*)args,&target))
       return false;

   if (m_session && target==m_session->GetPlayer())
   {
       SendSysMessage(LANG_COMMAND_KICKSELF);
       SetSentErrorMessage(true);
       return false;
   }

   // check online security
   if (HasLowerSecurity(target, 0))
       return false;

   // send before target pointer invalidate
   PSendSysMessage(LANG_COMMAND_KICKMESSAGE,GetNameLink(target).c_str());
+   sWorld.SendWorldText(LANG_KICK_WORLD_ANNOUNCE,nameOrIP.c_str(),m_session ? m_session->GetPlayerName() : "CONSOLE",reason);                        );
   target->GetSession()->KickPlayer();
   return true;
}  

mangos_string.sql

delete from `mangos_string` where `entry`='348';
insert into `mangos_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) values('348','|cffff0000[GM]:|r %s was kiked by %s. Reason: %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);

U like that?? (NOT TESTED)

Link to comment
Share on other sites

I get

..\\..\\src\\game\\Level2.cpp(2082) : error C2065: 'nameOrIP': not declared.
..\\..\\src\\game\\Level2.cpp(2082) : error C2228: Links von ".c_str" must be with a race / class / union.
       Typ ist ''unknown-type''
..\\..\\src\\game\\Level2.cpp(2082) : error C2065: 'reason': not declared.
..\\..\\src\\game\\Level2.cpp(2082) : error C2059: Syntaxerror: ')'

compile error with your code. Anyways thanks for the help :)

Link to comment
Share on other sites

Level2.cpp

Can u add that and try compile and paste the result?

#include <fstream>
#include <map>
#include "GlobalEvents.h"
+#include "WorldPacket.h"
+#include "WorldSession.h"
+#include "PlayerDump.h"
+#include "Log.h"
+#include "Guild.h"
+#include "ScriptCalls.h"
+#include "GridNotifiersImpl.h"
+#include "CellImpl.h"
+#include "Weather.h"
+#include "PointMovementGenerator.h"
+#include "SkillDiscovery.h"
+#include "SkillExtraItems.h"
+#include "SystemConfig.h"
+#include "Config/ConfigEnv.h"
+#include "ItemEnchantmentMgr.h"
+#include "BattleGroundMgr.h"
+#include "InstanceSaveMgr.h"
+#include "InstanceData.h"
+#include "CreatureEventAIMgr.h"

I am searching for the library that contains

Link to comment
Share on other sites

language.h

-// Room for more level 2              348-399 not used
+    LANG_KICK_WORLD_ANNOUNCE                = 348,
+// Room for more level 2              349-399 not used  

Level2.cpp

#include <fstream>
#include <map>
#include "GlobalEvents.h"
+#include "WorldPacket.h"
+#include "WorldSession.h"
+#include "PlayerDump.h"
+#include "Log.h"
+#include "Guild.h"
+#include "ScriptCalls.h"
+#include "GridNotifiersImpl.h"
+#include "CellImpl.h"
+#include "Weather.h"
+#include "PointMovementGenerator.h"
+#include "SkillDiscovery.h"
+#include "SkillExtraItems.h"
+#include "SystemConfig.h"
+#include "Config/ConfigEnv.h"
+#include "ItemEnchantmentMgr.h"
+#include "BattleGroundMgr.h"
+#include "InstanceSaveMgr.h"
+#include "InstanceData.h"
+#include "CreatureEventAIMgr.h"

Level2.cpp

//kick player
bool ChatHandler::HandleKickPlayerCommand(const char *args)
{
+    if (!*args)
+        return false;
+
+    char* cnameOrIP = strtok ((char*)args, " ");
+    if (!cnameOrIP)
+        return false;
+
+    std::string nameOrIP = cnameOrIP;
+
+    char* reason = strtok (NULL,"");
+    if(!reason)
+        return false;
+
   Player* target;
   if(!extractPlayerTarget((char*)args,&target))
       return false;

   if (m_session && target==m_session->GetPlayer())
   {
       SendSysMessage(LANG_COMMAND_KICKSELF);
       SetSentErrorMessage(true);
       return false;
   }

   // check online security
   if (HasLowerSecurity(target, 0))
       return false;

   // send before target pointer invalidate
   PSendSysMessage(LANG_COMMAND_KICKMESSAGE,GetNameLink(target).c_str());
+   sWorld.SendWorldText(LANG_KICK_WORLD_ANNOUNCE,nameOrIP.c_str(),m_session ? m_session->GetPlayerName() : "CONSOLE",reason);                        );
   target->GetSession()->KickPlayer();
   return true;
}  

mangos_string.sql

+delete from `mangos_string` where `entry`='348';
+insert into `mangos_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) values('348','|cffff0000[GM]:|r %s was kiked by %s. Reason: %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);  

Try that

Link to comment
Share on other sites

This code works gonna test it now ingame by the way I had to remove the last ");" on the

+   sWorld.SendWorldText(LANG_KICK_WORLD_ANNOUNCE,nameOrIP.c_str(),m_session ? m_session->GetPlayerName() : "CONSOLE",reason);                        [b]);[/b]

Thanks very much!

EDIT: Works awesome! Thank you very much for your patience and helping me!

Link to comment
Share on other sites

OH ^^ !!

Fuck copy + paste :D !!

Put the code for others peoples (sorry for my english xD)

Now I have a desire to learn, I'll throw a question and I also try to resolve it, but if someone wants to help me.

Create a table in the database where I save, User, kingdom, the time and IP

sso1 do you want to compile the projects and tell me the result? :?

^^ thx

Att Darky

Link to comment
Share on other sites

GREAT!!

Can u compile that?

mangos / src / realmd / AuthSocket.cpp

   ///- Check if SRP6 results match (password is correct), else send an error
   if (!memcmp(M.AsByteArray(), lp.M1, 20))
   {
       sLog.outBasic("User '%s' successfully authenticated", _login.c_str());

       ///- Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
       // No SQL injection (escaped user name) and IP address as received by socket
       const char* K_hex = K.AsHexStr();
       loginDatabase.PExecute("UPDATE account SET sessionkey = '%s', last_ip = '%s', last_login = NOW(), locale = '%u', failed_logins = 0 WHERE username = '%s'", K_hex, GetRemoteAddress().c_str(), GetLocaleByName(_localizationName), _safelogin.c_str() );
+       loginDatabase.PExecute("INSERT INTO log_loggins VALUES
('%s',UNIX_TIMESTAMP(),'%s', '1')",_safelogin.c_str(),GetRemoteAddress().c_str());

       OPENSSL_free((void*)K_hex);

       ///- Finish SRP6 and send the final result to the client
       sha.Initialize();
       sha.UpdateBigNumbers(&A, &M, &K, NULL);
       sha.Finalize();

...

       uint32 MaxWrongPassCount = sConfig.GetIntDefault("WrongPass.MaxCount", 0);
       if(MaxWrongPassCount > 0)
       {
           //Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP
           loginDatabase.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'",_safelogin.c_str());
+         

           if(QueryResult *loginfail = loginDatabase.PQuery("SELECT id, failed_logins FROM account WHERE username = '%s'", _safelogin.c_str()))
           {
               Field* fields = loginfail->Fetch();
               uint32 failed_logins = fields[1].GetUInt32();
+              loginDatabase.PExecute("INSERT INTO log_loggins VALUES
('%s',UNIX_TIMESTAMP(),'%s', '0')",_safelogin.c_str(),GetRemoteAddress().c_str());
               if( failed_logins >= MaxWrongPassCount )

And you need that table in Realm database

DROP TABLE IF EXISTS LOG_LOGGINS;
CREATE TABLE LOG_LOGGINS (
   username VARCHAR(32) DEFAULT 'TESTING',
   login_time TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
   ip VARCHAR(30) NOT NULL DEFAULT '1.1.1.1',
   loggin VARCHAR(1) NOT NULL DEFAULT '0',
   PRIMARY KEY  (username,login_time)
);

You test, fist that compile, and goob/bad loggins are loged in db^^

Thx sso1!!

Link to comment
Share on other sites

It compiles and I also dont get a error on starting it up, but what is it supposed to do?^_^ I done a few things but the table in the realmd db is empty

EDIT:

Aww yes a error

SQL : INSERT INTO log_loggings VALUES

('SSO' ,UNIX_TIMESTAMP(), '127.0.0.1', '1')

SQL ERROR: Incoorect datetime value: '1244571469' for column 'login_time' at row 1

Link to comment
Share on other sites

The error was in the table ¬¬ : )

DROP TABLE IF EXISTS LOG_LOGGINS;
CREATE TABLE LOG_LOGGINS (
   username VARCHAR(32) DEFAULT 'TESTING',
   login_time BIGINT(40) NOT NULL,
   ip VARCHAR(30) NOT NULL DEFAULT '1.1.1.1',
   loggin VARCHAR(1) NOT NULL DEFAULT '0',
   PRIMARY KEY  (username,login_time)
);  

The chart record

-account names

-dates

-ip

-Connect or wrong pass provided

You can take a statistical study of which is trying to be attacked, but really are just testing to learn and make a bigger proyect

^^ THX YOU!!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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