偶久网

 找回密码
 注册会员

QQ登录

只需一步,快速开始

[官方推荐]偶久魔兽改图一条龙工具[魔兽存档]魔兽商城存档盒子自主刷存档[存档自刷]魔兽多功能存档盒子畅玩[单机特权]超强无视平台限制自由存档
[单机改图]魔兽改图辅助工具一键注入[脚本注入]魔兽地图管理工具加脚本权限[源图定制]原创魔兽地图专业定制[本地特权]特权解锁工具解锁商城权限

网站魔兽热门地图

查看: 1988|回复: 1

网络延迟获取-jass版

[复制链接]
ou99孽缘 title=
发表于 2010-12-14 18:34:04
通过以下代码可以获取同步网络延迟的数值,以下为全部代码,其中ms为自定义的全局整型变量,gc为自定义的全局游戏缓存变量,mb是自定义的全局多面板变量.Clock和DelayClock是自定义的全局计时器变量;不明白的同学请不要随便乱用额.可能引起掉线.
function FreshDelayTime takes nothing returns nothing

     local string s="|cff00ff00"

     if GetLocalPlayer()==Player(0) then

     call StoreInteger(gc,"GameTime","GetDelay",GetStoredInteger(gc,"GameTime","GetDelay")-1)

     endif

     if GetStoredInteger(gc,"GameTime","GetDelay")>500 then

     set s="|cffff0000"

     elseif GetStoredInteger(gc,"GameTime","GetDelay")>250 then

     set s="|cffffff00"

     endif

     call MultiboardSetTitleText(mb,"|cffffffff网络延迟: |r"+s+I2S(GetStoredInteger(gc,"GameTime","GetDelay"))+"|r |cffffffffms|r")

endfunction



function GetDelayTime takes nothing returns nothing

     if GetStoredInteger(gc,"GameTime","LastDelay")!=GetStoredInteger(gc,"GameTime","Delay") then

     call StoreInteger(gc,"GameTime","GetDelay",ms-GetStoredInteger(gc,"GameTime","Delay"))

     call StoreInteger(gc,"GameTime","LastDelay",GetStoredInteger(gc,"GameTime","Delay"))

     call FreshDelayTime()

     endif

endfunction



function DelayTime takes nothing returns nothing

     if GetLocalPlayer()==Player(0) then

     call StoreInteger(gc,"GameTime","Delay",ms)

     call SyncStoredInteger(gc,"GameTime","Delay")

     endif

endfunction



function TimeClock takes nothing returns nothing

     set ms=ms+1

endfunction



function ClockTime takes nothing returns nothing

     call TimerStart(Clock,0.001,true,function TimeClock)

     call TimerStart(CreateTimer(),1,true,function DelayTime)

     call TimerStart(DelayClock,0.001,true,function GetDelayTime)

endfunction


ou99孽缘 title=
 楼主| 发表于 2010-12-14 18:35:38
{:6_306:}  
路过拉  
快速回复 返回顶部 返回列表