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

[Trigger] Need Helping fixing a Save/Load Code.

Status
Not open for further replies.
Level 8
Joined
Apr 8, 2009
Messages
499
Not too long ago i inserted a Save/Load system, Created by AceHeart.

Link to his Thread on the Save/Load System.

This System works perfectly. except for one little thing.

Whenever i save my hero, (with items) and i load it, only the first 2 items in his inventory will be loaded. the other 4 items the hero was (possibly) holding, are gone.

can anyone explain to me why?

my triggers:


  • SaveLoad Initialization All
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- List of Heroes --------
      • Set SaveLoad_Heroes[1] = Glaive Mistress
      • Set SaveLoad_Heroes[2] = Advanced Glaive Mistress
      • Set SaveLoad_Heroes[3] = Kunoichi
      • Set SaveLoad_Heroes[4] = Advanced Kunoichi
      • Set SaveLoad_Heroes[5] = Archer
      • Set SaveLoad_Heroes[6] = Advanced Archer
      • Set SaveLoad_Heroes[7] = Black Mage
      • Set SaveLoad_Heroes[8] = Advanced Black Mage
      • Set SaveLoad_Heroes[9] = Hunter
      • Set SaveLoad_Heroes[10] = Advanced Hunter
      • Set SaveLoad_Heroes[11] = SpellBlade
      • Set SaveLoad_Heroes[12] = Advanced SpellBlade
      • Set SaveLoad_Heroes[13] = Paladin
      • Set SaveLoad_Heroes[14] = Advanced Paladin
      • Set SaveLoad_Heroes[15] = Pirate
      • Set SaveLoad_Heroes[16] = Advanced Pirate
      • Set SaveLoad_Heroes[17] = Priestess
      • Set SaveLoad_Heroes[18] = Advanced Priestess
      • Set SaveLoad_Heroes[19] = Ranger
      • Set SaveLoad_Heroes[20] = Advanced Ranger
      • Set SaveLoad_Heroes[21] = Roque
      • Set SaveLoad_Heroes[22] = Advanced Rogue
      • Set SaveLoad_Heroes[23] = Summoner
      • Set SaveLoad_Heroes[24] = Advanced Summoner
      • Set SaveLoad_Heroes[25] = SwordFighter
      • Set SaveLoad_Heroes[26] = Advanced SwordFighter
      • Set SaveLoad_Heroes[27] = Wizzard
      • Set SaveLoad_Heroes[28] = Advanced Wizzard
      • -------- Number of Heroes --------
      • Set SaveLoad_Heroes_LastIndex = 28
      • -------- List of Items --------
      • Set SaveLoad_Items[1] = Healing Potion
      • Set SaveLoad_Items[2] = Mana Potion
      • Set SaveLoad_Items[3] = Minor healing potion
      • Set SaveLoad_Items[4] = Minor mana potion
      • Set SaveLoad_Items[5] = Large Mana Potion
      • Set SaveLoad_Items[6] = Large Healing Potion
      • Set SaveLoad_Items[7] = Lesser Elixer
      • Set SaveLoad_Items[8] = Elixer
      • Set SaveLoad_Items[9] = Large Elixer
      • Set SaveLoad_Items[10] = Potion of Haste
      • Set SaveLoad_Items[11] = Potion of Hardened Skin
      • Set SaveLoad_Items[12] = Advanced Arrows
      • Set SaveLoad_Items[13] = Advanced Battle Orb
      • Set SaveLoad_Items[14] = Advanced Life Orb
      • Set SaveLoad_Items[15] = Advanced Spirit Orb
      • Set SaveLoad_Items[16] = Basic Arrows
      • Set SaveLoad_Items[17] = Basic Battle Orb
      • Set SaveLoad_Items[18] = Basic Life Orb
      • Set SaveLoad_Items[19] = Basic Spirit Orb
      • Set SaveLoad_Items[20] = Templars Bracelet
      • Set SaveLoad_Items[21] = Templars Ring
      • Set SaveLoad_Items[22] = Templars Trinket
      • Set SaveLoad_Items[23] = Vampiric Trinket
      • Set SaveLoad_Items[24] = |c00000fffFrost Legions Arrows|r
      • Set SaveLoad_Items[25] = |c00000fffWolf Kings Spirit|r
      • Set SaveLoad_Items[26] = |c0000ff00Elite Wolf Token|r
      • Set SaveLoad_Items[27] = |c000fffffYmir's Spirit|r
      • Set SaveLoad_Items[28] = |c000fffffYmir's ice compressor|r
      • Set SaveLoad_Items[29] = |c00FF0000Dark Dragon Token|r
      • Set SaveLoad_Items[30] = |c00FF7F00Dark Wolf Token|r
      • Set SaveLoad_Items[31] = |c00FFFF00Elite Crystal Golem Token|r
      • Set SaveLoad_Items[32] = |c000fffffBasic Spirit Gem|r
      • Set SaveLoad_Items[33] = |c0096FF96Basic Life Gem|r
      • Set SaveLoad_Items[34] = Advanced Gloves
      • Set SaveLoad_Items[35] = Basic Gloves
      • Set SaveLoad_Items[36] = |c00000fffFrost Legions Gloves|r
      • Set SaveLoad_Items[37] = |c000fffffCrystal Cohort's Gloves|r
      • Set SaveLoad_Items[38] = Advanced Bow
      • Set SaveLoad_Items[39] = Advanced Bow [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[40] = Advanced Bow [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[41] = Advanced Dual Swords
      • Set SaveLoad_Items[42] = Advanced Dual Swords [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[43] = Advanced Dual Swords [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[44] = Advanced Glaives
      • Set SaveLoad_Items[45] = Advanced Glaives [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[46] = Advanced Glaives [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[47] = Advanced Halberd
      • Set SaveLoad_Items[48] = Advanced Halberd [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[49] = Advanced Halberd [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[50] = Advanced Hammer
      • Set SaveLoad_Items[51] = Advanced Hammer [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[52] = Advanced Hammer [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[53] = Advanced HandGun
      • Set SaveLoad_Items[54] = Advanced HandGun [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[55] = Advanced HandGun [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[56] = Advanced Knife
      • Set SaveLoad_Items[57] = Advanced Knife [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[58] = Advanced Knife [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[59] = Advanced Staff
      • Set SaveLoad_Items[60] = Advanced Staff [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[61] = Advanced Staff [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[62] = Advanced Sword
      • Set SaveLoad_Items[63] = Advanced Sword [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[64] = Advanced Sword [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[65] = Basic Bow
      • Set SaveLoad_Items[66] = Basic Dual Swords
      • Set SaveLoad_Items[67] = Basic Glaives
      • Set SaveLoad_Items[68] = Basic Halberd
      • Set SaveLoad_Items[69] = Basic Hammer
      • Set SaveLoad_Items[70] = Basic HandGun
      • Set SaveLoad_Items[71] = Basic Knife
      • Set SaveLoad_Items[72] = Basic Staff
      • Set SaveLoad_Items[73] = Basic Sword
      • Set SaveLoad_Items[74] = |c00000fffFrost Legions Bow|r
      • Set SaveLoad_Items[75] = |c00000fffFrost Legions Dual Swords|r
      • Set SaveLoad_Items[76] = |c00000fffFrost Legions Glaives|r
      • Set SaveLoad_Items[77] = |c00000fffFrost Legions Halberd|r
      • Set SaveLoad_Items[78] = |c00000fffFrost Legions Hammer|r
      • Set SaveLoad_Items[79] = |c00000fffFrost Legions HandGun|r
      • Set SaveLoad_Items[80] = |c00000fffFrost Legions Knife|r
      • Set SaveLoad_Items[81] = |c00000fffFrost Legions Staff|r
      • Set SaveLoad_Items[82] = |c00000fffFrost Legions Sword|r
      • Set SaveLoad_Items[83] = |c000fffffCrystal Cohort's Bow|r
      • Set SaveLoad_Items[84] = |c000fffffCrystal Cohort's Dual Blades|r
      • Set SaveLoad_Items[85] = |c000fffffCrystal Cohort's Glaives|r
      • Set SaveLoad_Items[86] = |c000fffffCrystal Cohort's Halberd|r
      • Set SaveLoad_Items[87] = |c000fffffCrystal Cohort's Hammer|r
      • Set SaveLoad_Items[88] = |c000fffffCrystal Cohort's HandGun|r
      • Set SaveLoad_Items[89] = |c000fffffCrystal Cohort's Knife|r
      • Set SaveLoad_Items[90] = |c000fffffCrystal Cohort's Staff|r
      • Set SaveLoad_Items[91] = |c000fffffCrystal Cohort's Sword|r
      • Set SaveLoad_Items[92] = Advanced Boots
      • Set SaveLoad_Items[93] = Basic Boots
      • Set SaveLoad_Items[94] = |c00000fffFrost Legions Boots|r
      • Set SaveLoad_Items[95] = |c000fffffCrystal Cohort's Boots|r
      • Set SaveLoad_Items[96] = Advanced Leather Cuiras
      • Set SaveLoad_Items[97] = Advanced Leather Cuiras [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[98] = Advanced Leather Cuiras [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[99] = Advanced Mage Cloak
      • Set SaveLoad_Items[100] = Advanced Mage Cloak [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[101] = Advanced Mage Cloak [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[102] = Advanced Plate Armor
      • Set SaveLoad_Items[103] = Advanced Plate Armor [Socketed - |c0000ff00Life Gem|r]
      • Set SaveLoad_Items[104] = Advanced Plate Armor [Socketed - |c000fffffSpirit Gem|r]
      • Set SaveLoad_Items[105] = Basic Leather Cuiras
      • Set SaveLoad_Items[106] = Basic Mage Cloak
      • Set SaveLoad_Items[107] = Basic Plate Armor
      • Set SaveLoad_Items[108] = |c00000fffFrost Legions Leather Armor|r
      • Set SaveLoad_Items[109] = |c00000fffFrost Legions Mantle|r
      • Set SaveLoad_Items[110] = |c00000fffFrost Legions Plate Armor|r
      • Set SaveLoad_Items[111] = |c000fffffCrystal Cohort's Leather Armor|r
      • Set SaveLoad_Items[112] = |c000fffffCrystal Cohort's Mantle|r
      • Set SaveLoad_Items[113] = |c000fffffCrystal Cohort's Plate Armor|r
      • -------- Number of Items --------
      • Set SaveLoad_Items_LastIndex = 113
      • -------- List of Abilities --------
      • Set SaveLoad_Abilities[1] = Banish
      • Set SaveLoad_Abilities[2] = Flame Strike
      • Set SaveLoad_Abilities[3] = Phoenix
      • Set SaveLoad_Abilities[4] = Siphon Mana
      • -------- Number of Abilities --------
      • Set SaveLoad_Abilities_LastIndex = 4
      • -------- These three lines may be changed if needed --------
      • Set SaveLoad_Alphabet = abcdefghijklmnopqrstuvwxyz0123456789
      • Set SaveLoad_CaseSensitive = True
      • Set SaveLoad_UsePlayername = True
      • -------- Required: false --------
      • Set SaveLoad_Initialized = False
      • -------- Leave as is. Used to autocreate variables when copy & pasting to a new map --------
      • Set Code = AceHart
      • Set Save[1] = 0
      • Set SaveCount = 1
      • Set Validate = False
      • Set SaveLoad_Compress[1] = 0
      • Set SaveLoad_Uncompress[1] = 0
  • SaveLoad Save Hero P Property
    • 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
    • Conditions
    • Actions
      • -------- Prepare the save array with this player's Hero --------
      • Set SaveCount = 0
      • -------- Player's Gold --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • -------- Player's Lumber --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current lumber)
      • -------- Take all Heroes --------
      • Set UnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = (Number of units in UnitGroup)
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • -------- Save the Hero --------
          • Set SaveCount = (SaveCount + 1)
          • Set TempUnit = (Picked unit)
          • Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
          • -------- Hero Experience --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Hero experience of (Picked unit))
          • -------- How many items does he carry --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Number of items carried by (Picked unit))
          • -------- Add all items --------
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Item carried by (Picked unit) in slot (Integer A)) is owned) Equal to True
                • Then - Actions
                  • -------- The actual item --------
                  • Set SaveCount = (SaveCount + 1)
                  • Set TempItem = (Item carried by (Picked unit) in slot (Integer A))
                  • Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
                  • -------- The number of charges it has --------
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot (Integer A)))
                • Else - Actions
      • -------- 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
  • SaveLoad Load Hero P Property
    • 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
    • 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 False
        • Then - Actions
          • -------- Invalid code --------
          • Game - Display to (Player group((Triggering player))) the text: There's some error ...
          • Skip remaining actions
        • Else - Actions
      • -------- It worked, let's do something with it --------
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Set SaveCount = 1
      • -------- Restore Gold --------
      • Player - Set (Triggering player) Current gold to Save[SaveCount]
      • Set SaveCount = (SaveCount + 1)
      • -------- Restore Lumber --------
      • Player - Set (Triggering player) Current lumber to Save[SaveCount]
      • -------- For "number of Heroes", do --------
      • Set SaveCount = (SaveCount + 1)
      • For each (Integer B) from 1 to Save[SaveCount], do (Actions)
        • Loop - Actions
          • -------- Restore Hero --------
          • Set SaveCount = (SaveCount + 1)
          • Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
          • Unit - Create 1 TempUnitType for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
          • -------- Set Experience --------
          • Set SaveCount = (SaveCount + 1)
          • Hero - Set (Last created unit) experience to Save[SaveCount], Hide level-up graphics
          • -------- Recreate all items --------
          • Set SaveCount = (SaveCount + 1)
          • For each (Integer A) from 1 to Save[SaveCount], do (Actions)
            • Loop - Actions
              • -------- The actual item --------
              • Set SaveCount = (SaveCount + 1)
              • Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
              • Hero - Create TempItemType and give it to (Last created unit)
              • -------- Number of charges --------
              • Set SaveCount = (SaveCount + 1)
              • Item - Set charges remaining in (Last created item) to Save[SaveCount]
 
Last edited:
Level 7
Joined
Jun 6, 2010
Messages
224
so it doesnt load all the items?
Then it's a thread crash.
If you overload a function with too many calls or try to calculate a null value, the thread crashes, exiting the function.
Basically this happens the most in GUI.

Can you show me the trigger where you load your items?
 
Level 8
Joined
Apr 8, 2009
Messages
499
so it doesnt load all the items?
Then it's a thread crash.
If you overload a function with too many calls or try to calculate a null value, the thread crashes, exiting the function.
Basically this happens the most in GUI.

Can you show me the trigger where you load your items?

posted them in my first post.

hope you can help me ;O
 
Last edited:
Level 7
Joined
Jun 6, 2010
Messages
224
Dear Animoi666
it comes to my attention that you've done yourself a 'possible' mistake in your trigger

You loop through your
For loop Integer B ( 1 to SaveCount)
and at the same team within the loops you increase your SaveCount variable

basically your looping is one big bomb.
You need to make it more efficient.
Create 2 seperate integer variablesm Loop1 and Loop2
set Loop1 = SaveCount
and then call the first loop
that goes for the second.

hit me back when you do it
 
Level 8
Joined
Apr 8, 2009
Messages
499
Dear Animoi666
it comes to my attention that you've done yourself a 'possible' mistake in your trigger

You loop through your
For loop Integer B ( 1 to SaveCount)
and at the same team within the loops you increase your SaveCount variable

basically your looping is one big bomb.
You need to make it more efficient.
Create 2 seperate integer variablesm Loop1 and Loop2
set Loop1 = SaveCount
and then call the first loop
that goes for the second.

hit me back when you do it

uhm... i dont fully understand what you mean :O.

i made 2 integer vars, loop1 & loop2

then what? could you post it in trigger taggs? would be really helpfull ^^

thank you very much if you do.
 
Status
Not open for further replies.
Top