• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to sync a locally saved string?

Status
Not open for further replies.
Level 7
Joined
Jan 30, 2011
Messages
267
i googled around a bit but i only found systems to synchronize integers
how do i synchronize a locally existing string to all other players?
i dont have a second computer to test it :/

this was my idea:
JASS:
function synctest takes nothing returns nothing
    local string s = ""
    local gamecache cache = InitGameCache("xy")
    if(GetLocalPlayer() == Player(0)) then
        set s = "hi"
        call StoreString(cache, "a", "a", s)
        call TriggerSyncStart()
        call SyncStoredString(cache, "a", "a")
        call TriggerSyncReady()
    endif
    set s = GetStoredString(cache, "a", "a")
endfunction

beside that, how much time does it take to sync a string? afaik it doesnt matter how long the string is
 
Last edited:
Level 7
Joined
Jan 30, 2011
Messages
267
i managed to get a second computer in order to test this stuff:

JASS:
function synctest takes nothing returns nothing
    local string s = "bye"
    local gamecache cache = InitGameCache("xy")
    if(GetLocalPlayer() == Player(0)) then
        set s = "hi"
    endif
    call StoreString(cache, "a", "a", s)
    call TriggerSyncStart()
    if(GetLocalPlayer() == Player(0)) then
        call SyncStoredString(cache, "a", "a")
    endif
    call TriggerSyncReady()
    set s = GetStoredString(cache, "a", "a")
    call TriggerSleepAction(0.)
    call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, s)
endfunction

it doesnt work...
i tried around a bit, disabling some lines, but couldnt get any satisfying result

EDIT: i tried the same thing with integer instead of string and it worked
beside that i found this thread: http://www.wc3c.net/showthread.php?t=105248
SyncStoredString seems to be useless...
 
Level 7
Joined
Jan 30, 2011
Messages
267
string hash wont work, because strings dont have unique hash ids
due to that the strings will only consists of 0-9, a-z and A-Z i can convert each block of 5 characters into 1 integer
this way it should work
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
http://www.hiveworkshop.com/forums/spells-569/network-v2-0-0-0-a-226065/?prev=mmr=6

http://www.hiveworkshop.com/forums/jass-resources-412/snippet-bitint-226174/
http://www.hiveworkshop.com/forums/jass-resources-412/system-bigint-188973/

Can do 8 bits per char like a cool person using BitInt (ascii), or can go random craziness and use BigInt

JASS:
local BitInt bits = BitInt.convertString("hello world", 6)
local BitInt node = bits

loop
    set node = node.next
    exitwhe node == bits

    //node.bits == number
endloop

//other way
loop
    exitwhen bits.bitCount == 0
    //bits.read(6) == number, but this is slower
endloop

//call bits.toString() //hello world
call bits.destroy()


edit
You can even do some madness and encrypt the string with AES as well as add an MD5 checksum to it : O.
 
Last edited:
Status
Not open for further replies.
Top