点击联系天涯红月客服!
工作时间: 9:00 - 22:00
客服电话:18953313678
客服QQ:5227433
VIP玩家群: 379155573
红月QQ群: 379155573


抵制不良游戏 拒绝盗版游戏
注意自我保护 谨防受骗上当
适度游戏益脑 沉迷游戏伤身
合理安排时间 享受健康生活
天涯红月无论在新开红月,还是老牌红月中均占有一席之地!天涯红月采用双线专业服务器,在这里让您游戏更有保证!游戏中没有GM确保游戏公平运行!
天涯红月会员增值计划:
详情请点击
信息浏览
关于比赛和如何设置比赛系统...
www.xtyhy.net  2012/4/12   天涯红月(中文)官方网站-红月十年浩劫风云再起

  关于比赛目前国外已经制作出比赛系统,是很多人进比赛地图从1级开始提供30分钟练及,30分钟以后PK 杀人越多积分越多排名就越高,其实比赛制作起来很简单,大家用自己的端就可以制作出比赛系统。最关键的就是如何设置你的服务器里的端。好了废话不多说看下面教程吧!

详细步骤:
用两套服务端(例如 d:\redmoonsvr [主服务端] 和 d:\Battle [比赛端] ),当然你[必须确保] Battle 服务端下的rmServer.ini配置文件的路径指向他

加入一个新的比赛数据库叫做:Battle 改变 rmServer.ini文件中RMBrain0 为 RMBrain1.新建数据源RMBrain1并且确保你的数据源 [ODBC] 也是如此命名的而且指向了第二个数据库,即Battle.

打开主服务器(非比赛服务器)的配置文件,删除132-136地图的信息,包括1_132开头的

接下来我们要编辑几张表..
第一张是 tblBattleZoneScore 表,右键单击该表并选择"设计表"

如果没有以下字段,请新加入.
EndLevel
EndExperience
NormalEnd
ZoneIndex
以上四个字段,请记住勾选上"不能为空"(NOT NULL)..

然后给该表的如下字段赋上初值.
ServerIndex 默认值  1
Win 默认值  0
Lose 默认值  0
Score 默认值  0
ZoneIndex 默认值  1

做完如上工作后,保存并退出.

接下来的两张表是 tblBattleZoneScoreLog 和  tblCurrentBattleZoneScore中给那些如上所述的字段赋上如上所述的初值.
然后是 tblBattleZoneChampionLog 表
zoneindex 和 serverindex 赋初值为 1
Mailsent 赋初值为 0
SentItem  赋初值为 0

给表tblbattlezonescorelog和表 tblBattleZoneScore 跟上面一样的初值.

现在你必须修改一些存储过程或增加一些存储过程.
第一个存储过程: USERDB_InsertBATTLEID(两个数据库都添加)

在两个服务端的数据库中同时新建这个存储过程
将以下代码复制后导入: ( 如果你的数据库本身有这个存储过程,请你删除它 )
-------------------[代码开始]请勿拷贝此线-----------------------
3.8c代碼
Create PROCEDURE dbo.RMS_USERDB_InsertBATTLEID

@GameID varchar(14),
@BillID varchar(14),
@Face int,
@Color1 int,
@Color2 int

AS
set nocount on

begin transaction RMS_USERDB_InsertBATTLEID

Delete Battle.dbo.tblGameID1 Where GameID=@GameID and BillID=@BillID
Insert INTO Battle.dbo.tblGameID1 (Version, lvl , Map, X, Y, TileKind, Item, Equipment, Skill, SpecialSkill, Strength, Spirit, Dexterity, Power, Fame, Experiment, HP, MP, SP, DP, Bonus, Money, QuickItem, QuickSkill, QuickSpecialSkill, BankMoney, BankItem, SETimer, PKTimer, PoisonUsedDate, LovePoint, SurvivalEvent, SurvivalTime, Bonus2, Sbonus, STotalBonus, BonusInitCount, TLETimer, OpArmy, BankSigMoney,SigMoney,PKPenaltyDecreaseTimer, ArmyHired, ArmyMarkIndex, Permission, OPPKTimer, PKPenaltyCount, BankItem2, GameID, BillID, Face, Color1, Color2) VALUES (100, 1, 132, 57, 16, 1, 0, 0, 0, 0, 10, 10, 10, 10, 0, 0, 2000, 2000, 2000, 0, 2, 200000000, 0, 0, 0, 20000000, 0, 0, 2005/02/02, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @GameID, @BillID, @Face, @Color1, @Color2)
Delete tblSpecialItem1 Where GameID=@GameID

begin
commit transaction RMS_USERDB_InsertBATTLEID
end
GO
程序代码
Create PROCEDURE dbo.RMS_USERDB_InsertBATTLEID

@GameID varchar(14),
@BillID varchar(14),
@Face int,
@Color1 int,
@Color2 int

AS
set nocount on

begin transaction RMS_USERDB_InsertBATTLEID

Delete Battle.dbo.tblGameID1 Where GameID=@GameID and BillID=@BillID
Insert INTO Battle.dbo.tblGameID1 (Version, lvl , Map, X, Y, TileKind, Item, Equipment, Skill, SpecialSkill, Strength, Spirit, Dexterity, Power, Fame, Experiment, HP, MP, SP, DP, Bonus, Money, QuickItem, QuickSkill, QuickSpecialSkill, BankMoney, BankItem, SETimer, PKTimer, PoisonUsedDate, LovePoint, ToMap, SurvivalEvent, SurvivalTime, Bonus2, Sbonus, STotalBonus, BonusInitCount, TLETimer, OpArmy, BankSigMoney,SigMoney,PKPenaltyDecreaseTimer, ArmyHired, ArmyMarkIndex, Permission, OPPKTimer, PKPenaltyCount, BankItem2, BankPassword, MailPassword, SpouseGameID, GameID, BillID, Face, Color1, Color2) VALUES (100, 1, 132, 57, 16, 1, 0, 0, 0, 0, 10, 10, 10, 10, 0, 0, 2000, 2000, 2000, 0, 2, 200000000, 0, 0, 0, 20000000, 0, 0, 0, 2005/02/02, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @GameID, @BillID, @Face, @Color1, @Color2)
Delete tblSpecialItem1 Where GameID=@GameID

begin
commit transaction RMS_USERDB_InsertBATTLEID
end
GO

==================代码结束============================

然后在是 RMS_INITIALIZEBILLBATTLEZONE 存储过程代码
切忌:在战场服务端的数据库中并不是在主服务端的数据库中.如果有此存储过程,请删除它,然后复制如下代码.

------------------代码开始-----------------------------------
程序代码
Create PROCEDURE RMS_INITIALIZEBILLBATTLEZONE

@ZoneIndex int

AS

set nocount on

declare @Error int

set @Error = 1

begin transaction

delete tblCurrentBattleZoneScore where ZoneIndex = @ZoneIndex
delete redmoon.dbo.tblCurrentBattleArenaScore where ZoneIndex = @ZoneIndex
select @Error = @@ERROR

if 0 = @Error
begin
commit transaction
end
else
begin
rollback transaction
end
GO

==========================代码结束================================

接下来是发放奖励邮件.打开存储过程 SENDBATTLEPRIZEMAIL,清除该存储过程中的所有代码,并复制如下代码进去
------------------代码开始---------------------------------------------
程序代码
Create PROCEDURE RMS_SENDBATTLEPRIZETMAIL
@Sender varchar(14),
@Recipient varchar(14),
@Title varchar(80),
@Content varchar(1000),
@ItemKind int,
@ItemIndex int,
@ItemCount int
AS

set nocount on

declare @MailCount int
declare @Time datetime
set @MailCount = 0
set @Time=cast(convert(varchar, GetDate(), 120) as datetime)

If @ItemCount>100
begin
set @ItemCount=100
end

if @ItemKind!=6
begin
set @ItemCount=0
end

begin transaction

select @MailCount = count(*) from RedMoon.dbo.tblMail1 where Recipient =@Recipient and Time = @Time
while @MailCount > 0
begin
set @MailCount = 0
set @Time = dateadd(second, 1, @Time)
select @MailCount = count(*) from RedMoon.dbo.tblMail1 where Recipient = @Recipient and Time = @Time
end

while @ItemCount>0
begin
insert RedMoon.dbo.tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, Position, Map, X, Y, TileKind, GameID, WindowKind, WindowIndex, MiscTime, AttackGrade, StrengthGrade, SpiritGrade, DexterityGrade, PowerGrade) values (@ItemKind, @ItemIndex, 4, 2, 1, 100, 100, 1, @Recipient, 100, 0, @Time, 0, 0, 0, 0, 0)
set @ItemCount=@ItemCount -1
end

insert RedMoon.dbo.tblMail1 (Time, Recipient, Sender, ReadOrNot, Title, Line, Content, Item) values(@Time, @Recipient,@Sender, 0, @Title, 20, @Content, '')


commit transaction
GO

=========代码结束========================

然后是比赛游戏的的注册积分,做法和上面一样,删除存储过程  RMS_INCREASEBATTLEZONESCORE中的一切并复制如下代码:

---------------------代码开始-----------------------------------
程序代码
Create PROCEDURE RMS_INCREASEBATTLEZONESCORE
@ZoneIndex int,
@WinnerGameID varchar(14),
@WinnerBillID varchar(14),
@WinnerServerIndex int,
@LoserGameID varchar(14),
@LoserBillID varchar(14),
@LoserServerIndex int,
@Score int
AS

set nocount on

declare @WinnerCount int, @LoserCount int, @WinnerUpdateError int, @LoserUpdateError int

set @WinnerCount = 0
set @LoserCount = 0
set @WinnerUpdateError = 1
set @LoserUpdateError = 1

begin transaction

select @WinnerCount = count(*) from tblCurrentBattleZoneScore where GameID = @WinnerGameID and BillID = @WinnerBillID and ServerIndex = @WinnerServerIndex
if @WinnerCount = 0
begin
insert tblCurrentBattleZoneScore (ZoneIndex, GameID, BillID, ServerIndex) values (@ZoneIndex, @WinnerGameID, @WinnerBillID, @WinnerServerIndex)
insert redmoon.dbo.tblCurrentBattleArenaScore (ZoneIndex, GameID, BillID, ServerIndex) values (@ZoneIndex, @WinnerGameID, @WinnerBillID, @WinnerServerIndex)
insert redmoon.dbo.tblBattleArenaScore (ZoneIndex, GameID, BillID, ServerIndex) values (@ZoneIndex, @WinnerGameID, @WinnerBillID, @WinnerServerIndex)
insert tblBattleZoneScore (ZoneIndex, GameID, BillID, ServerIndex) values (@ZoneIndex, @WinnerGameID, @WinnerBillID, @WinnerServerIndex)
insert tblBattleArenaScore (ZoneIndex, GameID, BillID, ServerIndex) values (1, @WinnerGameID, @WinnerBillID, @WinnerServerIndex)
end

select @LoserCount = count(*) from tblCurrentBattleZoneScore where GameID = @LoserGameID and BillID = @LoserBillID and ServerIndex = @LoserServerIndex
if @LoserCount = 0
begin
insert tblCurrentBattleZoneScore (ZoneIndex, GameID, BillID, ServerIndex) values (@ZoneIndex, @LoserGameID, @LoserBillID, @LoserServerIndex)
insert redmoon.dbo.tblCurrentBattleArenaScore (ZoneIndex, GameID, BillID, ServerIndex) values (@ZoneIndex, @LoserGameID, @LoserBillID, @LoserServerIndex)
insert tblBattleZoneScore (ZoneIndex, GameID, BillID, ServerIndex) values (@ZoneIndex, @LoserGameID, @LoserBillID, @LoserServerIndex)
insert redmoon.dbo.tblBattleArenaScore (ZoneIndex, GameID, BillID, ServerIndex) values (@ZoneIndex, @LoserGameID, @LoserBillID, @LoserServerIndex)
insert tblBattleArenaScore (ZoneIndex, GameID, BillID, ServerIndex) values (1, @LoserGameID, @LoserBillID, @LoserServerIndex)
end

update tblCurrentBattleZoneScore set Win = Win + 1, Score = Score + @Score where GameID = @WinnerGameID and BillID = @WinnerBillID and ServerIndex = @WinnerServerIndex
update redmoon.dbo.tblCurrentBattleArenaScore set Win = Win + 1, Score = Score + @Score where GameID = @WinnerGameID and BillID = @WinnerBillID and ServerIndex = @WinnerServerIndex
update tblBattleZoneScore set Win = Win + 1, Score = Score + @Score where GameID = @WinnerGameID and BillID = @WinnerBillID and ServerIndex = @WinnerServerIndex
update tblBattleArenaScore set Win = Win + 1, Score = Score + @Score where GameID = @WinnerGameID and BillID = @WinnerBillID and ServerIndex = @WinnerServerIndex
update redmoon.dbo.tblBattleArenaScore set Win = Win + 1, Score = Score + @Score where GameID = @WinnerGameID and BillID = @WinnerBillID and ServerIndex = @WinnerServerIndex
select @WinnerUpdateError = @@ERROR

update tblCurrentBattleZoneScore set Lose = Lose + 1 where GameID = @LoserGameID and BillID = @LoserBillID and ServerIndex = @LoserServerIndex
update redmoon.dbo.tblCurrentBattleArenaScore set Lose = Lose + 1 where GameID = @LoserGameID and BillID = @LoserBillID and ServerIndex = @LoserServerIndex
update tblBattleZoneScore set Lose = Lose + 1 where GameID = @LoserGameID and BillID = @LoserBillID and ServerIndex = @LoserServerIndex
update redmoon.dbo.tblBattleArenaScore set Lose = Lose + 1 where GameID = @LoserGameID and BillID = @LoserBillID and ServerIndex = @LoserServerIndex
update tblBattleArenaScore set Lose = Lose + 1 where GameID = @LoserGameID and BillID = @LoserBillID and ServerIndex = @LoserServerIndex
select @LoserUpdateError = @@ERROR

if @WinnerUpdateError = 0 and @LoserUpdateError = 0
begin
commit transaction
end
else
begin
rollback transaction
end
GO

=====================代码结束==========================================

接下来是存储过程 RMS_ELECTCHAMPIONANDCLEANUPBATTLEZONE,做法如上,不赘述.

----------------------代码开始---------------------------
程序代码
Create PROCEDURE RMS_ELECTCHAMPIONANDCLEANUPBATTLEZONE

@ZoneIndex int,
@Time datetime,
@Today datetime

AS

set nocount on

declare @GameID varchar(14), @BillID varchar(14), @ServerIndex int, @TodaySendItemCount int
declare @Error int, @ScoreCount int, @Win int, @Lose int, @Score int

set @TodaySendItemCount = 1
set @Error = 0


begin transaction

select top 1 @GameID = GameID, @BillID = BillID, @ServerIndex = ServerIndex from tblBattleArenaScore with (TABLOCKX) where Win > 0 And ZoneIndex = @ZoneIndex order by Win desc, EndLevel desc, sign(EndExperience), EndExperience desc
if @@ROWCOUNT > 0
begin
select @TodaySendItemCount = count(*) from tblBattleArenaChampionLog where GameID = @GameID and BillID = @BillID and Time >= @Today and Time < dateadd(day, 1, @Today) and SendItem = 1
select @Error = @@ERROR

if @Error = 0
begin
if @TodaySendItemCount > 0
begin
insert tblBattleArenaChampionLog (ZoneIndex, GameID, BillID, ServerIndex, Time) values (@ZoneIndex, @GameID, @BillID, @ServerIndex, @Time)
select @Error = @@ERROR
end
else
begin
insert tblBattleArenaChampionLog (ZoneIndex, GameID, BillID, ServerIndex, Time, SendItem, MailSent) values (@ZoneIndex, @GameID, @BillID, @ServerIndex, @Time, 1, 1)
select @Error = @@ERROR
end
end
end

declare user_cursor cursor for
select GameID, BillID, ServerIndex, Win, Lose, Score from tblCurrentBattleArenaScore where ZoneIndex = @ZoneIndex

open user_cursor

fetch next from user_cursor into @GameID, @BillID, @ServerIndex, @Win, @Lose, @Score

while @@FETCH_STATUS = 0 and @Error = 0
begin
select @ScoreCount = count(*) from tblBattleArenaScore where GameID = @GameID and BillID = @BillID and ServerIndex = @ServerIndex
select @Error = @@ERROR

if @Error = 0
begin
if @ScoreCount = 0
begin
insert tblBattleArenaScore (GameID, BillID, ServerIndex, Win, Lose, Score) values (@GameID, @BillID, @ServerIndex, @Win, @Lose, @Score)
insert redmoon.dbo.tblBattleArenaScore (GameID, BillID, ServerIndex, Win, Lose, Score) values (@GameID, @BillID, @ServerIndex, @Win, @Lose, @Score)
select @Error = @@ERROR
end
else
begin
update tblBattleArenaScore set Win = Win + @Win, Lose = Lose + @Lose, Score = Score + @Score where BillID = @BillID and GameID = @GameID and ServerIndex = @ServerIndex
update redmoon.dbo.tblBattleArenaScore set Win = Win + @Win, Lose = Lose + @Lose, Score = Score + @Score where BillID = @BillID and GameID = @GameID and ServerIndex = @ServerIndex
select @Error = @@ERROR
end
end
fetch next from user_cursor into @GameID, @BillID, @ServerIndex, @Win, @Lose, @Score
end

close user_cursor
deallocate user_cursor

if @Error = 0
begin
insert into tblBattleZoneScoreLog (ZoneIndex, GameID, BillID, ServerIndex, Win, Lose, Score, NormalEnd, EndLevel, EndExperience) select ZoneIndex, GameID, BillID, ServerIndex, Win, Lose, Score, NormalEnd, EndLevel, EndExperience from tblCurrentBattleZoneScore
delete tblCurrentBattleZoneScore where ZoneIndex = @ZoneIndex
insert into redmoon.dbo.tblBattleArenaScoreLog (ZoneIndex, GameID, BillID, ServerIndex, Win, Lose, Score, NormalEnd, EndLevel, EndExperience) select ZoneIndex, GameID, BillID, ServerIndex, Win, Lose, Score, NormalEnd, EndLevel, EndExperience from redmoon.dbo.tblCurrentBattleArenaScore
delete redmoon.dbo.tblCurrentBattleZoneScore where ZoneIndex = @ZoneIndex
select @Error = @@ERROR
end

if @Error = 0
begin

EXEC Battle.dbo.RMS_SENDBATTLEPRIZETMAIL 'Kasham', @GameID, 'Congradulations', 'You are the lastest winner in
the Battle Dimension! , congradulations! , here is your prize', 6, 66, 1
commit transaction
end
else
begin
rollback transaction
end
GO

====================代码结束============================================== =

然后清除比赛服务端中的存储过程RMS_CLEANUPGAMEBATTLE ,方法如上,我们继续..
有点繁琐哈,当然请坚持哦.!

-----------------代码开始---------------
程序代码
Create PROCEDURE RMS_CLEANUPGAMEBATTLE AS
set nocount on
Begin
Delete Battle.dbo.tblBattleArenaScore
Delete Battle.dbo.tblCurrentBattleZoneScore
Delete Battle.dbo.tblGameID1
Delete Battle.dbo.tblSpecialItem1
End

GO

==============代码结束=======================


Ok ,比赛服务器我们现在搞定了.. 你在运行过程中或许会出现一些奇怪的小问题,但是我相信你完全可以搞定它.

你必须从比赛服务端中启动MapCenter . 你必须同时在BattleArena参数启动它. 所有的比赛地图必须从它Battle服务端中启动否则它们将不能正常运行, 从你的比赛服务端的rmServermgr.ini 文件删除它以及相关配置,仅仅留下地图  132 - 136.

你不需要在主服务端启动你的 Map Center . 2个MapCenter 启动的话,会停止所有的内部或者外部的通信。.

简单来说,你要启动的程序的方法如下:

IPserv.exe 从主服务端启动
RMServMgr.exe 从主服务端启动.
Map Center for RMBattleLeague.exe 从战场服务端启动
RMServMgr.exe 从战场服务端启动

记得在两个服务端的配置文件中都设置好比赛的时间.
而且他们必须相同。.

/////////////////////***非常重要的一些事***///////////////////////////////
忘记了3个重要的设置:
在比赛RMSERVER。INI里面设置 1_21=127.0.0.1, 10141
在你的两个服务端的server.ini 文件中追加如下的配置
同时更改 BM message 为 BattleMatchMessage=0

接下来 :
在主服务端和战场服务端的表tblBattleEntry中

加入如下的配置
左边的列 : 加入所有的玩家名字
右边的列 : 1

不然的话当你点击比赛的时候它会告诉你无法进入.




添加:2012/4/12  录入:WanAdmin  人气:1930

返回】 【顶部】 【关闭

关于比赛和如何设置比赛系统...--天涯红月(中文)官方网站-红月十年浩劫风云再起