|
发表于 2012-9-20 23:52:02
|
显示全部楼层
[jass]
globals
gamecache udg_cameragc
endglobals
function InitCameraGC takes nothing returns nothing
if(udg_cameragc == null)then
call FlushGameCache(InitGameCache("SyncCamera.w3v"))
set udg_cameragc = InitGameCache("SyncCamera.w3v")
endif
endfunction
function GetSyncCameraPos takes player p returns location
local real x
local real y
local string k
if(GetPlayerController(p) != MAP_CONTROL_USER)then
return null
endif
set k = I2S(GetPlayerId(p))
call StoreInteger(udg_cameragc,k,"R",-1)//用来标记同步开始
if(GetLocalPlayer()==p)then//使用LocalPlayer以同步指定玩家的数据
call SyncStoredInteger(udg_cameragc,k,"R")
set x = GetStoredReal(udg_cameragc,k,"X")//记录同步前的数据
call StoreReal(udg_cameragc,k,"X",GetCameraTargetPositionX())
call SyncStoredReal(udg_cameragc,k,"X")//开始同步新数据
call StoreReal(udg_cameragc,k,"X",x)//还原同步前的数据,避免可能出现的不同步
set y = GetStoredReal(udg_cameragc,k,"Y")
call StoreReal(udg_cameragc,k,"Y",GetCameraTargetPositionY())
call SyncStoredReal(udg_cameragc,k,"Y")
call StoreReal(udg_cameragc,k,"X",y)//Y和X的同步同理
call StoreInteger(udg_cameragc,k,"R",0)
call SyncStoredInteger(udg_cameragc,k,"R")//标志同步结束
call StoreInteger(udg_cameragc,k,"R",-1)
endif
loop//循环等待,直到同步结束或玩家掉线
exitwhen(GetPlayerSlotState(p)==PLAYER_SLOT_STATE_LEFT)
call TriggerSleepAction(0.00)
if(GetStoredInteger(udg_cameragc,k,"R")==0)then
return Location(GetStoredReal(udg_cameragc,k,"X"),GetStoredReal(udg_cameragc,k,"Y"))
endif
endloop
return null//同步失败则返回null
endfunction
[/jass]
大概也许可能应该是这样吧 |
|