找回密码
 点一下
查看: 902|回复: 2

找到一段jass代码 但是怎么引用呢?

[复制链接]
发表于 2014-1-6 21:27:34 | 显示全部楼层 |阅读模式
用到全局变量 cache 类型游戏缓存


function Trig_timedelay_Actions takes nothing returns nothing
local integer i=0
local integer p
local integer array nP
local timer t=CreateTimer()
local real array dt
local real delay
local integer Pnum=0
loop
exitwhen i>=12
set nP=0
set dt=0
set i=i+1
endloop
call DisplayTimedTextToPlayer(GetLocalPlayer(),.0,.0,20.,"正在检测主机

及网络延时,请等待......")
set i=1
call TimerStart(t,20.,false,null)
loop
exitwhen i>5
set dt=TimerGetElapsed(t)
call StoreInteger(udg_cache,"Player","number",GetPlayerId

(GetLocalPlayer())+1)
call TriggerSyncStart()
call SyncStoredInteger(udg_cache,"Player","number")                    

        //同步每个玩家缓存为主机号
call TriggerSyncReady()
set p=GetStoredInteger(udg_cache,"Player","number")-1
set nP[p]=nP[p]+1
call FlushStoredMission(udg_cache,"Player")
set dt=TimerGetElapsed(t)-dt                                          

  //统计第i次延时抽样
call PauseTimer(t)
call PolledWait(1.)
set i=i+1
call ResumeTimer(t)
endloop
set i=0
loop
exitwhen i>=12
if nP[Pnum]<nPthen
set Pnum=i
endif
set i=i+1
endloop
call DestroyTimer(t)
set t=null
set delay=(dt[1]+dt[2]+dt[3]+dt[4]+dt[5])/5.                           

        //对5次抽样进行平均(当然越多抽样越好,但是要考虑时间)
call DisplayTimedTextToPlayer(GetLocalPlayer(),.0,.0,10.,"主机 :

"+GetPlayerName(Player(Pnum)))
call DisplayTimedTextToPlayer(GetLocalPlayer(),.0,.0,10.,"网络延时 :

"+I2S(R2I(delay*1000))+"ms")
endfunction
发表于 2014-1-6 22:07:16 | 显示全部楼层
本帖最后由 希瓦 于 2014-1-6 22:17 编辑

Trig_timedelay_Actions

这是T转J后写的代码吧
timedelay是一个触发器的名字...

创建一个名叫timedelay的触发器,事件为“游戏时间逝去1.00秒”
然后转自定义代码
把这段拷进去替换掉同名函数即可

当然,全局变量要自己创建好

点评

我说的判断后的主机玩家的函数名 已经找到了 还是谢谢你啦  详情 回复 发表于 2014-2-9 11:18
回复

使用道具 举报

 楼主| 发表于 2014-2-9 11:18:50 | 显示全部楼层
希瓦 发表于 2014-1-6 22:07
Trig_timedelay_Actions

这是T转J后写的代码吧

我说的判断后的主机玩家的函数名
已经找到了
还是谢谢你啦


老毛桃一键还原软件超强发布!全面支持包括Windows7、XP、Vista、2000、2003等主流操作系统。操作简便、功能强大,让您一键轻松备份还原。
http://www.laomaotao.net/?O5268
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-5-21 04:46 , Processed in 0.224266 second(s), 24 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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