• 🏆 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!

[Trigger] Save/Load Multiplayer Games Help

Status
Not open for further replies.
Level 1
Joined
Dec 8, 2015
Messages
5
Hello guys, I have some map ideas and I would like to learn how to save/load information in multiplayer games, but i don't know anything about JASS.

When you finish a game in Farm TD, you can type -save and the game saves a .txt file in your computer. Then you can load it later. This seems like the simplest way to me, convert information into strings then save into a .txt.

Anyone knows how to do that? :D
 
Without JASS it won't work, so the best would be you invest time inbefore to get base knowledge. Example HelpMe for some links, or just JASS Class.

Then for the save/load you at first might want to have a look at FileIO examples. It already provides the functionality to read and write a file.

Lastly if you might want to have some encryption to make the save code not human-readable anymore, so to fight cheating. This might be not too basic anymore. Optimal Save System 0.4 - Wc3C.net
 
Level 1
Joined
Dec 8, 2015
Messages
5
Without JASS it won't work, so the best would be you invest time inbefore to get base knowledge. Example HelpMe for some links, or just JASS Class.

Then for the save/load you at first might want to have a look at FileIO examples. It already provides the functionality to read and write a file.

Lastly if you might want to have some encryption to make the save code not human-readable anymore, so to fight cheating. This might be not too basic anymore. Optimal Save System 0.4 - Wc3C.net

Thanks! I tested FileIO in my own way and it worked, but how do I specify which player the file will save/load to?
 
Level 1
Joined
Dec 8, 2015
Messages
5
Presumably this system could be used to save a TD layout too with a bit of effort: Codeless Save and Load (Multiplayer) - v3.0.0

yeah, but this use a lot of JASS stuff that I don't understand D:
but maybe that FileIO and PlayerUtils libraries is what I need, I just don't know how to use it.

how do I specify which player the file will save/load to from that: call FileIO_Write("test.txt", udg_tempstring) ?
 
Read and write the File for LocalPlayer. There are for sure also tutorials about local player.

After reading the data it will be loaded only for one player first. The new Blizzard sync functions can be used to make them sync, globally for all players.

Tell us if you have problems with a certain step.
For testing I would go with a simple example.
 
Last edited:
Level 1
Joined
Dec 8, 2015
Messages
5
Ok, I learned how GetLocalPlayer() function works, but i don't know how to put it in the trigger.
(I also learned how to post my triggers lol)

Here is a simple example of the trigger I want to do, but for LocalPlayer:
  • Save
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as A substring
      • Player - Player 2 (Blue) types a chat message containing -save as A substring
      • Player - Player 3 (Teal) types a chat message containing -save as A substring
      • Player - Player 4 (Purple) types a chat message containing -save as A substring
    • Conditions
    • Actions
      • Set tempstring = (Substring((Entered chat string), 7, 999))
      • Custom script: call FileIO_Write("message.txt", udg_tempstring)
  • Load
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as An exact match
      • Player - Player 2 (Blue) types a chat message containing -load as An exact match
      • Player - Player 3 (Teal) types a chat message containing -load as An exact match
      • Player - Player 4 (Purple) types a chat message containing -load as An exact match
    • Conditions
    • Actions
      • Custom script: set udg_tempstring = FileIO_Read("message.txt")
      • Game - Display to (All players) the text: tempstring
 
Level 1
Joined
Dec 8, 2015
Messages
5
I think I got it, is that right?
  • save
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as A substring
      • Player - Player 2 (Blue) types a chat message containing -save as A substring
      • Player - Player 3 (Teal) types a chat message containing -save as A substring
      • Player - Player 4 (Purple) types a chat message containing -save as A substring
    • Conditions
    • Actions
      • Custom script: set udg_tempplayer = GetLocalPlayer()
      • Set tempstring = (Substring((Entered chat string), 7, 999))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to tempplayer
        • Then - Actions
          • Custom script: call FileIO_Write("player.txt", udg_tempstring)
        • Else - Actions
          • Do nothing
  • load
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as An exact match
      • Player - Player 2 (Blue) types a chat message containing -load as An exact match
      • Player - Player 3 (Teal) types a chat message containing -load as An exact match
      • Player - Player 4 (Purple) types a chat message containing -load as An exact match
    • Conditions
    • Actions
      • Custom script: set udg_tempplayer = GetLocalPlayer()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to tempplayer
        • Then - Actions
          • Custom script: set udg_tempstring = FileIO_Read("player.txt")
          • Game - Display to (All players) the text: tempstring
        • Else - Actions
          • Do nothing
 
Level 39
Joined
Feb 27, 2007
Messages
5,024
The Do Nothing action is useless, just don't put anything there. I believe it's still possible to desync the game by desyncing the string table. To be sure this doesn't happen the string needs to be saved into a global that everyone can 'see'. Normally one does this by saving the string in a variable outside the local block and then only using it inside the block, but here you can't exactly do that because the LP block is what's used to load the string. Someone else will have to comment on if I'm correct or this is a non-issue.
 
Status
Not open for further replies.
Top