建立一个数据库
/* MySQL Data Transfer Source Host: localhost Source Database: wowkk_db Target Host: localhost Target Database: wowkk_db Date: 2007-8-23 16:04:31 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for gonggao -- ---------------------------- CREATE TA*LE `gonggao` ( `guid` bigint(20) NOT NULL auto_increment, `text` varchar(200) NOT NULL, `color` varbinary(10) NOT NULL, PRIMARY KEY (`guid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Player System'; -- ---------------------------- -- Records -- ---------------------------- INSERT INTO `gonggao` VALUES ('1', '内容。。。。。。。。。。。。。。', '|cFFFF3366'); INSERT INTO `gonggao` VALUES ('2', '内容。。。。。。。。。。。。。。。', '|cFF00FFFF'); INSERT INTO `gonggao` VALUES ('3', '内容。。。。。。。。。。。。。。', '|cFF00FFFF');
然后增加代码
Index: Player.cpp =================================================================== --- Player.cpp (revision 1203) +++ Player.cpp (working copy) @@ -89,6 +89,21 @@
m_nextSave = getMSTime() + sWorld.getIntRate(INTRATE_SAVE);
+ gonggaotiem = sWorld.getIntRate(CONFIG_INTRATE_GONGGAO); + GongGaoID = 0; + m_currentSpell = NULL; m_resurrectHealth = m_resurrectMana = 0;
@@ -822,6 +905,169 @@ else m_pvpTimer -= p_time; } + + if(gonggaotiem) + { + if(p_time >= gonggaotiem) + { + gonggaotiem = sWorld.getIntRate(CONFIG_INTRATE_GONGGAO); + if(!GongGaoID) + GongGaoID = 1; + + GongGao * GongGaoInfo = GongGaoInfoStorage.LookupEntry(GongGaoID); + if(!GongGaoInfo) + GongGaoID = 1; + + if(GongGaoInfo) + { + sChatHandler.ColorSystemMessage(GetSession(),GongGaoInfo->color,GongGaoInfo->text); + GongGaoID += 1; + return; + } + } + else + gonggaotiem -= p_time; + }
Index: Player.h =================================================================== --- Player.h (revision 1203) +++ Player.h (working copy) @@ -289,6 +289,14 @@ return HATED; } }; +struct GongGao +{ + uint32 guid; + char * text; + char * color; +}; + + uint32 GongGaoID; + uint32 gonggaotiem; + uint32 m_nextGongGao;
Index: World.cpp =================================================================== --- World.cpp (revision 1203) +++ World.cpp (working copy) @@ -2026,9 +2024,64 @@ SpeedhackProtection = Config.MainConfig.Get*oolDefault("Server", "SpeedhackProtection", false); SendStatsOnJoin = Config.MainConfig.Get*oolDefault("Server", "SendStatsOnJoin", true); compression_threshold = Config.MainConfig.GetIntDefault("Server", "CompressionThreshold", 1000); LevelCap = Config.MainConfig.GetIntDefault("Server", "LevelCap", 60); Expansion1LevelCap = Config.MainConfig.GetIntDefault("Server", "Expansion1LevelCap", 70);
+ setIntRate(CONFIG_INTRATE_GONGGAO, Config.MainConfig.GetIntDefault("Server","GongGaoTime", 240000));
Index: World.h =================================================================== --- World.h (revision 1203) +++ World.h (working copy) @@ -60,6 +60,18 @@ enum IntRates { INTRATE_SAVE=0, + CONFIG_INTRATE_AUTO_F*ZY_GONGGAO,
Index: ObjectStorage.cpp =================================================================== --- ObjectStorage.cpp (revision 1203) +++ ObjectStorage.cpp (working copy) @@ -19,7 +19,7 @@
/** Table formats converted to strings */ const char * gCreatureNameFormat = "ussuuuuuuuffcc"; const char * gGameObjectNameFormat = "uuusuuuuuuuuuuuuuuuuuuuuuuuu"; const char * gCreatureProtoFormat = "uuuuuuufuuffuffuuuuuuuuuuuuuuuuuuffsuuuu"; @@ -35,6 +35,11 @@ +const char * gGongGaoInfoFormat = "uss";
/** SQLStorage symbols */ SERVER_DECL SQLStorage<ItemPrototype, ArrayStorageContainer<ItemPrototype> > ItemPrototypeStorage; @@ -52,6 +57,11 @@ SERVER_DECL SQLStorage<MapInfo, HashMapStorageContainer<MapInfo> > WorldMapInfoStorage; SERVER_DECL SQLStorage<ZoneGuardEntry, HashMapStorageContainer<ZoneGuardEntry> > ZoneGuardStorage; LanguageInfoStorage; +SERVER_DECL SQLStorage<GongGao, HashMapStorageContainer<GongGao> > GongGaoInfoStorage;
@@ -263,6 +273,12 @@ make_task(NpcTextStorage, GossipText, HashMapStorageContainer, "npc_text", gNpcTextFormat); make_task(WorldMapInfoStorage, MapInfo, HashMapStorageContainer, "worldmap_info", gWorldMapInfoFormat); make_task(ZoneGuardStorage, ZoneGuardEntry, HashMapStorageContainer, "zoneguards", gZoneGuardsFormat);
+ make_task(GongGaoInfoStorage, GongGao, HashMapStorageContainer, "gonggao", gGongGaoInfoFormat);
@@ -296,6 +312,11 @@ NpcTextStorage.Cleanup(); WorldMapInfoStorage.Cleanup(); ZoneGuardStorage.Cleanup(); + + GongGaoInfoStorage.Cleanup();
Index: ObjectStorage.h =================================================================== --- ObjectStorage.h (revision 1203) +++ ObjectStorage.h (working copy) @@ -33,6 +33,11 @@ extern SERVER_DECL SQLStorage<MapInfo, HashMapStorageContainer<MapInfo> > WorldMapInfoStorage; extern SERVER_DECL SQLStorage<ZoneGuardEntry, HashMapStorageContainer<ZoneGuardEntry> > ZoneGuardStorage;
+extern SERVER_DECL SQLStorage<GongGao, HashMapStorageContainer<GongGao> > GongGaoInfoStorage;
上面的是以前写的,看大家找得很辛苦,所以共享给大家,可能有遗漏的地方,大家借鉴一下
setIntRate(CONFIG_INTRATE_GONGGAO, Config.MainConfig.GetIntDefault("Server","GongGaoTime", 240000));
这条大家应该知道什么意思吧,就是可以在ascent.conf 里面的 Server 字头文件里面加入 GongGaoTime = "240000" 设置一下间隔时间,默认为 4分钟 |