Making a save code at the end of a game

LoveTD's

New Member
Reaction score
34
hey all, I'm having a big problem with aceharts save/load code... What I try to do is: create a save code when the game ends instead of having to type -save everytime to save your code... Now my problem is:
whenever I try to show a code without having to type -save the code is invalid for some reason... here is the trigger I used to create the save codes at the end of the game:

Trigger:
  • My game is ending
    • Events
      • My game ends <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" />
    • Conditions
    • Actions
      • Set Save[1] = Total_Score_of_player[1]
      • Set Save[2] = double_kills_player[1]
      • Set Save[3] = triple_kills_player[1]
      • Set Save[4] = overkills_player[1]
      • Set Save[5] = killtaculars_player[1]
      • Set Save[6] = killtrocitys_player[1]
      • Set Save[7] = killinmanjaros_player[1]
      • Set SaveCount = 7
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Game - Display to Player Group - Player 1 (Red) for 60.00 seconds the text: Code
      • Set Save[1] = Total_Score_of_player[2]
      • Set Save[2] = double_kills_player[2]
      • Set Save[3] = triple_kills_player[2]
      • Set Save[4] = overkills_player[2]
      • Set Save[5] = killtaculars_player[2]
      • Set Save[6] = killtrocitys_player[2]
      • Set Save[7] = killinmanjaros_player[2]
      • Set SaveCount = 7
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Game - Display to Player Group - Player 2 (Blue) for 60.00 seconds the text: Code
      • Set Save[1] = Total_Score_of_player[3]
      • Set Save[1] = Total_Score_of_player[3]
      • Set Save[2] = double_kills_player[3]
      • Set Save[3] = triple_kills_player[3]
      • Set Save[4] = overkills_player[3]
      • Set Save[5] = killtaculars_player[3]
      • Set Save[6] = killtrocitys_player[3]
      • Set Save[7] = killinmanjaros_player[3]
      • Set SaveCount = 7
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Game - Display to Player Group - Player 3 (Teal) for 60.00 seconds the text: Code
      • Set Save[2] = double_kills_player[4]
      • Set Save[3] = triple_kills_player[4]
      • Set Save[4] = overkills_player[4]
      • Set Save[5] = killtaculars_player[4]
      • Set Save[6] = killtrocitys_player[4]
      • Set Save[7] = killinmanjaros_player[4]
      • Set SaveCount = 7
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Game - Display to Player Group - Player 4 (Purple) for 60.00 seconds the text: Code
      • Set Save[2] = double_kills_player[5]
      • Set Save[3] = triple_kills_player[5]
      • Set Save[4] = overkills_player[5]
      • Set Save[5] = killtaculars_player[5]
      • Set Save[6] = killtrocitys_player[5]
      • Set Save[7] = killinmanjaros_player[5]
      • Set SaveCount = 7
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Game - Display to Player Group - Player 5 (Yellow) for 60.00 seconds the text: Code
      • Set Save[1] = Total_Score_of_player[6]
      • Set Save[2] = double_kills_player[6]
      • Set Save[3] = triple_kills_player[6]
      • Set Save[4] = overkills_player[6]
      • Set Save[5] = killtaculars_player[6]
      • Set Save[6] = killtrocitys_player[6]
      • Set Save[7] = killinmanjaros_player[6]
      • Set SaveCount = 7
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Game - Display to Player Group - Player 6 (Orange) for 60.00 seconds the text: Code
      • Set Save[1] = Total_Score_of_player[7]
      • Set Save[2] = double_kills_player[7]
      • Set Save[3] = triple_kills_player[7]
      • Set Save[4] = overkills_player[7]
      • Set Save[5] = killtaculars_player[7]
      • Set Save[6] = killtrocitys_player[7]
      • Set Save[7] = killinmanjaros_player[7]
      • Set SaveCount = 7
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Game - Display to Player Group - Player 7 (Green) for 60.00 seconds the text: Code
      • Set Save[1] = Total_Score_of_player[8]
      • Set Save[1] = Total_Score_of_player[8]
      • Set Save[2] = double_kills_player[8]
      • Set Save[3] = triple_kills_player[8]
      • Set Save[4] = overkills_player[8]
      • Set Save[5] = killtaculars_player[8]
      • Set Save[6] = killtrocitys_player[8]
      • Set Save[7] = killinmanjaros_player[8]
      • Set SaveCount = 7
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Game - Display to Player Group - Player 8 (Pink) for 60.00 seconds the text: Code
      • Set Save[2] = double_kills_player[9]
      • Set Save[3] = triple_kills_player[9]
      • Set Save[4] = overkills_player[9]
      • Set Save[5] = killtaculars_player[9]
      • Set Save[6] = killtrocitys_player[9]
      • Set Save[7] = killinmanjaros_player[9]
      • Set SaveCount = 7
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Game - Display to Player Group - Player 9 (Gray) for 60.00 seconds the text: Code
      • Set Save[2] = double_kills_player[10]
      • Set Save[3] = triple_kills_player[10]
      • Set Save[4] = overkills_player[10]
      • Set Save[5] = killtaculars_player[10]
      • Set Save[6] = killtrocitys_player[10]
      • Set Save[7] = killinmanjaros_player[10]
      • Set SaveCount = 7
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Game - Display to Player Group - Player 10 (Light Blue) for 60.00 seconds the text: Code


the load trigger I used:

Trigger:
  • SaveLoad Load
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
      • Player - Player 2 (Blue) types a chat message containing -load as A substring
      • Player - Player 3 (Teal) types a chat message containing -load as A substring
      • Player - Player 4 (Purple) types a chat message containing -load as A substring
      • Player - Player 5 (Yellow) types a chat message containing -load as A substring
      • Player - Player 6 (Orange) types a chat message containing -load as A substring
      • Player - Player 7 (Green) types a chat message containing -load as A substring
      • Player - Player 8 (Pink) types a chat message containing -load as A substring
      • Player - Player 9 (Gray) types a chat message containing -load as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -load as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
      • (Length of (Entered chat string)) Greater than 6
    • Actions
      • -------- Try to decode what was typed --------
      • Set Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
      • Custom script: set udg_Validate = SaveLoad_Decode( udg_Code )
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Validate Equal to True
        • Then - Actions
          • For each (Integer A) from 1 to SaveCount, do (Actions)
            • Loop - Actions
              • Set Total_Score_of_player[(Integer A)] = Save[1]
              • Set double_kills_player[(Integer A)] = Save[2]
              • Set triple_kills_player[(Integer A)] = Save[3]
              • Set overkills_player[(Integer A)] = Save[4]
              • Set killtaculars_player[(Integer A)] = Save[5]
              • Set killtrocitys_player[(Integer A)] = Save[6]
              • Set killinmanjaros_player[(Integer A)] = Save[7]
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) the text: Invalid Code!


So the problem is that whenever I want to load my code it shows that it is an invalid code....

Now whenever I used this trigger it worked perfectly:
Trigger:
  • SaveLoad Save
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
      • Player - Player 2 (Blue) types a chat message containing -save as An exact match
      • Player - Player 3 (Teal) types a chat message containing -save as An exact match
      • Player - Player 4 (Purple) types a chat message containing -save as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -save as An exact match
      • Player - Player 6 (Orange) types a chat message containing -save as An exact match
      • Player - Player 7 (Green) types a chat message containing -save as An exact match
      • Player - Player 8 (Pink) types a chat message containing -save as An exact match
      • Player - Player 9 (Gray) types a chat message containing -save as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • -------- Those values need saving --------
      • Set Save[1] = Total_Score_of_player[(Player number of (Triggering player))]
      • Set Save[2] = double_kills_player[(Player number of (Triggering player))]
      • Set Save[3] = triple_kills_player[(Player number of (Triggering player))]
      • Set Save[4] = overkills_player[(Player number of (Triggering player))]
      • Set Save[5] = killtaculars_player[(Player number of (Triggering player))]
      • Set Save[6] = killtrocitys_player[(Player number of (Triggering player))]
      • Set Save[7] = killinmanjaros_player[(Player number of (Triggering player))]
      • Set Save[8] = killtastrophes_player[(Player number of (Triggering player))]
      • Set Save[9] = killpocalypses_player[(Player number of (Triggering player))]
      • Set Save[10] = killionaires_player[(Player number of (Triggering player))]
      • -------- The number of values we have --------
      • Set SaveCount = 10
      • -------- Turn values into code --------
      • Custom script: set udg_Code = SaveLoad_Encode()
      • -------- Show code to player --------
      • Quest - Display to (Player group((Triggering player))) the Secret message: Your code:
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code


but thats not what i want to accomplish... If someone can help me out on this he/she definitly deserves my rep and gratitude!
 

Executor

I see you
Reaction score
57
Trigger:
  • SaveLoad Load
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
      • Player - Player 2 (Blue) types a chat message containing -load as A substring
      • Player - Player 3 (Teal) types a chat message containing -load as A substring
      • Player - Player 4 (Purple) types a chat message containing -load as A substring
      • Player - Player 5 (Yellow) types a chat message containing -load as A substring
      • Player - Player 6 (Orange) types a chat message containing -load as A substring
      • Player - Player 7 (Green) types a chat message containing -load as A substring
      • Player - Player 8 (Pink) types a chat message containing -load as A substring
      • Player - Player 9 (Gray) types a chat message containing -load as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -load as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
      • (Length of (Entered chat string)) Greater than 6
    • Actions
      • -------- Try to decode what was typed --------
      • Set Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
      • Custom script: set udg_Validate = SaveLoad_Decode( udg_Code )
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Validate Equal to True
        • Then - Actions
          • For each (Integer A) from 1 to SaveCount, do (Actions)
            • Loop - Actions
              • Set Total_Score_of_player[(Integer A)] = Save[1]
              • Set double_kills_player[(Integer A)] = Save[2]
              • Set triple_kills_player[(Integer A)] = Save[3]
              • Set overkills_player[(Integer A)] = Save[4]
              • Set killtaculars_player[(Integer A)] = Save[5]
              • Set killtrocitys_player[(Integer A)] = Save[6]
              • Set killinmanjaros_player[(Integer A)] = Save[7]
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) the text: Invalid Code!


I don't know the system and I don't now how to use it I just able to conclude:

SaveLoad_Decode( udg_Code ) stores the loaded values in the array "Save".
These loaded values belong to the "Triggering Player". So I think you must delete this loop and only transfer the values from "Save" in the array of the "Triggering Player".

In my opinion "SaveCount" specifies the upper bound of the save array and not sth. like PlayerCount.
You should also check in your load condition whether SaveCount equals the number of values u stored.
 

LoveTD's

New Member
Reaction score
34
as I said before, the save and load trigger works fine, the problem is:
I cant seem to show a text message with the save code without having someone to type -save...

as you can see this is exactly the same:

Trigger:
  • Set Save[1] = Total_Score_of_player[1]
    • Set Save[2] = double_kills_player[1]
    • Set Save[3] = triple_kills_player[1]
    • Set Save[4] = overkills_player[1]
    • Set Save[5] = killtaculars_player[1]
    • Set Save[6] = killtrocitys_player[1]
    • Set Save[7] = killinmanjaros_player[1]
    • Set SaveCount = 7
    • Custom script: set udg_Code = SaveLoad_Encode()
    • Game - Display to Player Group - Player 1 (Red) for 60.00 seconds the text: Code


as this (but for some reason only this works...):
Trigger:
  • Set Save[1] = Total_Score_of_player[(Player number of (Triggering player))]
    • Set Save[2] = double_kills_player[(Player number of (Triggering player))]
    • Set Save[3] = triple_kills_player[(Player number of (Triggering player))]
    • Set Save[4] = overkills_player[(Player number of (Triggering player))]
    • Set Save[5] = killtaculars_player[(Player number of (Triggering player))]
    • Set Save[6] = killtrocitys_player[(Player number of (Triggering player))]
    • Set Save[7] = killinmanjaros_player[(Player number of (Triggering player))]
    • Set SaveCount = 7
    • Custom script: set udg_Code = SaveLoad_Encode()
    • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code


edit: also... As you can see I made a lot of mistakes in the end game trigger... But that doesn't matter since I was just testing if it worked for player 1...

Hmmm... I think I found the solution... In the jass script made by acehart he has a part that is like this:

JASS:
function SaveLoad_EncodeVerify takes string buffer returns integer
    local integer i = 0
    local integer j = 0
    local string name = GetPlayerName(GetTriggerPlayer())
    if udg_SaveLoad_UsePlayername == true then
        loop
            set j = j + SaveLoad_EncodeChar(SubString(name,i,i + 1))
            set i = i + 1
            exitwhen i &gt;= StringLength(name)
        endloop
    endif
    set i = 0
    loop
        set j = j + SaveLoad_EncodeChar(SubString(buffer,i,i + 1))
        set i = i + 1
        exitwhen i &gt;= StringLength(buffer)
    endloop
    return j
endfunction


maybe this part has to do something with validating the code ;)
local string name = GetPlayerName(GetTriggerPlayer())
it searches for a triggering player ><....
anyone knows how to change this in jass ^^?
should I use GetLocalPlayer? and if so, how do I make it so that it recognizes the name for all players?

EDIT: tryed it and fixed it :D
script:
JASS:
function SaveLoad_EncodeVerify takes string buffer returns integer
    local integer i = 0
    local integer j = 0
    local string name = GetPlayerName(GetLocalPlayer())
    if udg_SaveLoad_UsePlayername == true then
        loop
            set j = j + SaveLoad_EncodeChar(SubString(name,i,i + 1))
            set i = i + 1
            exitwhen i &gt;= StringLength(name)
        endloop
    endif
    set i = 0
    loop
        set j = j + SaveLoad_EncodeChar(SubString(buffer,i,i + 1))
        set i = i + 1
        exitwhen i &gt;= StringLength(buffer)
    endloop
    return j
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top