吾爱尚玩资源基地

标题: 会员说话系统-参考代码 [打印本页]

作者: admin    时间: 2016-4-18 22:50
标题: 会员说话系统-参考代码
服务端的会员说话系统-参考代码(貌似是比较老的代码了)


diff --git a/addition/[104] mangos_name_announce.sql b/addition/[104] mangos_name_announce.sqlnew file mode 100644
index 0000000..3b350af
--- /dev/null
+++ b/addition/[104] mangos_name_announce.sql       
@@ -0,0 +1,2 @@
+INSERT INTO `command` VALUES ('nameannounce',1,'Syntax: .nameannounce $MessageToBroadcast Send a global message to all players online in chat log with colored sender\'s name.');
+INSERT INTO `mangos_string` VALUES (60,'|c1f40af20 <Mod>|cffff0000[%s]|c1f40af20 announce:|cffffff00 %s|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (61,'|c1f40af20 <GM>|cffff0000[%s]|c1f40af20 announce:|cffffff00 %s|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (62,'|c1f40af20 <Admin>|cffff0000[%s]|c1f40af20 announce:|cffffff00 %s|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index 891d96b..03d484f 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -598,6 +598,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "aura",           SEC_ADMINISTRATOR,  false, &ChatHandler::HandleAuraCommand,                "", NULL },
         { "unaura",         SEC_ADMINISTRATOR,  false, &ChatHandler::HandleUnAuraCommand,              "", NULL },
         { "announce",       SEC_MODERATOR,      true,  &ChatHandler::HandleAnnounceCommand,            "", NULL },
+        { "nameannounce",   SEC_MODERATOR,      false, &ChatHandler::HandleNameAnnounceCommand,        "", NULL },
         { "notify",         SEC_MODERATOR,      true,  &ChatHandler::HandleNotifyCommand,              "", NULL },
         { "goname",         SEC_MODERATOR,      false, &ChatHandler::HandleGonameCommand,              "", NULL },
         { "namego",         SEC_MODERATOR,      false, &ChatHandler::HandleNamegoCommand,              "", NULL },
diff --git a/src/game/Chat.h b/src/game/Chat.h
index 9c3ff0a..573f47e 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -441,6 +441,7 @@ class ChatHandler
         bool HandleGroupgoCommand(const char* args);
         bool HandleRecallCommand(const char* args);
         bool HandleAnnounceCommand(const char* args);
+        bool HandleNameAnnounceCommand(const char* args);
         bool HandleNotifyCommand(const char* args);
         bool HandleGPSCommand(const char* args);
         bool HandleTaxiCheatCommand(const char* args);
diff --git a/src/game/Language.h b/src/game/Language.h
index a7eaa08..888f4aa 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -84,6 +84,9 @@ enum MangosStrings
     LANG_USING_SCRIPT_LIB               = 58,
     LANG_USING_EVENT_AI                 = 59,
     // Room for more level 0              60-99 not used
+    LANG_SYSTEMMESSAGE_MODERATOR        = 60,
+    LANG_SYSTEMMESSAGE_GAMEMASTER       = 61,
+    LANG_SYSTEMMESSAGE_ADMINISTRATOR    = 62,

     // level 1 chat
     LANG_GLOBAL_NOTIFY                  = 100,
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index 61a998e..0cb3fc0 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -132,6 +132,34 @@ bool ChatHandler::HandleAnnounceCommand(const char* args)
     return true;
}

+// Nameannounce
+bool ChatHandler::HandleNameAnnounceCommand(const char* args)
+{
+    int32 strid = 0;
+
+    if(!*args)
+        return false;
+
+    switch(m_session->GetSecurity())
+    {
+      case SEC_MODERATOR:
+        strid = LANG_SYSTEMMESSAGE_MODERATOR;
+        break;
+      case SEC_GAMEMASTER:
+        strid = LANG_SYSTEMMESSAGE_GAMEMASTER;
+        break;
+      case SEC_ADMINISTRATOR:
+        strid = LANG_SYSTEMMESSAGE_ADMINISTRATOR;
+        break;
+      default:
+        return false;
+    }
+
+    sWorld.SendWorldText(strid, m_session->GetPlayerName(), args);
+
+    return true;
+}
+
//notification player at the screen
bool ChatHandler::HandleNotifyCommand(const char* args)
{


作者: 你懂的    时间: 2016-11-7 03:37
感谢楼主分享,祝愿吾爱尚玩越来越好!




欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/) Powered by Discuz! X3.4