找回密码
 register

QQ登录

只需一步,快速开始

搜索
查看: 284|回复: 0

天龙场景计时器的使用方法:SetTimer 定时OnSceneTimer

[复制链接]
  • 打卡等级:热心大叔
  • 打卡总天数:270
  • 打卡月天数:20
  • 打卡总奖励:268
  • 最近打卡:2025-08-21 12:09:08
Waylee 发表于 2022-9-26 16:41 | 显示全部楼层 |阅读模式

马上注册,查看网站隐藏内容!!

您需要 登录 才可以下载或查看,没有账号?register

×
/** -----------------------------------------------------------------------
        *     开发人员 : 
        *     编写时间 : 2005-9-28
        *     函数名称 : LuaFnSetTimer
        *     参数说明 : 
        *                                 L
        *                                        LuaState执行环境指针
        *                                 sceneId
        *                                        调用该函数场景ID,short
        *                                 selfId
        *                                        调用者ID,无符号整型
        *                                 scriptId
        *                                        执行脚本ID,short类型
        *                                 funcName
        *                                        计时器回调调函数名,字符串类型
        *                                 tickTime
        *                                        计时器调用间隔时间
        *     功能说明 :
        *                                 给玩家打开计时器,时间到时将自动调用OnTimer函数        
        *                                 玩家本身身上并没有计时器,脚本程序需要计时器时向系统申请“租用”,由系统分配
        *                返回-1,表示错误
        */


scene.lua 在进入场景函数中加入 x888888_OnScenePlayerEnter

  1. if sceneId == 538 then  ---地宫4时间检查
  2.                 if CheckTimer(sceneId, 0) == 0  then
  3.                         SetTimer(sceneId, playerId, 989899, "OnSceneTimer", 10000)
  4.                 end
  5.         end
复制代码


二、自己的脚本
  1. --**********************************
  2. -- OnTime
  3. --**********************************
  4. function x892000_OnSceneTimer(sceneId)
  5.         local nHumanCount = LuaFnGetCopyScene_HumanCount(sceneId)
  6.         for i=0, nHumanCount-1 do
  7.                 local nHumanId = LuaFnGetCopyScene_HumanObjId(sceneId, i)
  8.                 x892000_DoHanYuLogic( sceneId, nHumanId )
  9.         end

  10. end
复制代码



您需要登录后才可以回帖 登录 | register

本版积分规则

雪舞知识库 ( 浙ICP备15015590号-1 | 萌ICP备20232229号|浙公网安备33048102000118号 ) |网站地图|天天打卡

GMT+8, 2025-8-22 09:50 , Processed in 0.101578 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表