| 11-10-2009, 02:27 PM | #1 |
Actually i do it with the local selection for each player with dummies units. But theoretically it could fuck up players' unit selections. I think it can be done with gamecache, but i'm not sure and i don't know how to do it. I think i can edit this script for my purpose but i don't see how : http://www.wc3jass.com/viewtopic.php?t=2713#gethost Maybe it would be slower but i don't care, i don't need to sync local datas each 0.03 s or so, it can't be done anyway. |
| 11-10-2009, 02:28 PM | #2 |
Each local data of players? I even don't understand the question. Edit: Ah you mean the stored campaign data? |
| 11-10-2009, 02:29 PM | #3 |
For example, the camera target x of Player(0), Player(1), Player(2), and so one. But for the question let's assume it's a local boolean, it would be easier to explain the method. |
| 11-10-2009, 03:45 PM | #4 |
Gamecache. Clear X of gc for all. Set X = Y for gc for local player. Sync X of gc for all. Get Y from gc for local player. Since it only exists for one player, it syncs fine. |
| 11-10-2009, 04:28 PM | #5 |
I don't really understand what you said, i've tried this : Don't sync any data : JASS:call StoreInteger(GC,I2S(GetPlayerId(GetLocalPlayer())),"0",GetPlayerId(GetLocalPlayer())+1) call TriggerSyncStart() call SyncStoredInteger(GC, "0", "0") call TriggerSyncReady() call TriggerSyncStart() call SyncStoredInteger(GC, "1", "0") call TriggerSyncReady() call BJDebugMsg(I2S(GetStoredInteger(GC,"0","0"))) call BJDebugMsg(I2S(GetStoredInteger(GC,"1","0"))) sync only the first data JASS:call StoreInteger(GC,I2S(GetPlayerId(GetLocalPlayer())),"0",GetPlayerId(GetLocalPlayer())+1) call TriggerSyncStart() call SyncStoredInteger(GC, "0", "0") call SyncStoredInteger(GC, "1", "0") call TriggerSyncReady() call BJDebugMsg(I2S(GetStoredInteger(GC,"0","0"))) call BJDebugMsg(I2S(GetStoredInteger(GC,"1","0"))) |
| 11-10-2009, 05:18 PM | #6 |
Its basicly this: JASS:if GetLocalPlayer() == player then call SaveSomeStuffToCache(lols) // now this lols only exists //on this one players machine endif call DoGamecacheSyncStuff(luls) // After syncing it now exists on all players machines, //so you can use that having to worry about doing something desyncing with it. Its just sad that syncing takes some time because it requires net traffic stuff, so you cant really use it instantly. |
| 11-10-2009, 05:22 PM | #7 |
Sorry but i still don't understand how to get each player local data on each player computer. Or maybe using some .execute(), hmm ... |
| 11-11-2009, 06:57 PM | #8 |
I've tried many things including using several threads/triggers/gamecache, even using a TriggerSleepAction/timer between several syncs (ofc i used GetLocalPlayer() with Store...), and i can only sync the host data. So i guess i will keep the unit selection stuff. |
| 11-11-2009, 10:24 PM | #9 |
We can't read your mind. Post what you have. Also, have you tried putting the sync data bit into the local player block? |
| 11-12-2009, 03:19 PM | #10 | ||
Quote:
But i will post a clean one. Quote:
|
| 11-12-2009, 04:09 PM | #11 |
It should probably work. Isnt that how people used to do when they did those cheats in DotA to get 100000 damage for their spells or something? |
| 11-12-2009, 04:53 PM | #12 |
JASS:library SyncDatas initializer onInit globals private trigger array Trig private gamecache array GC private timer array Tim endglobals // first test private function Actions_11 takes nothing returns nothing call FlushStoredInteger(GC[11],"0","0") if GetLocalPlayer() == Player(0) then call StoreInteger(GC[11],"0","0",1) endif call TriggerSyncStart() call SyncStoredInteger(GC[11], "0", "0") call TriggerSyncReady() call BJDebugMsg("Test 1-1 , data synchronized == " + I2S(GetStoredInteger(GC[11],"0","0"))) endfunction private function Actions_12 takes nothing returns nothing call FlushStoredInteger(GC[12],"0","0") if GetLocalPlayer() == Player(1) then call StoreInteger(GC[12],"0","0",2) endif call TriggerSyncStart() call SyncStoredInteger(GC[12], "0", "0") call TriggerSyncReady() call BJDebugMsg("Test 1-2 , data synchronized == " + I2S(GetStoredInteger(GC[12],"0","0"))) call BJDebugMsg(" ") endfunction private function DoTheSync takes nothing returns nothing local integer i = S2I(GetEventPlayerChatString()) call TimerStart(Tim[10*i+1],1.,false,null) call TimerStart(Tim[10*i+2],6.,false,null) endfunction private function onInit takes nothing returns nothing local trigger trig = CreateTrigger() call TriggerRegisterPlayerChatEvent(trig,Player(0),"",false) call TriggerAddAction(trig,function DoTheSync) //! textmacro t_InitTestSync takes TEST_NAME set GC[10*$TEST_NAME$+1] = InitGameCache("$TEST_NAME$"+"1") set GC[10*$TEST_NAME$+2] = InitGameCache("$TEST_NAME$"+"2") set Trig[10*$TEST_NAME$+1] = CreateTrigger() set Trig[10*$TEST_NAME$+2] = CreateTrigger() set Tim[10*$TEST_NAME$+1] = CreateTimer() set Tim[10*$TEST_NAME$+2] = CreateTimer() call TriggerAddAction(Trig[10*$TEST_NAME$+1],function Actions_$TEST_NAME$1) call TriggerRegisterTimerExpireEvent(Trig[10*$TEST_NAME$+1],Tim[10*$TEST_NAME$+1]) call TriggerAddAction(Trig[10*$TEST_NAME$+2],function Actions_$TEST_NAME$2) call TriggerRegisterTimerExpireEvent(Trig[10*$TEST_NAME$+2],Tim[10*$TEST_NAME$+2]) //! endtextmacro //! runtextmacro t_InitTestSync("1") endfunction endlibrary Currently here is only one test, i can't imagine an other which should work in theory, any idea ? EDIT : Ofc, here i use several triggers and gamecache, a 5s margin between 2 tests, just to be sure it will work, but i need a better way. |
| 11-12-2009, 11:06 PM | #13 |
try local sync. |
| 11-13-2009, 09:19 PM | #14 |
It works. The time needed to sync all local datas is about 0.5 s. But i've tested only with a good host, it's probably higher with a crap connection. I will edit this post to tell the difference. JASS:library SyncDatas initializer onInit globals private trigger array Trig private gamecache array GC private timer array Tim private force Players private integer I endglobals private function Actions takes nothing returns nothing local integer i = I if GetLocalPlayer() == Player(i) then call StoreReal(GC[0],I2S(i),"0",GetCameraTargetPositionX()) endif call TriggerSyncStart() if GetLocalPlayer() == Player(i) then call SyncStoredReal(GC[0], I2S(i), "0") endif call TriggerSyncReady() call BJDebugMsg("time elapsed == " + R2S(TimerGetElapsed(Tim[0]))) call BJDebugMsg("data of Player( " + I2S(i) + ") == " + R2S(GetStoredReal(GC[0],I2S(i),"0"))) call BJDebugMsg(" ") endfunction private function Callback takes nothing returns nothing set I = GetPlayerId(GetEnumPlayer()) call TriggerExecute(Trig[i]) endfunction private function DoTheSync takes nothing returns nothing call ForForce(Players,function Callback) call TimerStart(Tim[0],10.,false,null) endfunction private function onInit takes nothing returns nothing local trigger trig = CreateTrigger() local integer i = 0 call TriggerRegisterPlayerChatEvent(trig,Player(0),"test",true) call TriggerAddAction(trig,function DoTheSync) set Players = CreateForce() set GC[0] = InitGameCache(SCOPE_PREFIX) set Tim[0] = CreateTimer() loop exitwhen i == 12 if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(i)) == MAP_CONTROL_USER then call ForceAddPlayer(Players,Player(i)) set Trig[i] = CreateTrigger() call TriggerAddAction(Trig[i],function Actions) endif set i = i+1 endloop endfunction endlibrary |
