function ontimerex0()
-- 跨服定时器
-- 10秒执行一次
-- 跨服通知本服触发
a = a + 1
release_print("跨服定时器触发", a)
if a % 10 == 0 then
kfsyscall_30("0", "arg1", "arg2")
end
-- if a >= 10 then
-- a = 0
-- 跨服通知本服触发
-- k
🤖 回答引擎: 后端Lua |
🕒 时间: 2026-03-18 00:42:29 |
👁️ 阅读: 6
我是后端Lua老师!
小仙,根据你的需求,我来帮你修改这个跨服定时器。你需要检测特定分钟数来控制传送门的开启和关闭。由于你的定时器是10秒执行一次,我们可以通过计算总秒数来判断当前处于哪个分钟阶段。
```lua
function ontimerex0()
-- 跨服定时器
-- 10秒执行一次
-- 跨服通知本服触发
a = a + 1
release_print("跨服定时器触发", a)
-- 计算当前总秒数(10秒执行一次,a是执行次数)
local total_seconds = a * 10
local current_minute = math.floor(total_seconds / 60)
-- 检测传送门开启关闭逻辑
if current_minute == 1 then
-- 第1分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第1分钟传送门开启")
elseif current_minute == 4 then
-- 第4分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第4分钟传送门关闭")
elseif current_minute == 6 then
-- 第6分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第6分钟传送门开启")
elseif current_minute == 9 then
-- 第9分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第9分钟传送门关闭")
elseif current_minute == 10 then
-- 第10分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第10分钟传送门开启")
elseif current_minute == 13 then
-- 第13分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第13分钟传送门关闭")
elseif current_minute == 14 then
-- 第14分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第14分钟传送门开启")
elseif current_minute == 17 then
-- 第17分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第17分钟传送门关闭")
elseif current_minute == 19 then
-- 第19分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第19分钟传送门开启")
elseif current_minute == 22 then
-- 第22分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第22分钟传送门关闭")
elseif current_minute == 24 then
-- 第24分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第24分钟传送门开启")
elseif current_minute == 27 then
-- 第27分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第27分钟传送门关闭")
elseif current_minute == 30 then
-- 第30分钟活动结束
kfsyscall_30("0", "活动结束", tostring(current_minute))
release_print("第30分钟活动结束")
-- 可以在这里停止定时器
setofftimerex(0)
end
-- 原有的逻辑
if a % 10 == 0 then
kfsyscall_30("0", "arg1", "arg2")
end
-- 如果活动已经结束,重置a
if current_minute >= 30 then
a = 0
end
end
```
这个修改后的定时器会:
1. 每10秒执行一次
2. 计算当前的总秒数和分钟数
3. 在指定的分钟数触发传送门的开启、关闭和活动结束
4. 活动结束后停止定时器
注意:`kfsyscall_30`函数需要你在本服有对应的接收处理逻辑。另外,记得在活动开始时设置`a = 0`来重置计数器。
我是后端Lua老师!
小仙,根据你的需求,我来帮你修改这个跨服定时器。你需要检测特定分钟数来控制传送门的开启和关闭。由于你的定时器是10秒执行一次,我们可以通过计算总秒数来判断当前处于哪个分钟阶段。
```lua
function ontimerex0()
-- 跨服定时器
-- 10秒执行一次
-- 跨服通知本服触发
a = a + 1
release_print("跨服定时器触发", a)
-- 计算当前总秒数(10秒执行一次,a是执行次数)
local total_seconds = a * 10
local current_minute = math.floor(total_seconds / 60)
-- 检测传送门开启关闭逻辑
if current_minute == 1 then
-- 第1分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第1分钟传送门开启")
elseif current_minute == 4 then
-- 第4分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第4分钟传送门关闭")
elseif current_minute == 6 then
-- 第6分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第6分钟传送门开启")
elseif current_minute == 9 then
-- 第9分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第9分钟传送门关闭")
elseif current_minute == 10 then
-- 第10分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第10分钟传送门开启")
elseif current_minute == 13 then
-- 第13分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第13分钟传送门关闭")
elseif current_minute == 14 then
-- 第14分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第14分钟传送门开启")
elseif current_minute == 17 then
-- 第17分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第17分钟传送门关闭")
elseif current_minute == 19 then
-- 第19分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第19分钟传送门开启")
elseif current_minute == 22 then
-- 第22分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第22分钟传送门关闭")
elseif current_minute == 24 then
-- 第24分钟传送门开启
kfsyscall_30("0", "传送门开启", tostring(current_minute))
release_print("第24分钟传送门开启")
elseif current_minute == 27 then
-- 第27分钟传送门关闭
kfsyscall_30("0", "传送门关闭", tostring(current_minute))
release_print("第27分钟传送门关闭")
elseif current_minute == 30 then
-- 第30分钟活动结束
kfsyscall_30("0", "活动结束", tostring(current_minute))
release_print("第30分钟活动结束")
-- 可以在这里停止定时器
setofftimerex(0)
end
-- 原有的逻辑
if a % 10 == 0 then
kfsyscall_30("0", "arg1", "arg2")
end
-- 如果活动已经结束,重置a
if current_minute >= 30 then
a = 0
end
end
```
这个修改后的定时器会:
1. 每10秒执行一次
2. 计算当前的总秒数和分钟数
3. 在指定的分钟数触发传送门的开启、关闭和活动结束
4. 活动结束后停止定时器
注意:`kfsyscall_30`函数需要你在本服有对应的接收处理逻辑。另外,记得在活动开始时设置`a = 0`来重置计数器。
← 返回问答库