导航菜单
首页 » 石器私服教程 » 正文

利用LUA写族战时间保护

今天在群里看到石器一个群里有人问到怎么用LUA写族战保护时间,因为我记得服务端里是有这个功能的,没记错的话应该

#define _BATTLE_OVER_STAR_TIME// 战斗后重新开始时间间隔

如果没有打开该怎么办?我大致想了下原理,先从PK结束后写入一个常量,然后再通过PK点击按钮进行判断即可。

那么就这么办,首先打开battlefinishfunction.lua并看到function BattleFinishFunction( charaindex, battletime, battleturn, win )函数

这个函数最初是任何战斗的执行函数,后来有人改过了,所以这里是PK的函数。那么就在这里添加下列代码:


function BattleFinishFunction( charaindex, battletime, battleturn, win )
	char.setWorkInt(charaindex, "PK时间", os.time())
end

之后找到freevsplayer.lua看到function FreeVsPlayer( meindex, toindex )函数后加入下列代码:



function FreeVsPlayer( meindex, toindex )
		for i = 1, table.getn(fmpkpoint) do 
			if char.getInt(meindex, "地图号") == fmpkpoint[i] then
				if char.getWorkInt(toindex,"PK时间") + 120 > os.time() then
					char.TalkToCli(meindex, -1, "对方正在保护中,剩余时间:" .. char.getWorkInt(toindex,"PK时间") + 120 - os.time() .. "秒。", "红色")
					return 1
				end
			end
		end
		return 0
end

function main()
	fmpkpoint = {1042, 2032, 3032, 4032, 2002,5032,6032}
end

这样就行了,fmpkpoint的数组中是族战PK的地图ID。

评论(0)

二维码