• 🏆 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] Serious Trigger Problem

Status
Not open for further replies.
Level 4
Joined
Dec 4, 2010
Messages
63
To anyone can identify the main cause of the problem please help me, i cant determine because i dont have enough knowledge to understand vjass,jass and other programming language, first of all is the main script at first its all fine working but when i add it another function heres the script.

JASS:
function CodeGen_Init takes nothing returns nothing
    set udg_SaveLoad_Char     = SubString(udg_SaveLoad_Alphabet, 0, 1)
    set udg_SaveLoad_Alphabet = SubString(udg_SaveLoad_Alphabet, 1, 999)
    set udg_SaveLoad_Base     = udg_SaveLoad_Base - 1
endfunction

function CodeGen_ConvertItem takes integer id returns integer
    local integer i = 1
    loop
        exitwhen i > udg_SaveLoad_ItemCount
        if (id == udg_SaveLoad_Item[i]) then
            return i
        endif
        set i = i + 1
    endloop
    return 0
endfunction

function CodeGen_ConvertUnit takes integer id returns integer
    local integer i = 1
    loop
        exitwhen i > udg_SaveLoad_PetCount
        if (id == udg_SaveLoad_Pet[i]) then
            return i
        endif
        set i = i + 1
    endloop
    return 0
endfunction

function CodeGen_ConvertUnit takes integer id returns integer
    local integer i = 1
    loop
        exitwhen i > udg_SaveLoad_HeroCount
        if (id == udg_SaveLoad_Hero[i]) then
            return i
        endif
        set i = i + 1
    endloop
    return 0
endfunction

function CodeGen_Encode takes integer i returns string
    local integer b
    local string s = ""
    
    if i < udg_SaveLoad_Base then
        return SubString(udg_SaveLoad_Alphabet, i, i + 1)
    endif
    
    loop
        exitwhen i <= 0
        set b = i - (i / udg_SaveLoad_Base) * udg_SaveLoad_Base
        set s = SubString(udg_SaveLoad_Alphabet, b, b + 1) + s
        set i = i / udg_SaveLoad_Base
    endloop
    return s
endfunction

function CodeGen_StrPos takes string s returns integer
    local integer i = 0
    loop
        exitwhen i > udg_SaveLoad_Base
        if s == SubString(udg_SaveLoad_Alphabet, i, i + 1) then
            return i
        endif
        set i = i + 1
    endloop
    return -1
endfunction

function CodeGen_Alphabet takes string s returns integer
    local integer i = 0
    local string x  = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    local integer b = StringLength(x)
    loop
        exitwhen i > b
        if s == SubString(x, i, i + 1) then
            return i
        endif
        set i = i + 1
    endloop
    return -1
endfunction

function CodeGen_Decode takes string s returns integer
    local integer a = 0
    
    loop
        exitwhen StringLength(s) == 1
        set a = a * udg_SaveLoad_Base + udg_SaveLoad_Base * CodeGen_StrPos(SubString(s, 0, 1))
        set s = SubString(s, 1, 50)
    endloop
    
    return a+CodeGen_StrPos(s)
endfunction

function CodeGen_String takes string s returns integer
     local integer i = 0
     local integer x = StringLength(s)
     local integer z = 0
     
     loop
        exitwhen i > x
        set z = z + CodeGen_Alphabet(SubString(s, i, i + 1))
        set i = i + 1
    endloop
    
    return z
endfunction

function CodeGen_Color takes string char returns string
    local integer i = 0
    local string s  = udg_SaveLoad_Alphabet + udg_SaveLoad_Char
    local string x  = ""
    loop
        exitwhen i > udg_SaveLoad_Base+1
        set x = SubString(s, i, i + 1)
        if char == x then
            if (x=="0"or x=="1"or x=="2"or x=="3"or x=="4"or x=="5"or x=="6"or x=="7"or x=="8"or x=="9"or x=="10") then
                return udg_SaveLoad_Number + char + "|r"
            elseif StringCase(x, false) == x then
                return udg_SaveLoad_Lower + char + "|r"
            elseif StringCase(x, true) == x then
                return udg_SaveLoad_Upper + char + "|r"
            endif
        endif
        set i = i + 1
    endloop
    return char
endfunction

function CodeGen_Format takes string s returns string
    local integer i = 0
    local integer x = StringLength(s)
    local integer j = 1
    local string s2 = ""
    
    if (x <= udg_SaveLoad_HyphenSpace) then
        return s
    endif
    
    loop
        exitwhen i >= x
        
        set s2 = s2 + CodeGen_Color(SubString(s, i, i + 1))
        
        if (j >= udg_SaveLoad_HyphenSpace and i != (x-1)) then
            set j = 0
            set s2 = s2 + "-"
        endif
        
        set j = j + 1
        set i = i + 1
    endloop
    
    return s2
endfunction

function CodeGen_Strip takes string s  returns string
    local integer i  = 0
    local integer x  = StringLength(s)
    local string out = ""
    local string a   = ""
    
    loop
        exitwhen i > x
        set a = SubString(s, i, i + 1)
        if not (a == "-") then
            set out = out + a
        endif
        set i = i + 1
    endloop
    
    return out
endfunction

function CodeGen_Load takes string s returns nothing
    local integer i = 0
    local integer r = 0
    local integer x = 0
    local integer j = 0
    local integer b = 0
    
    set s = CodeGen_Strip(s)
    set x = StringLength(s)
    
    set j = CodeGen_Decode(SubString(s, x - 1, x))
    set r = CodeGen_Decode(SubString(s, x - j - 1, x - 1))
    set s = SubString(s, 0, x - j - 1)
    
    if (r != CodeGen_String(s)) then
        set udg_SaveLoad_Valid = false
        return
    endif
    
    set x = CodeGen_String(GetPlayerName(GetTriggerPlayer()))
    
    set udg_SaveLoad_Valid = true

    
    if (udg_SaveLoad_CheckName) then
        if not (CodeGen_Decode(SubString(s, 0, 2)) == x) then
            if not (CodeGen_Decode(SubString(s, 0, 1)) == x) then
                set udg_SaveLoad_Valid = false
                return
            else
                set s = SubString(s, 1, 999)
            endif
        else
            set s = SubString(s, 2, 999)
        endif
    endif
    
    set j = StringLength(s)
    set x = 0
    
    loop
        exitwhen i == j
        if (SubString(s, i, i + 1) == udg_SaveLoad_Char) then
            set b = CodeGen_Decode(SubString(s, i + 1, i + 2))
            set udg_Load[x] = CodeGen_Decode(SubString(s, i + 2, i + (b + 2)))
            set i = i + b + 1
        else
            set udg_Load[x] = CodeGen_Decode(SubString(s, i, i + 1))
        endif
        set x = x + 1
        set i = i + 1
    endloop
    
endfunction

function CodeGen_Compile takes nothing returns string
    local integer i  = 0
    local integer j  = 0
    local string out = ""
    local string ln  = ""
    local string x   = ""
    
    if (udg_SaveLoad_CheckName) then
        set out = out + CodeGen_Encode(CodeGen_String(GetPlayerName(GetTriggerPlayer())))
    endif
    
    loop
        exitwhen i == udg_SaveCount
        set x = CodeGen_Encode(udg_Save[i])

        set j = StringLength(x)

        if (j > 1) then
            set out = out + udg_SaveLoad_Char + CodeGen_Encode(j)
        endif

        set out = out + x
        set i = i + 1
    endloop

    set x = CodeGen_Encode(CodeGen_String(out))
    return CodeGen_Format(out + x + CodeGen_Encode(StringLength(x)))
endfunction

The added function is

JASS:
function CodeGen_ConvertUnit takes integer id returns integer
    local integer i = 1
    loop
        exitwhen i > udg_SaveLoad_PetCount
        if (id == udg_SaveLoad_Pet[i]) then
            return i
        endif
        set i = i + 1
    endloop
    return 0
endfunction

i added it to balance the save/load system i used;IGEN i know its simple, its simple enough to understand to people who have low knowledge to other types of languages,

here's the problem, the system works fine without the function above i added to save the pet but when i load the character it loads other type of pet and not the original one the used in saving, so i added that function whether i dont really know what will happen. whenever i add that function to the main script, it cannot played thru warcraft3 even single player or multiplayer, it just blank, you cant select your team and start the game, the map is only 7mb, so i realize the problem is on the script itself.

Here's the triggers of save/load system i used and may help.

  • SaveLoad Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Some configurables --------
      • Set SaveLoad_Alphabet = aA5bB0cCdDeE9fFgGhH8iIj1JkK4lLmMn7NoOp3PqQrRsStTu2UvV6wWxXyYzZ
      • Set SaveLoad_CheckName = True
      • Set SaveLoad_HyphenSpace = 4
      • Set SaveLoad_Lower = |c002a4580
      • Set SaveLoad_Number = |cffffcc00
      • Set SaveLoad_Upper = |cff1142aa
      • -------- Store all the items you want to be able to be saved below. --------
      • -------- ------Osmos--------- --------
      • Set SaveLoad_Item[1] = Boots of Speed
      • Set SaveLoad_Item[2] = Potion of Healing
      • Set SaveLoad_Item[3] = Potion of Mana
      • Set SaveLoad_Item[4] = Scroll of Healing
      • Set SaveLoad_Item[5] = Scroll of Mana
      • Set SaveLoad_Item[6] = Enchanted Shield
      • Set SaveLoad_Item[7] = Claws of Attack +6
      • Set SaveLoad_Item[8] = Claws of Attack +9
      • Set SaveLoad_Item[9] = Claws of Attack +12
      • -------- ------Laston--------- --------
      • Set SaveLoad_Item[10] = Azune Orb
      • Set SaveLoad_Item[11] = Lightning Bolt
      • -------- ------Tonio--------- --------
      • Set SaveLoad_Item[12] = Light Knife
      • Set SaveLoad_Item[13] = Staff Bon'jin
      • Set SaveLoad_Item[15] = Axe Of Retsu
      • Set SaveLoad_Item[14] = Great Mighty Shield
      • Set SaveLoad_Item[16] = Battle Hammer
      • Set SaveLoad_Item[17] = Mega Guard
      • Set SaveLoad_Item[18] = Heat Amulet
      • Set SaveLoad_Item[19] = Firehand Gauntlets
      • Set SaveLoad_Item[20] = Shaman Claws
      • -------- ------Lonika--------- --------
      • Set SaveLoad_Item[21] = Power Orb
      • Set SaveLoad_Item[22] = Great Orb Of Life
      • Set SaveLoad_Item[23] = Darklord's Mighty Orb
      • Set SaveLoad_Item[24] = Holy Staff of Bon'jin
      • Set SaveLoad_Item[25] = Almighty Power
      • Set SaveLoad_Item[26] = Orb of Venom
      • Set SaveLoad_Item[65] = Almighty Power II
      • -------- ------Furion--------- --------
      • Set SaveLoad_Item[27] = Shadow's Essence (P)
      • Set SaveLoad_Item[28] = Summoner's Essence (N)
      • Set SaveLoad_Item[29] = Naga Royal Guard's Essence (N)
      • Set SaveLoad_Item[30] = Mountain Giant's Essence (N)
      • -------- ------Medivc--------- --------
      • Set SaveLoad_Item[31] = Almighty Power III
      • Set SaveLoad_Item[32] = Almighty Power IV
      • Set SaveLoad_Item[33] = |c0000ccccAlmighty Power V|r
      • Set SaveLoad_Item[34] = Increate Explosion
      • Set SaveLoad_Item[35] = Lightning Strike
      • Set SaveLoad_Item[66] = Angelwing Boots
      • -------- ------Divine Frog--------- --------
      • Set SaveLoad_Item[36] = Scroll Of |cff32cd32Z Reaver|r
      • Set SaveLoad_Item[37] = Scroll Of |cff3366ffY Caster|r
      • Set SaveLoad_Item[38] = Scroll Of |cffff0000X Slasher|r
      • Set SaveLoad_Item[39] = |cff32cd32Z Reaver|r
      • Set SaveLoad_Item[40] = |cff3366ffY Caster|r
      • Set SaveLoad_Item[41] = |cffff0000X Slasher|r
      • Set SaveLoad_Item[42] = Divine God Transformation
      • Set SaveLoad_Item[43] = Darklord Transformation
      • Set SaveLoad_Item[44] = Dark Lord's Essence (EP)
      • Set SaveLoad_Item[45] = Divine God's Essence (EP)
      • Set SaveLoad_Item[46] = |c0000ccccAlmighty V Scroll|r
      • -------- God --------
      • Set SaveLoad_Item[47] = God's Orb
      • -------- Medals --------
      • Set SaveLoad_Item[48] = Archmage's Medal
      • Set SaveLoad_Item[49] = Beastmaster's Medal
      • Set SaveLoad_Item[50] = Blademaster's Medal
      • Set SaveLoad_Item[51] = Dark Ranger's Medal
      • Set SaveLoad_Item[52] = Death Knight's Medal
      • Set SaveLoad_Item[53] = Demon Hunters's Medal
      • Set SaveLoad_Item[54] = Icelord's Medal
      • Set SaveLoad_Item[55] = Keeper of the Grove's Medal
      • Set SaveLoad_Item[56] = Lich's Medal
      • Set SaveLoad_Item[57] = Murloc Nightcrawler's Medal
      • Set SaveLoad_Item[58] = Paladin's Medal
      • Set SaveLoad_Item[59] = Priestess of the Moon's Medal
      • Set SaveLoad_Item[60] = Shadow Hunter's Medal
      • Set SaveLoad_Item[61] = Warden's Medal
      • -------- chapion medals --------
      • Set SaveLoad_Item[62] = Champion Of Knowledge Medal
      • Set SaveLoad_Item[63] = Champion Of Power Medal
      • Set SaveLoad_Item[64] = Champion Of Speed Medal
      • -------- ------Powerups and others--------- --------
      • Set SaveLoad_Item[67] = Craft |c0000ccccFrostmoure|r
      • Set SaveLoad_Item[68] = Craft |c0000ccccDual Frostmoure|r
      • Set SaveLoad_Item[69] = |c0000ccccThe Frostmoure|r
      • Set SaveLoad_Item[70] = |c0000ccccThe Great Dual Frostmoure|r
      • Set SaveLoad_Item[71] = |c0000ccccThe Great Dual Frostmoure + 1|r
      • Set SaveLoad_Item[72] = |c0000ccccThe Great Dual Frostmoure + 2|r
      • Set SaveLoad_Item[73] = |c0000ccccThe Great Dual Frostmoure + 3|r
      • Set SaveLoad_Item[74] = |c0000ccccThe Great Dual Frostmoure + 4|r
      • Set SaveLoad_Item[75] = |c0000ccccThe Great Dual Frostmoure + 5|r
      • Set SaveLoad_Item[76] = |c0000ccccThe Great Dual Frostmoure + 6|r
      • Set SaveLoad_Item[77] = |c0000ccccThe Great Dual Frostmoure + 7|r
      • Set SaveLoad_Item[78] = |c0000ccccThe Great Dual Frostmoure + 8|r
      • Set SaveLoad_Item[79] = |c0000ccccThe Great Dual Frostmoure + 9|r
      • Set SaveLoad_Item[80] = |c0000ccccThe Great Dual Frostmoure + 10|r
      • Set SaveLoad_Item[81] = |c0000ccccThe Great Dual Frostmoure EX|r
      • Set SaveLoad_Item[82] = |c0000ccccAlmighty Power V + 1|r
      • Set SaveLoad_Item[83] = |c0000ccccAlmighty Power V + 2|r
      • Set SaveLoad_Item[84] = |c0000ccccAlmighty Power V + 3|r
      • Set SaveLoad_Item[85] = |c0000ccccAlmighty Power V + 4|r
      • Set SaveLoad_Item[86] = |c0000ccccAlmighty Power V + 5|r
      • Set SaveLoad_Item[87] = |c0000ccccAlmighty Power V + 6|r
      • Set SaveLoad_Item[88] = |c0000ccccAlmighty Power V + 7|r
      • Set SaveLoad_Item[89] = |c0000ccccAlmighty Power V + 8|r
      • Set SaveLoad_Item[90] = |c0000ccccAlmighty Power V + 9|r
      • Set SaveLoad_Item[91] = |c0000ccccAlmighty Power V + 10|r
      • Set SaveLoad_Item[92] = |c0000ccccAlmighty Power V EX|r
      • -------- ------Powerups ingreadients--------- --------
      • Set SaveLoad_Item[93] = Dark Crystal
      • Set SaveLoad_Item[94] = Chaos Emerald
      • Set SaveLoad_Item[95] = X Emerald
      • Set SaveLoad_Item[96] = Enigma Stone
      • Set SaveLoad_Item[97] = Maximus
      • Set SaveLoad_Item[98] = Powerup
      • -------- ------Medics 2--------- --------
      • Set SaveLoad_Item[99] = Scroll Of Hand Of The Hell
      • Set SaveLoad_Item[100] = Scroll Of Infernal Fire
      • Set SaveLoad_Item[101] = Hand Of The Hell
      • Set SaveLoad_Item[102] = Infernal Fire
      • Set SaveLoad_ItemCount = 102
      • -------- Store all the heroes you want to be able to be saved below. --------
      • Set SaveLoad_Hero[1] = Shadow
      • Set SaveLoad_Hero[2] = Mountain Giant
      • Set SaveLoad_Hero[3] = Naga Royal Guard
      • Set SaveLoad_Hero[4] = Sea Summoner
      • Set SaveLoad_Hero[5] = |cffffcc00Divine God|r
      • Set SaveLoad_Hero[6] = Darklord
      • -------- 1st heroes --------
      • Set SaveLoad_Hero[7] = Paladin
      • Set SaveLoad_Hero[8] = Archmage
      • Set SaveLoad_Hero[9] = Blademaster
      • Set SaveLoad_Hero[10] = Shadow Hunter
      • Set SaveLoad_Hero[11] = Death Knight
      • Set SaveLoad_Hero[12] = Lich
      • Set SaveLoad_Hero[13] = Keeper of the Grove
      • Set SaveLoad_Hero[14] = Priestess of the Moon
      • Set SaveLoad_Hero[15] = Demon Hunter
      • Set SaveLoad_Hero[16] = Warden
      • Set SaveLoad_Hero[17] = Beastmaster
      • Set SaveLoad_Hero[18] = Dark Ranger
      • Set SaveLoad_Hero[19] = Murloc Nightcrawler
      • Set SaveLoad_Hero[20] = Icelord
      • Set SaveLoad_HeroCount = 20
      • -------- Save pet --------
      • Set SaveLoad_Pet[1] = Chicken
      • Set SaveLoad_Pet[2] = Dog
      • Set SaveLoad_Pet[3] = Boar
      • Set SaveLoad_Pet[4] = Lizard
      • Set SaveLoad_Pet[5] = Grizzle
      • Set SaveLoad_Pet[6] = Raccoon
      • Set SaveLoad_Pet[7] = Dire Wolf
      • Set SaveLoad_Pet[8] = Satyr
      • Set SaveLoad_Pet[9] = Bladelord
      • Set SaveLoad_Pet[10] = Doom Beast
      • Set SaveLoad_Pet[11] = Lava Colossus
      • Set SaveLoad_Pet[12] = Murloc hunter
      • Set SaveLoad_Pet[13] = Murloc supreme
      • Set SaveLoad_Pet[14] = Shadow Fiend
      • Set SaveLoad_Pet[15] = Snowmannn
      • Set SaveLoad_Pet[16] = Webspiner
      • Set SaveLoad_PetCount = 16
      • -------- Don't modify below this line. --------
      • Set SaveLoad_Base = (Length of SaveLoad_Alphabet)
      • Set SaveLoad_Char = <Empty String>
      • Set Load[0] = 0
      • Set LoadCount = 0
      • Custom script: call CodeGen_Init()

  • SaveLoad Save1
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • -------- Find the players hero, and save it. I realize it leaks but it's just for demonstration. --------
      • Set SaveCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Set Hero = (Picked unit))
      • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit(GetUnitTypeId(udg_Hero))
      • Set SaveCount = (SaveCount + 1)
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A ground unit) Equal to True)) and do (Set Pet = (Picked unit))
      • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit(GetUnitTypeId(udg_Pet))
      • -------- Save players gold. --------
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save players lumber. --------
      • Set Save[SaveCount] = ((Triggering player) Current lumber)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save heroes EXP. --------
      • Set Save[SaveCount] = (Hero experience of Hero)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save heroes items. --------
      • Set Save[SaveCount] = (Number of items carried by Hero)
      • For each (Integer Integer_A_Replacement) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by Hero in slot Integer_A_Replacement)) Not equal to (Item-type of No item)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement)) Greater than 0
                • Then - Actions
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = 1
                  • Set SaveCount = (SaveCount + 1)
                  • Set Item = (Item carried by Hero in slot Integer_A_Replacement)
                  • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement))
                • Else - Actions
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = 2
                  • Set SaveCount = (SaveCount + 1)
                  • Set Item = (Item carried by Hero in slot Integer_A_Replacement)
                  • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
                  • Set SaveCount = (SaveCount + 1)
            • Else - Actions
              • Set SaveCount = (SaveCount + 1)
              • Set Save[SaveCount] = 0
              • Set SaveCount = (SaveCount + 2)
      • Set SaveCount = (SaveCount + 1)
      • -------- Show Code --------
      • Custom script: set udg_Code = CodeGen_Compile()
      • Cinematic - Clear the screen of text messages for (All players)
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
      • Trigger - Turn off (This trigger)
      • Game - Display to (Player group((Triggering player))) for 30.00 seconds the text: Warning: You can on...
  • SaveLoad Load1
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -load
    • Actions
      • -------- Check if load is valid --------
      • Set Code = (Substring((Entered chat string), 7, 999))
      • Custom script: call CodeGen_Load(udg_Code)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SaveLoad_Valid Equal to False
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: Invalid code.
          • Skip remaining actions
        • Else - Actions
      • -------- Start loading, load the hero first. --------
      • Set LoadCount = 0
      • Unit - Create 1 SaveLoad_Hero[Load[LoadCount]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
      • Set Hero = (Last created unit)
      • Set PETOwner = (Last created unit)
      • Set PETOwnerLoc = (Position of PETOwner)
      • Selection - Select (Last created unit) for (Triggering player)
      • Unit - Create 1 SaveLoad_Pet[Load[LoadCount]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
      • Set PETDummy[(Player number of (Owner of PETOwner))] = (Last created unit)
      • Unit - Order PETDummy[(Player number of (Owner of PETOwner))] to Right-Click PETOwner
      • -------- Now load players gold --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current gold to Load[LoadCount]
      • -------- Now load players Lumber --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current lumber to Load[LoadCount]
      • -------- Load heroes EXP --------
      • Set LoadCount = (LoadCount + 1)
      • Hero - Set Hero experience to Load[LoadCount], Hide level-up graphics
      • -------- Now items --------
      • Set LoadCount = (LoadCount + 1)
      • For each (Integer Integer_A_Replacement) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set LoadCount = (LoadCount + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Load[LoadCount] Not equal to 0
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Load[LoadCount] Equal to 1
                • Then - Actions
                  • Set LoadCount = (LoadCount + 1)
                  • Hero - Create SaveLoad_Item[Load[LoadCount]] and give it to Hero
                  • Set LoadCount = (LoadCount + 1)
                  • Item - Set charges remaining in (Last created item) to Load[LoadCount]
                • Else - Actions
                  • Set LoadCount = (LoadCount + 1)
                  • Hero - Create SaveLoad_Item[Load[LoadCount]] and give it to Hero
                  • Set LoadCount = (LoadCount + 1)
            • Else - Actions
              • Set LoadCount = (LoadCount + 2)
Please help me, i dont really know what to do, if you have questions pm me.

PS: To anyone can help me even a little is deserve for a +rep
 
Last edited:
This:
JASS:
function CodeGen_ConvertUnit takes integer id returns integer
    local integer i = 1
    loop
        exitwhen i > udg_SaveLoad_PetCount
        if (id == udg_SaveLoad_Pet[i]) then
            return i
        endif
        set i = i + 1
    endloop
    return 0
endfunction

function CodeGen_ConvertUnit takes integer id returns integer
    local integer i = 1
    loop
        exitwhen i > udg_SaveLoad_HeroCount
        if (id == udg_SaveLoad_Hero[i]) then
            return i
        endif
        set i = i + 1
    endloop
    return 0
endfunction

Should bring up an error because you can't have two functions with the same name. (unless you use encapsulation, but that is converted into unique names anyway)

Change the name of the custom function you made, and then change it for the lines you've used it in. Then it should allow the map to be loaded.

Sometimes if a map script is too big, I think pjass might miss some of that stuff, or at least it has for me.
 
Level 4
Joined
Dec 4, 2010
Messages
63
Should bring up an error because you can't have two functions with the same name. (unless you use encapsulation, but that is converted into unique names anyway)

Change the name of the custom function you made, and then change it for the lines you've used it in. Then it should allow the map to be loaded.

Sometimes if a map script is too big, I think pjass might miss some of that stuff, or at least it has for me.

Thanks, i helps but what do you mean "and then change it for the lines you've used it in" sorry but i didn't really get it. anyway you help me alot +rep
 
Basically, if you rename this:
JASS:
function CodeGen_ConvertUnit takes integer id returns integer
To something like:
JASS:
function CodeGen_ConvertUnit_New takes integer id returns integer

You would change the lines in your GUI code to fit that. So for example, you have this line:
  • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit(GetUnitTypeId(udg_Pet))
If you want it to use your new function, you would change it to:
  • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit_New(GetUnitTypeId(udg_Pet))
 
Level 4
Joined
Dec 4, 2010
Messages
63
oh i get it thanks, and i have a new problem.. but if you dont have time its ok your time is important. here, whenever i load a character with a pet i loads different instead of the original, i know it will been hard but you can try, i try it already many times but it always failed.

anyway thanks Purge,
 
Level 17
Joined
Jul 17, 2011
Messages
1,864
if it loads a different pet make sure you are not changing the id of the pet or the variable to which the id is assigned this can happen when you mix gui and jass because gui player indexes start from 1 and jass indexes from 0
your pet array index starts from 1 not 0 like it should change the index to start from 0 and it might work
 
Status
Not open for further replies.
Top