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

[JASS] Changing info on Save File from Save/load system

Level 11
Joined
Aug 11, 2009
Messages
594
Hello!
I have this save/load system which in the map header (or whatever its called) has a custom script which I believe creates the save file. There are two things I would like to change if its possible.

1. Change the file name to inclue the Heroes proper name that is shown above the XP bar.

For example, a test save can look like this: "WorldEdit_1_1104062033.txt".
I would prefer it to look maybe like this: "WorldEdit_HeroName_1104062033.txt".

2. This one is not necessary if the first one can be done, if it cant, I would like the Heroes proper name to be included within the file.

Now it looks like this:
SaveFile.jpg

I would like the Gold and Lumber to be removed as they are not used. And the Char: should say the Heroes proper name, and not "Champion" which is the name on the XP bar.



Warning, long code xD
JASS:
//*************************************************************************************************************************************************************************************
//
// RPG Creator Basic Function Descriptions By Grabiti
//
//
//
//
// Internal System Functions Index
//
// function ToNotation takes integer input returns string
//  ???
//
// function ToInteger takes string input returns integer
//  ???
//
// function ToNotation2 takes integer input returns string
//  Convert the given decimal to a binary value
//
// function ToInteger2 takes string input returns integer
//  Converts the given binary to a decimal value
//
// function CodeLength takes string input, integer notation returns string
//  ???
//
// function CodeLength2 takes string input, integer maxLength returns string
//  ???
//
// function NameToInteger takes string name returns integer
//  Converts the given string to a number
//
// function IsNumber takes string input returns boolean
//  Check if the given text is a number
//
// function IsSpecial takes string input returns boolean
//  Check if the given text is a symbol
//
// function IsSmallAlphabet takes string input returns boolean
//  Check if the given text is lowercase
//
// function IsSmallAlphabet takes string input returns boolean
//  Check if the given text is lowercase
//
// function CodeColor takes string input returns string
//  ColorCodes the given string and returns new format
//
// function PrintCode takes player p, string saveResult, integer codeLine returns string
//  Output the code to the player
//
// function HashSetting takes nothing returns nothing
//  Save the object in setup HeroItem trigger to the hashtable.
//
// function MakeFile takes player p, string fileName, string string1, string string2, string string3, string string4 returns nothing
//  Create and save a text file to CustomGameData/
//
// function DataOnBoolean takes integer loopA returns boolean
//  returns true if the given value is an array value or cipher, otherwise returns false
//
// function SaveDataHash takes player p returns nothing
//  Save the udg_data variables from the Save trigger to the hashtable
//
//
//
//
// User-Friendly Functions
//
// function AlphaToNormal takes unit whichUnit, real tick returns nothing
//  Transforms the unit instantly and gradually fades it in (Gets less transparent with every tick internal)
//
// function NormalToAlpha takes unit whichUnit, real tick returns nothing
//  Transforms the unit instantly and gradually fades it out (Gets more transparent with every tick internval)
//
// function DummyToAlpha takes unit whichUnit, real tick returns nothing
//  Creates a dummy unit instantly and gradually fades it out (Gets more transparent with every tick interval)
//
// function MessageToTarget takes unit target, string text, integer alpha, real size, real speed, real time, real low, real high, real decline, real cycle, integer red, integer green, integer blue, boolean same returns nothing
//  Creates a floating text of a set size at the set location and reduces the size of the floating text by a set value at the specified intervals
//
//
//
//
// Save Function
//
// function HeroSave takes player p, string message returns nothing
//  Save function.
//
//
//
//
// Load Function
//
// function HeroLoad takes player p, string message returns nothing
//  Load function.
//
//*************************************************************************************************************************************************************************************


















//************************************************************************************************************************************************************************
//*
//*  Internal System Functions
//*
//************************************************************************************************************************************************************************



function ToNotation takes integer input returns string
    local string inputStr = I2S(input)
    local string result = null
    local integer mod
    loop
        exitwhen input <= 0
        set mod = ModuloInteger(input, udg_keyLength)
        set result = SubString(udg_keySet, mod, mod + 1) + result
        set input = input / udg_keyLength
    endloop
    return result
endfunction


function ToInteger takes string input returns integer
    local integer length = StringLength(input)
    local string current = null
    local integer result = 0
    local integer loopA
    local integer loopB
    set loopA = 0
    loop
        exitwhen loopA >= length
        set result = result * udg_keyLength
        set current = SubString(input, loopA, loopA + 1)
        set loopB = 0
        loop
            exitwhen (loopB >= udg_keyLength) or (current == SubString(udg_keySet, loopB, loopB + 1))
            set loopB = loopB + 1
        endloop
        if (loopB <= udg_keyLength) then
            set result = result + loopB
        endif
        set loopA = loopA + 1
    endloop
    return result
endfunction


function ToNotation2 takes integer input returns string
    local string keySet = "01"
    local integer keyLength = StringLength(keySet)
    local string inputStr = I2S(input)
    local string result = null
    local integer mod
    loop
        exitwhen input <= 0
        set mod = ModuloInteger(input, keyLength)
        set result = SubString(keySet, mod, mod + 1) + result
        set input = input / keyLength
    endloop
    return result
endfunction


function ToInteger2 takes string input returns integer
    local string keySet = "01"
    local integer keyLength = StringLength(keySet)
    local integer length = StringLength(input)
    local string current = null
    local integer result = 0
    local integer loopA
    local integer loopB
    set loopA = 0
    loop
        exitwhen loopA >= length
        set result = result * keyLength
        set current = SubString(input, loopA, loopA + 1)
        set loopB = 0
        loop
            exitwhen (loopB >= keyLength) or (current == SubString(keySet, loopB, loopB + 1))
            set loopB = loopB + 1
        endloop
        if (loopB <= keyLength) then
            set result = result + loopB
        endif
        set loopA = loopA + 1
    endloop
    return result
endfunction


function CodeLength takes string input, integer notation returns string
    local integer length = StringLength(input)
    local integer blank = length - notation
    if (blank < 0) then
        loop
            exitwhen blank >= 0
            set input = udg_keyFirst + input
            set blank = blank + 1
        endloop
    endif
    return input
endfunction


function CodeLength2 takes string input, integer maxLength returns string
    local integer length = StringLength(input)
    local integer blank = length - maxLength
    if (blank < 0) then
        loop
            exitwhen blank >= 0
            set input = "0" + input
            set blank = blank + 1
        endloop
    endif
    return input
endfunction


function NameToInteger takes string name returns integer
    local string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~`!#$^&*()-_=+|{}[]:;<>,.?@"
    local string cutString
    local integer alphabetLength = StringLength(alphabet)
    local integer nameLength = StringLength(name)
    local integer cutLength
    local integer result = 0
    local integer loopA
    local integer loopB
    set loopA = 0
    loop
        exitwhen loopA > nameLength
        set cutString = SubString(name, loopA, loopA + 1)
        set loopB = 0
        loop
            exitwhen loopB > alphabetLength
            if (cutString == SubString(alphabet, loopB, loopB + 1)) then
                set result = result + (loopB * loopA)
            endif
            set loopB = loopB + 1
        endloop
        set loopA = loopA + 1
    endloop
  return result
endfunction


function IsNumber takes string input returns boolean
    local integer loopA
    set loopA = 0
    loop
        exitwhen loopA > 9
        if (input == I2S(loopA)) then
            return true
        endif
        set loopA = loopA + 1
    endloop
    return false
endfunction


function IsSpecial takes string input returns boolean
    local string alphabet = udg_specialChar
    local integer loopA
    set loopA = 0
    loop
        exitwhen loopA > StringLength(alphabet)
        if (input == SubString(alphabet, loopA, loopA + 1)) then
            return true
        endif
        set loopA = loopA + 1
    endloop
    return false
endfunction


function IsSmallAlphabet takes string input returns boolean
    local string alphabet = udg_smallAlphabetChar
    local integer loopA
    set loopA = 0
    loop
        exitwhen loopA > StringLength(alphabet)
        if (input == SubString(alphabet, loopA, loopA + 1)) then
            return true
        endif
        set loopA = loopA + 1
    endloop
    return false
endfunction


function IsBigAlphabet takes string input returns boolean
    local string alphabet = udg_bigAlphabetChar
    local integer loopA
    set loopA = 0
    loop
        exitwhen loopA > StringLength(alphabet)
        if (input == SubString(alphabet, loopA, loopA + 1)) then
            return true
        endif
        set loopA = loopA + 1
    endloop
    return false
endfunction


function CodeColor takes string input returns string
    local string result = ""
    local string small = "|cff8080FF"
    local string big = "|cff75E975"
    local string special = "|cffFF8000"
    local string number = "|cffFEFE7F"
    local string checkStr
    local boolean prevSmall = false
    local boolean prevBig = false
    local boolean prevSpecial = false
    local boolean prevNumber = false
    local integer loopA
    set loopA = 0
    loop
        exitwhen loopA > StringLength(input)
        set checkStr = SubString(input, loopA, loopA + 1)
        if (IsNumber(checkStr) == true) then
            if (prevNumber == true) then
                set result = result + checkStr
            else
                set result = result + number + checkStr
            endif
            set prevNumber = true
            set prevSpecial = false
            set prevSmall = false
            set prevBig = false
        endif
        if (IsSpecial(checkStr) == true) then
            if (prevSpecial == true) then
                set result = result + checkStr
            else
                set result = result + special + checkStr
            endif
            set prevNumber = false
            set prevSpecial = true
            set prevSmall = false
            set prevBig = false
        endif
        if (IsSmallAlphabet(checkStr) == true) then
            if (prevSmall == true) then
                set result = result + checkStr
            else
                set result = result + small + checkStr
            endif
            set prevNumber = false
            set prevSpecial = false
            set prevSmall = true
            set prevBig = false
        endif
        if (IsBigAlphabet(checkStr) == true) then
            if (prevBig == true) then
                set result = result + checkStr
            else
                set result = result + big + checkStr
            endif
            set prevNumber = false
            set prevSpecial = false
            set prevSmall = false
            set prevBig = true
        endif
        set loopA = loopA + 1
    endloop
    set result = result + "|r"
    return result
endfunction


function HashSetting takes nothing returns nothing
    local integer loopA
    set udg_saveHeroHash = InitHashtable()
    set udg_saveItemHash = InitHashtable()
    set loopA = 1
    loop
        exitwhen loopA > 32768
        if (udg_saveHero[loopA] != 0) then
            call SaveInteger(udg_saveHeroHash, 0, udg_saveHero[loopA], loopA)
        endif
        if (udg_saveItem[loopA] != 0) then
            call SaveInteger(udg_saveItemHash, 0, udg_saveItem[loopA], loopA)
        endif
        if (ModuloInteger(loopA, 700) == 0) then
            call TriggerSleepAction(0.01)
        endif
        set loopA = loopA + 1
    endloop
    call SaveInteger(udg_saveHeroHash, 0, 0, 0)
    call SaveInteger(udg_saveItemHash, 0, 0, 0)
endfunction


function MakeFile takes player p, string message, string lv returns nothing
    local string gold = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataGold)
    local string lumber = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataLumber)
    local string char = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroType)
    local string heroExp = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroExp)
    local string heroStr = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroStr)
    local string heroAgi = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroAgi)
    local string heroInt = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroInt)
    local string heroItem1 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroItem1)
    local string heroItem2 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroItem2)
    local string heroItem3 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroItem3)
    local string heroItem4 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroItem4)
    local string heroItem5 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroItem5)
    local string heroItem6 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroItem6)
    local string heroCharge1 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroCharge1)
    local string heroCharge2 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroCharge2)
    local string heroCharge3 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroCharge3)
    local string heroCharge4 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroCharge4)
    local string heroCharge5 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroCharge5)
    local string heroCharge6 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataHeroCharge6)
    local string bag1Item1 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Item1)
    local string bag1Item2 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Item2)
    local string bag1Item3 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Item3)
    local string bag1Item4 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Item4)
    local string bag1Item5 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Item5)
    local string bag1Item6 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Item6)
    local string bag1Charge1 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Charge1)
    local string bag1Charge2 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Charge2)
    local string bag1Charge3 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Charge3)
    local string bag1Charge4 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Charge4)
    local string bag1Charge5 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Charge5)
    local string bag1Charge6 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag1Charge6)
    local string bag2Item1 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Item1)
    local string bag2Item2 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Item2)
    local string bag2Item3 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Item3)
    local string bag2Item4 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Item4)
    local string bag2Item5 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Item5)
    local string bag2Item6 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Item6)
    local string bag2Charge1 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Charge1)
    local string bag2Charge2 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Charge2)
    local string bag2Charge3 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Charge3)
    local string bag2Charge4 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Charge4)
    local string bag2Charge5 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Charge5)
    local string bag2Charge6 = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataBag2Charge6)
    local string saveTick = LoadStr(udg_dataTextStringHash, GetHandleId(p), udg_saveDataSaveTick)
    local string code1 = LoadStr(udg_makeFileHash, GetHandleId(p), 1)
    local string code2 = LoadStr(udg_makeFileHash, GetHandleId(p), 2)
    local string code3 = LoadStr(udg_makeFileHash, GetHandleId(p), 3)
    local string code4 = LoadStr(udg_makeFileHash, GetHandleId(p), 4)
    local string code5 = LoadStr(udg_makeFileHash, GetHandleId(p), 5)
    local string code6 = LoadStr(udg_makeFileHash, GetHandleId(p), 6)
    local string code7 = LoadStr(udg_makeFileHash, GetHandleId(p), 7)
    local string code8 = LoadStr(udg_makeFileHash, GetHandleId(p), 8)
    local string code9 = LoadStr(udg_makeFileHash, GetHandleId(p), 9)
    local string code10 = LoadStr(udg_makeFileHash, GetHandleId(p), 10)
    local string code11 = LoadStr(udg_makeFileHash, GetHandleId(p), 11)
    local string code12 = LoadStr(udg_makeFileHash, GetHandleId(p), 12)
    local string code13 = LoadStr(udg_makeFileHash, GetHandleId(p), 13)
    local string code14 = LoadStr(udg_makeFileHash, GetHandleId(p), 14)
    local string code15 = LoadStr(udg_makeFileHash, GetHandleId(p), 15)
    local string code16 = LoadStr(udg_makeFileHash, GetHandleId(p), 16)
    local string code17 = LoadStr(udg_makeFileHash, GetHandleId(p), 17)
    local string code18 = LoadStr(udg_makeFileHash, GetHandleId(p), 18)
    local string code19 = LoadStr(udg_makeFileHash, GetHandleId(p), 19)
    local string code20 = LoadStr(udg_makeFileHash, GetHandleId(p), 20)
    local string code21 = LoadStr(udg_makeFileHash, GetHandleId(p), 21)
    local string code22 = LoadStr(udg_makeFileHash, GetHandleId(p), 22)
    local string code23 = LoadStr(udg_makeFileHash, GetHandleId(p), 23)
    local string code24 = LoadStr(udg_makeFileHash, GetHandleId(p), 24)
    local string code25 = LoadStr(udg_makeFileHash, GetHandleId(p), 25)
    local string code26 = LoadStr(udg_makeFileHash, GetHandleId(p), 26)
    local string code27 = LoadStr(udg_makeFileHash, GetHandleId(p), 27)
    local string code28 = LoadStr(udg_makeFileHash, GetHandleId(p), 28)
    local string code29 = LoadStr(udg_makeFileHash, GetHandleId(p), 29)
    local string code30 = LoadStr(udg_makeFileHash, GetHandleId(p), 30)
    local string fileName = GetPlayerName(p) + "_" + saveTick + "_" + I2S(GetRandomInt(1000000000, 2000000000))

    if (GetLocalPlayer() == p) then
        call PreloadGenClear()
        call PreloadGenStart()
        call Preload("----------------- Save Code ------------------")
        if (code1 != null) then
            call Preload("Code1: " + code1 + " ")
        endif
        if (code2 != null) then
            call Preload("Code2: " + code2 + " ")
        endif
        if (code3 != null) then
            call Preload("Code3: " + code3 + " ")
        endif
        if (code4 != null) then
            call Preload("Code4: " + code4 + " ")
        endif
        if (code5 != null) then
            call Preload("Code5: " + code5 + " ")
        endif
        if (code6 != null) then
            call Preload("Code6: " + code6 + " ")
        endif
        if (code7 != null) then
            call Preload("Code7: " + code7 + " ")
        endif
        if (code8 != null) then
            call Preload("Code8: " + code8 + " ")
        endif
        if (code9 != null) then
            call Preload("Code9: " + code9 + " ")
        endif
        if (code10 != null) then
            call Preload("Code10: " + code10 + " ")
        endif
        if (code11 != null) then
            call Preload("Code11: " + code11 + " ")
        endif
        if (code12 != null) then
            call Preload("Code12: " + code12 + " ")
        endif
        if (code13 != null) then
            call Preload("Code13: " + code13 + " ")
        endif
        if (code14 != null) then
            call Preload("Code14: " + code14 + " ")
        endif
        if (code15 != null) then
            call Preload("Code15: " + code15 + " ")
        endif
        if (code16 != null) then
            call Preload("Code16: " + code16 + " ")
        endif
        if (code17 != null) then
            call Preload("Code17: " + code17 + " ")
        endif
        if (code18 != null) then
            call Preload("Code18: " + code18 + " ")
        endif
        if (code19 != null) then
            call Preload("Code19: " + code19 + " ")
        endif
        if (code20 != null) then
            call Preload("Code20: " + code20 + " ")
        endif
        if (code21 != null) then
            call Preload("Code21: " + code21 + " ")
        endif
        if (code22 != null) then
            call Preload("Code22: " + code22 + " ")
        endif
        if (code23 != null) then
            call Preload("Code23: " + code23 + " ")
        endif
        if (code24 != null) then
            call Preload("Code24: " + code24 + " ")
        endif
        if (code25 != null) then
            call Preload("Code25: " + code25 + " ")
        endif
        if (code26 != null) then
            call Preload("Code26: " + code26 + " ")
        endif
        if (code27 != null) then
            call Preload("Code27: " + code27 + " ")
        endif
        if (code28 != null) then
            call Preload("Code28: " + code28 + " ")
        endif
        if (code29 != null) then
            call Preload("Code29: " + code29 + " ")
        endif
        if (code30 != null) then
            call Preload("Code30: " + code30 + " ")
        endif
        call Preload("----------------- Data Stats -----------------")
        if (gold != "0") then
            call Preload("Gold: " + gold)
        endif
        if (lumber != "0") then
            call Preload("Lumber: " + lumber)
        endif
        if (char != "0") then
            call Preload("Char: " + char)
        endif
        if (lv != "0") then
            call Preload("Lv: " + lv)
        endif
        if (heroExp != "0") then
            call Preload("Exp: " + heroExp)
        endif
        if (heroStr != "0") then
            call Preload("Str: " + heroStr)
        endif
        if (heroAgi != "0") then
            call Preload("Agi: " + heroAgi)
        endif
        if (heroInt != "0") then
            call Preload("Int: " + heroInt)
        endif
        if (heroItem1 != "0") then
            call Preload("HeroItem1: '" + heroItem1 + "' Charges: " + heroCharge1)
        endif
        if (heroItem2 != "0") then
            call Preload("HeroItem2: '" + heroItem2 + "' Charges: " + heroCharge2)
        endif
        if (heroItem3 != "0") then
            call Preload("HeroItem3: '" + heroItem3 + "' Charges: " + heroCharge3)
        endif
        if (heroItem4 != "0") then
            call Preload("HeroItem4: '" + heroItem4 + "' Charges: " + heroCharge4)
        endif
        if (heroItem5 != "0") then
            call Preload("HeroItem5: '" + heroItem5 + "' Charges: " + heroCharge5)
        endif
        if (heroItem6 != "0") then
            call Preload("HeroItem6: '" + heroItem6 + "' Charges: " + heroCharge6)
        endif
        if (bag1Item1 != "0") then
            call Preload("BagItem1: '" + bag1Item1 + "' Charges: " + bag1Charge1)
        endif
        if (bag1Item2 != "0") then
            call Preload("BagItem2: '" + bag1Item2 + "' Charges: " + bag1Charge2)
        endif
        if (bag1Item3 != "0") then
            call Preload("BagItem3: '" + bag1Item3 + "' Charges: " + bag1Charge3)
        endif
        if (bag1Item4 != "0") then
            call Preload("BagItem4: '" + bag1Item4 + "' Charges: " + bag1Charge4)
        endif
        if (bag1Item5 != "0") then
            call Preload("BagItem5: '" + bag1Item5 + "' Charges: " + bag1Charge5)
        endif
        if (bag1Item6 != "0") then
            call Preload("BagItem6: '" + bag1Item6 + "' Charges: " + bag1Charge6)
        endif
        if (bag2Item1 != "0") then
            call Preload("BagItem1: '" + bag2Item1 + "' Charges: " + bag2Charge1)
        endif
        if (bag2Item2 != "0") then
            call Preload("BagItem2: '" + bag2Item2 + "' Charges: " + bag2Charge2)
        endif
        if (bag2Item3 != "0") then
            call Preload("BagItem3: '" + bag2Item3 + "' Charges: " + bag2Charge3)
        endif
        if (bag2Item4 != "0") then
            call Preload("BagItem4: '" + bag2Item4 + "' Charges: " + bag2Charge4)
        endif
        if (bag2Item5 != "0") then
            call Preload("BagItem5: '" + bag2Item5 + "' Charges: " + bag2Charge5)
        endif
        if (bag2Item6 != "0") then
            call Preload("BagItem6: '" + bag2Item6 + "' Charges: " + bag2Charge6)
        endif
        call Preload("---------------- Chat Message ----------------")
        call Preload(message)
        call Preload("Grabiti's RPG Creator: http://cafe.naver.com/rpgcreator")
        call PreloadGenEnd("ChampionRPG" + "\\" + udg_MapName + "\\" + fileName + ".txt")
        call PreloadEnd(3.0)
        call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cfffffc01\\ChampionRPG\\" + udg_MapName + " _ " + fileName + ".txt.|r\n|c00DFFB4F Grabiti RPG Creator 1.08.|r")
        call FlushChildHashtable(udg_dataTextStringHash, GetHandleId(p))
        call FlushChildHashtable(udg_makeFileHash, GetHandleId(p))
    endif
endfunction


function PrintCodeTimer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local player p = LoadPlayerHandle(udg_printCodeHash, GetHandleId(t), 0)
    local string saveResult = LoadStr(udg_printCodeHash, GetHandleId(t), 0)
    local integer codeLine = LoadInteger(udg_printCodeHash, GetHandleId(t), 0)
    if (saveResult != null) then
        call DisplayTimedTextToPlayer(p, 0.0, 0.0, 999.0, "|c00DFFB4FCode" + I2S(codeLine) + "\n" + CodeColor(saveResult))
    endif
    call FlushChildHashtable(udg_printCodeHash, GetHandleId(t))
    call DestroyTimer(t)
    set t = null
    set p = null
endfunction


function PrintCode takes player p, string saveResult, integer codeLine returns nothing
    local timer t = CreateTimer()
    call SavePlayerHandle(udg_printCodeHash, GetHandleId(t), 0, p)
    call SaveStr(udg_printCodeHash, GetHandleId(t), 0, saveResult)
    call SaveInteger(udg_printCodeHash, GetHandleId(t), 0, codeLine)
    call TimerStart(t, 0.0, false, function PrintCodeTimer)
    set t = null
endfunction


function DataOnBoolean takes integer loopA returns boolean
    if (loopA == udg_saveDataLengthCheck) or (loopA == udg_saveDataLength1) or (loopA == udg_saveDataLength2) or (loopA == udg_saveDataLength3) or (loopA == udg_saveDataLength4) or (loopA == udg_saveDataLength5) or (loopA == udg_saveDataLength6) or (loopA == udg_saveDataLength7) or (loopA == udg_saveDataLength8) or (loopA == udg_saveDataLength9) or (loopA == udg_saveDataLength10) or (loopA == udg_saveDataLength11) or (loopA == udg_saveDataLength12) or (loopA == udg_saveDataLength13) or (loopA == udg_saveDataLength14) or (loopA == udg_saveDataLength15) or (loopA == udg_saveDataLength16) or (loopA == udg_saveDataLength17) or (loopA == udg_saveDataLength18) or (loopA == udg_saveDataLength19) or (loopA == udg_saveDataLength20) or (loopA == udg_saveDataLength21) or (loopA == udg_saveDataLength22) or (loopA == udg_saveDataLength23) or (loopA == udg_saveDataLength24) or (loopA == udg_saveDataEncryption) then
        return true
    else
        return false
    endif
endfunction


function SaveDataHash takes player p returns nothing
    local integer loopA
    set loopA = 1
    loop
        exitwhen loopA > udg_saveDataN
        call SaveInteger(udg_dataHash, GetConvertedPlayerId(p), loopA, udg_data[loopA])
        set loopA = loopA + 1
    endloop
endfunction


//************************************************************************************************************************************************************************
//*
//*  User-Friendly Functions
//*
//************************************************************************************************************************************************************************



function AlphaToNormalTimer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit whichUnit = LoadUnitHandle(udg_alphaToNormalHash, GetHandleId(t), 0)
    local integer timerLoop = LoadInteger(udg_alphaToNormalHash, GetHandleId(t), 1)
    if (timerLoop > 0) then
        set timerLoop = timerLoop - 1
        call SetUnitVertexColorBJ(whichUnit, 100, 100, 100, I2R(timerLoop * 10))
        call SaveInteger(udg_alphaToNormalHash, GetHandleId(t), 1, timerLoop)
    else
        call FlushChildHashtable(udg_alphaToNormalHash, GetHandleId(t))
        call DestroyTimer(t)
    endif
    set t = null
    set whichUnit = null
endfunction

function AlphaToNormal takes unit whichUnit, real tick returns nothing
    local timer t = CreateTimer()
    local integer timerLoop = 10
    call SetUnitVertexColorBJ(whichUnit, 100, 100, 100, 100.0)
    call SaveUnitHandle(udg_alphaToNormalHash, GetHandleId(t), 0, whichUnit)
    call SaveInteger(udg_alphaToNormalHash, GetHandleId(t), 1, timerLoop)
    call TimerStart(t, tick, true, function AlphaToNormalTimer)
    set t = null
endfunction


function NormalToAlphaTimer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit whichUnit = LoadUnitHandle(udg_normalToAlphaHash, GetHandleId(t), 0)
    local integer timerLoop = LoadInteger(udg_normalToAlphaHash, GetHandleId(t), 1)
    if (timerLoop > 0) then
        set timerLoop = timerLoop - 1
        call SetUnitVertexColorBJ(whichUnit, 100, 100, 100, 100.0 - I2R(timerLoop * 10))
        call SaveInteger(udg_normalToAlphaHash, GetHandleId(t), 1, timerLoop)
    else
        call FlushChildHashtable(udg_normalToAlphaHash, GetHandleId(t))
        call DestroyTimer(t)
    endif
    set t = null
    set whichUnit = null
endfunction

function NormalToAlpha takes unit whichUnit, real tick returns nothing
    local timer t = CreateTimer()
    local integer timerLoop = 10
    call SetUnitVertexColorBJ(whichUnit, 100, 100, 100, 0.0)
    call SaveUnitHandle(udg_normalToAlphaHash, GetHandleId(t), 0, whichUnit)
    call SaveInteger(udg_normalToAlphaHash, GetHandleId(t), 1, timerLoop)
    call TimerStart(t, tick, true, function NormalToAlphaTimer)
    set t = null
endfunction


function DummyToAlphaTimer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit tempUnit = LoadUnitHandle(udg_dummyToAlphaHash, GetHandleId(t), 0)
    local integer timerLoop = LoadInteger(udg_dummyToAlphaHash, GetHandleId(t), 1)
    if (timerLoop > 0) then
        set timerLoop = timerLoop - 1
        call SetUnitVertexColorBJ(tempUnit, 100, 100, 100, 100.0 - I2R(timerLoop * 10))
        call SaveInteger(udg_dummyToAlphaHash, GetHandleId(t), 1, timerLoop)
    else
        call RemoveUnit(tempUnit)
        call FlushChildHashtable(udg_dummyToAlphaHash, GetHandleId(t))
        call DestroyTimer(t)
    endif
    set t = null
    set tempUnit = null
endfunction

function DummyToAlpha takes unit whichUnit, real tick returns nothing
    local timer t = CreateTimer()
    local unit tempUnit
    local integer timerLoop = 10
    set tempUnit = CreateUnit(GetOwningPlayer(whichUnit), GetUnitTypeId(whichUnit), GetUnitX(whichUnit), GetUnitY(whichUnit), GetUnitFacing(GetTriggerUnit()))
    call UnitAddAbility(tempUnit, 'Aloc')
    call UnitMakeAbilityPermanent(tempUnit, true, 'Aloc')
    call SaveUnitHandle(udg_dummyToAlphaHash, GetHandleId(t), 0, tempUnit)
    call SaveInteger(udg_dummyToAlphaHash, GetHandleId(t), 1, timerLoop)
    call TimerStart(t, tick, true, function DummyToAlphaTimer)
    set t = null
    set tempUnit = null
endfunction


function MessageToTargetNonOverlap takes nothing returns nothing
    local timer sameTimer = GetExpiredTimer()
    local integer targetId = LoadInteger(udg_messageToTargetHash, GetHandleId(sameTimer), 0)
    call FlushChildHashtable(udg_messageToTargetHash, targetId)
    call FlushChildHashtable(udg_messageToTargetHash, GetHandleId(sameTimer))
    call DestroyTimer(sameTimer)
    set sameTimer = null
endfunction

function MessageToTargetTimer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local texttag textTag = LoadTextTagHandle(udg_messageToTargetHash, GetHandleId(t), 0)
    local string text = LoadStr(udg_messageToTargetHash, GetHandleId(t), 1)
    local real size = LoadReal(udg_messageToTargetHash, GetHandleId(t), 2)
    local real decline = LoadReal(udg_messageToTargetHash, GetHandleId(t), 3)
    local real cycle = LoadReal(udg_messageToTargetHash, GetHandleId(t), 4)
    local integer loopN = LoadInteger(udg_messageToTargetHash, GetHandleId(t), 5)
    if (loopN > 0) then
        set loopN = loopN - 1
        set decline = decline / 100
        set size = size / (1 + decline)
        set decline = decline * 100
        call SetTextTagText(textTag, text, size * 0.023 / 10)
        call SaveTextTagHandle(udg_messageToTargetHash, GetHandleId(t), 0, textTag)
        call SaveStr(udg_messageToTargetHash, GetHandleId(t), 1, text)
        call SaveReal(udg_messageToTargetHash, GetHandleId(t), 2, size)
        call SaveReal(udg_messageToTargetHash, GetHandleId(t), 3, decline)
        call SaveReal(udg_messageToTargetHash, GetHandleId(t), 4, cycle)
        call SaveInteger(udg_messageToTargetHash, GetHandleId(t), 5, loopN)
    else
        call FlushChildHashtable(udg_messageToTargetHash, GetHandleId(t))
        call DestroyTimer(t)
    endif
    set t = null
    set textTag = null
endfunction

function MessageToTarget takes unit target, string text, integer alpha, real size, real speed, real time, real low, real high, integer decline, real cycle, integer red, integer green, integer blue, boolean same returns nothing
    local timer t
    local timer sameTimer
    local texttag textTag
    local real vel = speed * 0.071 / 128
    local real xvel = vel * Cos(GetRandomReal(low, high) * bj_DEGTORAD)
    local real yvel = vel * Sin(GetRandomReal(low, high) * bj_DEGTORAD)
    local integer loopN = 5
    if (same == true) then
        if (HaveSavedHandle(udg_messageToTargetHash, GetHandleId(target), 0)) then
            set sameTimer = LoadTimerHandle(udg_messageToTargetHash, GetHandleId(target), 0)
            if (TimerGetRemaining(sameTimer) != 0.0) then
                set t = null
                set sameTimer = null
                set textTag = null
                return
            endif
        endif
        set sameTimer = CreateTimer()
        call SaveTimerHandle(udg_messageToTargetHash, GetHandleId(target), 0, sameTimer)
        call SaveInteger(udg_messageToTargetHash, GetHandleId(sameTimer), 0, GetHandleId(target))
        call TimerStart(sameTimer, 0.001, false, function MessageToTargetNonOverlap)
    endif
    set textTag = CreateTextTag()
    call SetTextTagText(textTag, text, size * 0.023 / 10)
    call SetTextTagPosUnit(textTag, target, 0.00)
    call SetTextTagColor(textTag, red, green, blue, alpha)
    call SetTextTagPermanent(textTag, false)
    call SetTextTagLifespan(textTag, time)
    call SetTextTagFadepoint(textTag, 0.00)
    call SetTextTagVelocity(textTag, xvel, yvel)
    set t = CreateTimer()
    call SaveTextTagHandle(udg_messageToTargetHash, GetHandleId(t), 0, textTag)
    call SaveStr(udg_messageToTargetHash, GetHandleId(t), 1, text)
    call SaveReal(udg_messageToTargetHash, GetHandleId(t), 2, size)
    call SaveReal(udg_messageToTargetHash, GetHandleId(t), 3, decline)
    call SaveReal(udg_messageToTargetHash, GetHandleId(t), 4, cycle)
    call SaveInteger(udg_messageToTargetHash, GetHandleId(t), 5, loopN)
    call TimerStart(t, cycle, true, function MessageToTargetTimer)
    set t = null
    set sameTimer = null
    set textTag = null
endfunction



//************************************************************************************************************************************************************************
//*
//*  Save Function
//*
//************************************************************************************************************************************************************************



function HeroSave takes player p, string message returns nothing
    local string array data
    local integer array dataOn
    local string result = null
    local string array saveResult
    local string array dataTextString
    local integer checkNum = 0
    local unit hero = udg_hero[GetConvertedPlayerId(p)]
    local unit bag1 = udg_bag1[GetConvertedPlayerId(p)]
    local unit bag2 = udg_bag2[GetConvertedPlayerId(p)]
    local integer num
    local integer num2
    local real real1
    local integer loopA
    local integer loopExit


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Data Settings (Save)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set loopA = 1
    loop
        exitwhen loopA > udg_saveDataN
        if (DataOnBoolean(loopA) == false) then
            set num = 0

            // Compares whether the data exceeds the maximum value, and sets it to the maximum when exceeding.
            if (LoadInteger(udg_dataHash, GetConvertedPlayerId(p), loopA) < R2I(Pow(udg_keyLength, udg_saveData[loopA]))) then
                set num = LoadInteger(udg_dataHash, GetConvertedPlayerId(p), loopA)
            else
                set num = R2I(Pow(udg_keyLength, udg_saveData[loopA]) - 1)
            endif

            // Set the data.
            set data[loopA] = ToNotation(num)
            set dataTextString[loopA] = I2S(num)
        endif
        set loopA = loopA + 1
    endloop

    // Sets the name of the unit and item.
    set dataTextString[udg_saveDataHeroType] = GetUnitName(hero)
    set dataTextString[udg_saveDataHeroItem1] = GetItemName(UnitItemInSlot(hero, 0))
    set dataTextString[udg_saveDataHeroItem2] = GetItemName(UnitItemInSlot(hero, 1))
    set dataTextString[udg_saveDataHeroItem3] = GetItemName(UnitItemInSlot(hero, 2))
    set dataTextString[udg_saveDataHeroItem4] = GetItemName(UnitItemInSlot(hero, 3))
    set dataTextString[udg_saveDataHeroItem5] = GetItemName(UnitItemInSlot(hero, 4))
    set dataTextString[udg_saveDataHeroItem6] = GetItemName(UnitItemInSlot(hero, 5))
    set dataTextString[udg_saveDataBag1Item1] = GetItemName(UnitItemInSlot(bag1, 0))
    set dataTextString[udg_saveDataBag1Item2] = GetItemName(UnitItemInSlot(bag1, 1))
    set dataTextString[udg_saveDataBag1Item3] = GetItemName(UnitItemInSlot(bag1, 2))
    set dataTextString[udg_saveDataBag1Item4] = GetItemName(UnitItemInSlot(bag1, 3))
    set dataTextString[udg_saveDataBag1Item5] = GetItemName(UnitItemInSlot(bag1, 4))
    set dataTextString[udg_saveDataBag1Item6] = GetItemName(UnitItemInSlot(bag1, 5))
    set dataTextString[udg_saveDataBag2Item1] = GetItemName(UnitItemInSlot(bag2, 0))
    set dataTextString[udg_saveDataBag2Item2] = GetItemName(UnitItemInSlot(bag2, 1))
    set dataTextString[udg_saveDataBag2Item3] = GetItemName(UnitItemInSlot(bag2, 2))
    set dataTextString[udg_saveDataBag2Item4] = GetItemName(UnitItemInSlot(bag2, 3))
    set dataTextString[udg_saveDataBag2Item5] = GetItemName(UnitItemInSlot(bag2, 4))
    set dataTextString[udg_saveDataBag2Item6] = GetItemName(UnitItemInSlot(bag2, 5))


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Verify that the data is the correct value. (Save)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    // If the save target does not exist, stop saving.
    if (hero == null) then
        call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FSave target does not exist.|r")
        set hero = null
        set bag1 = null
        set bag2 = null
        set udg_codeSavingNow[GetConvertedPlayerId(p)] = false
        return
    endif

    // If the hero to be saved does not exist in the array set in the setup HeroItem trigger, stop saving.
    if (LoadInteger(udg_saveHeroHash, 0, GetUnitTypeId(hero)) == 0) then
        call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FThe save target is not the hero set in the array.|r")
        set hero = null
        set bag1 = null
        set bag2 = null
        set udg_codeSavingNow[GetConvertedPlayerId(p)] = false
        return
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Set whether each data value is 0 or 1 or more. (Save)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set loopA = 1
    loop
        exitwhen loopA > udg_saveDataN
        if (ToInteger(data[loopA]) > 0) or (DataOnBoolean(loopA)) then
            set dataOn[loopA] = 1
        else
            set dataOn[loopA] = 0
        endif
        if (ModuloInteger(loopA, 100) == 0) then
            call TriggerSleepAction(0.01)
        endif
        set loopA = loopA + 1
    endloop

    // Due to the nature of Warcraft, when the loop returns a certain amount, it waits for a while because the function is forcibly terminated.
    call TriggerSleepAction(0.01)


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 1 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength1] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 1
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength1] = I2S(dataOn[loopA]) + data[udg_saveDataLength1]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 1.
    if (ToInteger2(data[udg_saveDataLength1]) != 0) then
        set data[udg_saveDataLength1] = ToNotation(ToInteger2(data[udg_saveDataLength1]))
    else
        set dataOn[udg_saveDataLength1] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 2 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength2] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 31
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength2] = I2S(dataOn[loopA]) + data[udg_saveDataLength2]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 2.
    if (ToInteger2(data[udg_saveDataLength2]) != 0) then
        set data[udg_saveDataLength2] = ToNotation(ToInteger2(data[udg_saveDataLength2]))
    else
        set dataOn[udg_saveDataLength2] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 3 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength3] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 61
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength3] = I2S(dataOn[loopA]) + data[udg_saveDataLength3]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 3.
    if (ToInteger2(data[udg_saveDataLength3]) != 0) then
        set data[udg_saveDataLength3] = ToNotation(ToInteger2(data[udg_saveDataLength3]))
    else
        set dataOn[udg_saveDataLength3] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 4 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength4] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 91
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength4] = I2S(dataOn[loopA]) + data[udg_saveDataLength4]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 4.
    if (ToInteger2(data[udg_saveDataLength4]) != 0) then
        set data[udg_saveDataLength4] = ToNotation(ToInteger2(data[udg_saveDataLength4]))
    else
        set dataOn[udg_saveDataLength4] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 5 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength5] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 121
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength5] = I2S(dataOn[loopA]) + data[udg_saveDataLength5]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 5.
    if (ToInteger2(data[udg_saveDataLength5]) != 0) then
        set data[udg_saveDataLength5] = ToNotation(ToInteger2(data[udg_saveDataLength5]))
    else
        set dataOn[udg_saveDataLength5] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 6 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength6] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 151
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength6] = I2S(dataOn[loopA]) + data[udg_saveDataLength6]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 6.
    if (ToInteger2(data[udg_saveDataLength6]) != 0) then
        set data[udg_saveDataLength6] = ToNotation(ToInteger2(data[udg_saveDataLength6]))
    else
        set dataOn[udg_saveDataLength6] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 7 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength7] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 181
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength7] = I2S(dataOn[loopA]) + data[udg_saveDataLength7]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 7.
    if (ToInteger2(data[udg_saveDataLength7]) != 0) then
        set data[udg_saveDataLength7] = ToNotation(ToInteger2(data[udg_saveDataLength7]))
    else
        set dataOn[udg_saveDataLength7] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 8 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength8] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 211
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength8] = I2S(dataOn[loopA]) + data[udg_saveDataLength8]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 8.
    if (ToInteger2(data[udg_saveDataLength8]) != 0) then
        set data[udg_saveDataLength8] = ToNotation(ToInteger2(data[udg_saveDataLength8]))
    else
        set dataOn[udg_saveDataLength8] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 9 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength9] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 241
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength9] = I2S(dataOn[loopA]) + data[udg_saveDataLength9]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 9.
    if (ToInteger2(data[udg_saveDataLength9]) != 0) then
        set data[udg_saveDataLength9] = ToNotation(ToInteger2(data[udg_saveDataLength9]))
    else
        set dataOn[udg_saveDataLength9] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 10 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength10] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 271
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength10] = I2S(dataOn[loopA]) + data[udg_saveDataLength10]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 10.
    if (ToInteger2(data[udg_saveDataLength10]) != 0) then
        set data[udg_saveDataLength10] = ToNotation(ToInteger2(data[udg_saveDataLength10]))
    else
        set dataOn[udg_saveDataLength10] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 11 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength11] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 301
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength11] = I2S(dataOn[loopA]) + data[udg_saveDataLength11]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 11.
    if (ToInteger2(data[udg_saveDataLength11]) != 0) then
        set data[udg_saveDataLength11] = ToNotation(ToInteger2(data[udg_saveDataLength11]))
    else
        set dataOn[udg_saveDataLength11] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 12 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength12] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 331
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength12] = I2S(dataOn[loopA]) + data[udg_saveDataLength12]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 12.
    if (ToInteger2(data[udg_saveDataLength12]) != 0) then
        set data[udg_saveDataLength12] = ToNotation(ToInteger2(data[udg_saveDataLength12]))
    else
        set dataOn[udg_saveDataLength12] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 13 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength13] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 361
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength13] = I2S(dataOn[loopA]) + data[udg_saveDataLength13]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 13.
    if (ToInteger2(data[udg_saveDataLength13]) != 0) then
        set data[udg_saveDataLength13] = ToNotation(ToInteger2(data[udg_saveDataLength13]))
    else
        set dataOn[udg_saveDataLength13] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 14 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength14] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 391
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength14] = I2S(dataOn[loopA]) + data[udg_saveDataLength14]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 14.
    if (ToInteger2(data[udg_saveDataLength14]) != 0) then
        set data[udg_saveDataLength14] = ToNotation(ToInteger2(data[udg_saveDataLength14]))
    else
        set dataOn[udg_saveDataLength14] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 15 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength15] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 421
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength15] = I2S(dataOn[loopA]) + data[udg_saveDataLength15]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 15.
    if (ToInteger2(data[udg_saveDataLength15]) != 0) then
        set data[udg_saveDataLength15] = ToNotation(ToInteger2(data[udg_saveDataLength15]))
    else
        set dataOn[udg_saveDataLength15] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 16 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength16] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 451
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength16] = I2S(dataOn[loopA]) + data[udg_saveDataLength16]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 16.
    if (ToInteger2(data[udg_saveDataLength16]) != 0) then
        set data[udg_saveDataLength16] = ToNotation(ToInteger2(data[udg_saveDataLength16]))
    else
        set dataOn[udg_saveDataLength16] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 17 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength17] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 481
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength17] = I2S(dataOn[loopA]) + data[udg_saveDataLength17]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 17.
    if (ToInteger2(data[udg_saveDataLength17]) != 0) then
        set data[udg_saveDataLength17] = ToNotation(ToInteger2(data[udg_saveDataLength17]))
    else
        set dataOn[udg_saveDataLength17] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 18 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength18] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 511
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength18] = I2S(dataOn[loopA]) + data[udg_saveDataLength18]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 18.
    if (ToInteger2(data[udg_saveDataLength18]) != 0) then
        set data[udg_saveDataLength18] = ToNotation(ToInteger2(data[udg_saveDataLength18]))
    else
        set dataOn[udg_saveDataLength18] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 19 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength19] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 541
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength19] = I2S(dataOn[loopA]) + data[udg_saveDataLength19]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 19.
    if (ToInteger2(data[udg_saveDataLength19]) != 0) then
        set data[udg_saveDataLength19] = ToNotation(ToInteger2(data[udg_saveDataLength19]))
    else
        set dataOn[udg_saveDataLength19] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 20 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength20] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 571
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength20] = I2S(dataOn[loopA]) + data[udg_saveDataLength20]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 20.
    if (ToInteger2(data[udg_saveDataLength20]) != 0) then
        set data[udg_saveDataLength20] = ToNotation(ToInteger2(data[udg_saveDataLength20]))
    else
        set dataOn[udg_saveDataLength20] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 21 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength21] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 601
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength21] = I2S(dataOn[loopA]) + data[udg_saveDataLength21]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 21.
    if (ToInteger2(data[udg_saveDataLength21]) != 0) then
        set data[udg_saveDataLength21] = ToNotation(ToInteger2(data[udg_saveDataLength21]))
    else
        set dataOn[udg_saveDataLength21] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 22 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength22] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 631
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength22] = I2S(dataOn[loopA]) + data[udg_saveDataLength22]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 22.
    if (ToInteger2(data[udg_saveDataLength22]) != 0) then
        set data[udg_saveDataLength22] = ToNotation(ToInteger2(data[udg_saveDataLength22]))
    else
        set dataOn[udg_saveDataLength22] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 23 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength23] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 661
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength23] = I2S(dataOn[loopA]) + data[udg_saveDataLength23]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 23.
    if (ToInteger2(data[udg_saveDataLength23]) != 0) then
        set data[udg_saveDataLength23] = ToNotation(ToInteger2(data[udg_saveDataLength23]))
    else
        set dataOn[udg_saveDataLength23] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 24 (Save) Information with a numeric value of 0 is excluded from the code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength24] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 691
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength24] = I2S(dataOn[loopA]) + data[udg_saveDataLength24]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 24.
    if (ToInteger2(data[udg_saveDataLength24]) != 0) then
        set data[udg_saveDataLength24] = ToNotation(ToInteger2(data[udg_saveDataLength24]))
    else
        set dataOn[udg_saveDataLength24] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 1 Rewrite (Save)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLength1] = null

    // The dataOn of each data is 0 or 1, and the value is compared with a string.
    set loopA = 1
    set loopExit = 1
    loop
        exitwhen (loopA > udg_saveDataN) or (loopExit > 30)
        set data[udg_saveDataLength1] = I2S(dataOn[loopA]) + data[udg_saveDataLength1]
        set loopExit = loopExit + 1
        set loopA = loopA + 1
    endloop

    // Set the code length value 1.
    if (ToInteger2(data[udg_saveDataLength1]) != 0) then
        set data[udg_saveDataLength1] = ToNotation(ToInteger2(data[udg_saveDataLength1]))
    else
        set dataOn[udg_saveDataLength1] = 0
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length check value (Save) Exclude code length value whose value is 0 from code.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set data[udg_saveDataLengthCheck] = null

    // The value of each code length value is 0 or 1 or more.
    set loopA = udg_saveDataLength1
    loop
        exitwhen loopA > udg_saveDataLength24
        if (ToInteger(data[loopA]) == 0) then
            set data[udg_saveDataLengthCheck] = "0" + data[udg_saveDataLengthCheck]
        else
            set data[udg_saveDataLengthCheck] = "1" + data[udg_saveDataLengthCheck]
        endif
        set loopA = loopA + 1
    endloop

    // Set the code length check value.
    set data[udg_saveDataLengthCheck] = ToNotation(ToInteger2(data[udg_saveDataLengthCheck]))

    // Due to the nature of Warcraft, when the loop returns a certain amount, it waits for a while because the function is forcibly terminated.
    call TriggerSleepAction(0.01)


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Encryption value (Save) If you add new data to the save list, please set it above this comment.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    // Adds an overall number to the decimal encryption value.
    set loopA = 1
    loop
        exitwhen loopA > udg_saveDataN
        if (dataOn[loopA] == 1) and (loopA != udg_saveDataEncryption) then
            set checkNum = checkNum + (ModuloInteger(ToInteger(data[loopA]), R2I(Pow(udg_keyLength, 2))) * (ModuloInteger(loopA, 5) + 1))
        endif
        if (ModuloInteger(loopA, 200) == 0) then
            call TriggerSleepAction(0.01)
        endif
        set loopA = loopA + 1
    endloop

    // Add the code version to the decrypted value in decimal.
    if (udg_saveDataVersion > 999) then
        set checkNum = checkNum + ModuloInteger(udg_saveDataVersion, 1000)
    else
        set checkNum = checkNum + udg_saveDataVersion
    endif

    // Adds the name of the map to the decimal encryption value.
    set checkNum = checkNum + NameToInteger(udg_MapName)

    // Adds the player's ID to the decrypted value in decimal.
    set checkNum = checkNum + NameToInteger(GetPlayerName(p))

    // Encodes the decimal number and sets the data [Encryption value].
    set data[udg_saveDataEncryption] = ToNotation(checkNum)

    // Due to the nature of Warcraft, when the loop returns a certain amount, it waits for a while because the function is forcibly terminated.
    call TriggerSleepAction(0.01)


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Arrange the length of the code appropriately. (Save) If you want to add new data to the save list, please set it above this comment.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // Arrange the length of the code appropriately.
    set loopA = 1
    loop
        exitwhen loopA > udg_saveDataN
        if (dataOn[loopA] == 1) then
            set data[loopA] = CodeLength(data[loopA], udg_saveData[loopA])
            set result = result + data[loopA]
        endif
        set loopA = loopA + 1
    endloop

    // Due to the nature of Warcraft, when the loop returns a certain amount, it waits for a while because the function is forcibly terminated.
    call TriggerSleepAction(0.01)

    // If the code is longer than the chat input maximum of 127, it divides into multiple lines.
    set real1 = StringLength(result) / 127
    if (real1 + 1 == R2I(real1) + 1) then
        set loopExit = R2I(real1)
    else
        set loopExit = R2I(real1) + 1
    endif

    set loopA = 1
    loop
        exitwhen loopExit < 0
        if (StringLength(result) < 127) then
            set saveResult[loopA] = SubString(result, 0, StringLength(result))
        else
            set saveResult[loopA] = SubString(result, 0, 127)
        endif
        set result = SubString(result, 127, StringLength(result))
        set loopA = loopA + 1
        set loopExit = loopExit - 1
    endloop

    // Due to the nature of Warcraft, when the loop returns a certain amount, it waits for a while because the function is forcibly terminated.
    call TriggerSleepAction(0.01)


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Output the save code. (Save) If you want to add new data to the save list, please set it above this comment.
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // You belong to the item.
    call SetItemPlayer(UnitItemInSlot(hero, 0), p, false)
    call SetItemPlayer(UnitItemInSlot(hero, 1), p, false)
    call SetItemPlayer(UnitItemInSlot(hero, 2), p, false)
    call SetItemPlayer(UnitItemInSlot(hero, 3), p, false)
    call SetItemPlayer(UnitItemInSlot(hero, 4), p, false)
    call SetItemPlayer(UnitItemInSlot(hero, 5), p, false)
    call SetItemPlayer(UnitItemInSlot(bag1, 0), p, false)
    call SetItemPlayer(UnitItemInSlot(bag1, 1), p, false)
    call SetItemPlayer(UnitItemInSlot(bag1, 2), p, false)
    call SetItemPlayer(UnitItemInSlot(bag1, 3), p, false)
    call SetItemPlayer(UnitItemInSlot(bag1, 4), p, false)
    call SetItemPlayer(UnitItemInSlot(bag1, 5), p, false)
    call SetItemPlayer(UnitItemInSlot(bag2, 0), p, false)
    call SetItemPlayer(UnitItemInSlot(bag2, 1), p, false)
    call SetItemPlayer(UnitItemInSlot(bag2, 2), p, false)
    call SetItemPlayer(UnitItemInSlot(bag2, 3), p, false)
    call SetItemPlayer(UnitItemInSlot(bag2, 4), p, false)
    call SetItemPlayer(UnitItemInSlot(bag2, 5), p, false)

    // Output the save code as a message.
    set loopA = 1
    loop
        exitwhen loopA > 30
        call PrintCode(p, saveResult[loopA], loopA)
        set loopA = loopA + 1
    endloop

    // Due to the nature of Warcraft, when the loop returns a certain amount, it waits for a while because the function is forcibly terminated.
    call TriggerSleepAction(0.01)

    // Create a text file.
    set loopA = 1
    loop
        exitwhen loopA > udg_saveDataN
        if (dataTextString[loopA] != null) then
            call SaveStr(udg_dataTextStringHash, GetHandleId(p), loopA, dataTextString[loopA])
        else
            call SaveStr(udg_dataTextStringHash, GetHandleId(p), loopA, "0")
        endif
        set loopA = loopA + 1
    endloop

    // Clean up the lines of code.
    set loopA = 1
    loop
        exitwhen loopA > 30
        if (saveResult[loopA] != null) then
            call SaveStr(udg_makeFileHash, GetHandleId(p), loopA, saveResult[loopA])
        endif
        set loopA = loopA + 1
    endloop
    call MakeFile(p, message, I2S(GetUnitLevel(hero)))
    set udg_codeSavingNow[GetConvertedPlayerId(p)] = false

    // Set the free space to get the handle ID value.
    set hero = null
    set bag1 = null
    set bag2 = null
endfunction



//************************************************************************************************************************************************************************
//*
//*  Load function
//*
//************************************************************************************************************************************************************************



function HeroLoad takes player p, string message returns boolean
    local integer array data
    local integer array dataOn
    local integer array lengthOn
    local integer dataStart
    local string dataLength
    local integer encryptionData = 0
    local integer num
    local integer num2
    local real real1
    local integer checkNum = 0
    local integer loopA
    local integer loopExit


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Add the entered code to udg_codeString. This variable is the total string of code in case the code is too long to be split. (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set udg_codeString[GetConvertedPlayerId(p)] = udg_codeString[GetConvertedPlayerId(p)] + message


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length check value (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set dataStart = 0

    // If the code input is first, set the code length check value.
    if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
        set udg_dataLengthCheck[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLengthCheck])
    endif

    // Set dataLength to the code length check value.
    set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLengthCheck[GetConvertedPlayerId(p)])), 24)

    // Sets whether code length values are present or not.
    set loopA = 1
    set loopExit = 24
    loop
        exitwhen (loopA + (udg_saveDataLength1 - 1) > udg_saveDataLength24) or (loopExit < 1)
        set lengthOn[loopA + (udg_saveDataLength1 - 1)] = S2I(SubString(dataLength, loopExit - 1, loopExit))
        set loopA = loopA + 1
        set loopExit = loopExit - 1
    endloop


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 1 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 1 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength1] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength1[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength1])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength1[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 1
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 2 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 2 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength2] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength2[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength2])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength2[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 31
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 3 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 3 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength3] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength3[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength3])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength3[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 61
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 4 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 4 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength4] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength4[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength4])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength4[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 91
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 5 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 5 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength5] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength5[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength5])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength5[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 121
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 6 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 6 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength6] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength6[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength6])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength6[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 151
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 7 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 7 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength7] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength7[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength7])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength7[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 181
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 8 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 8 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength8] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength8[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength8])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength8[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 211
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 9 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 9 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength9] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength9[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength9])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength9[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 241
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 10 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 10 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength10] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength10[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength10])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength10[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 271
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 11 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 11 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength11] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength11[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength11])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength11[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 301
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 12 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 12 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength12] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength12[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength12])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength12[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 331
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 13 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 13 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength13] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength13[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength13])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength13[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 361
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 14 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 14 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength14] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength14[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength14])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength14[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 391
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 15 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 15 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength15] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength15[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength15])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength15[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 421
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 16 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 16 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength16] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength16[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength16])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength16[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 451
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 17 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 17 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength17] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength17[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength17])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength17[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 481
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 18 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 18 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength18] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength18[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength18])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength18[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 511
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 19 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 19 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength19] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength19[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength19])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength19[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 541
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 20 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 20 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength20] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength20[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength20])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength20[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 571
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 21 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 21 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength21] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength21[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength21])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength21[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 601
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 22 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 22 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength22] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength22[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength22])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength22[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 631
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 23 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 23 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength23] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength23[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength23])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength23[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 661
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Code length value 24 (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // If the code length value 24 exists in the code, the following action is executed.
    if (lengthOn[udg_saveDataLength24] == 1) then
        set dataStart = dataStart + 5

        // If code input is first, set the code length value.
        if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
            set udg_dataLength24[GetConvertedPlayerId(p)] = SubString(message, dataStart, dataStart + udg_saveData[udg_saveDataLength24])
        endif

        // Set dataLength to the code length value.
        set dataLength = CodeLength2(ToNotation2(ToInteger(udg_dataLength24[GetConvertedPlayerId(p)])), 30)

        // Compares the code length value and sets whether each data is 1 or more.
        set loopA = 691
        set loopExit = 30
        loop
            exitwhen (loopA > udg_saveDataN) or (loopExit < 1)
            set dataOn[loopA] = S2I(SubString(dataLength, loopExit - 1, loopExit))
            set loopA = loopA + 1
            set loopExit = loopExit - 1
        endloop

    endif

    // Due to the nature of Warcraft, when the loop returns a certain amount, it waits for a while because the function is forcibly terminated.
    call TriggerSleepAction(0.01)


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// If the code is multiple lines, combine the codes. (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set num = 0
    set loopA = 1
    loop
        exitwhen loopA > udg_saveDataN
        if (dataOn[loopA] == 1) then
            set num = num + udg_saveData[loopA]
        endif
        set loopA = loopA + 1
    endloop

    // Due to the nature of Warcraft, when the loop returns a certain amount, it waits for a while because the function is forcibly terminated.
    call TriggerSleepAction(0.01)

    // Sets the number of lines of code if the code entry is first.
    if (udg_codeTypingTick[GetConvertedPlayerId(p)] == 0) then
        set udg_codeLine[GetConvertedPlayerId(p)] = R2I(I2R(num) / 127.0)
    endif

    // If there are more lines of code, add the message to the code and stop it.
    if (udg_codeLine[GetConvertedPlayerId(p)] > 0) then
        set udg_codeLine[GetConvertedPlayerId(p)] = udg_codeLine[GetConvertedPlayerId(p)] - 1
        set udg_codeTypingTick[GetConvertedPlayerId(p)] = udg_codeTypingTick[GetConvertedPlayerId(p)] + 1
        call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0.0, 0.0, 3.0, "|c00DFFB4F" + I2S(udg_codeTypingTick[GetConvertedPlayerId(p)] + 1) + "Please enter the save code in the second line.|r")
        set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
        return false
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Load data (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set num = 0

    // All the data in the code is loaded.
    set loopA = 1
    loop
        exitwhen loopA > udg_saveDataN
        if (dataOn[loopA] == 1) then
            set data[loopA] = ToInteger(SubString(udg_codeString[GetConvertedPlayerId(p)], num, num + udg_saveData[loopA]))

            // If the data is an encryption value, the encryption code entered by the player is set.
            if (loopA == udg_saveDataEncryption) then
                set encryptionData = ToInteger(SubString(udg_codeString[GetConvertedPlayerId(p)], num, num + udg_saveData[loopA]))
            endif
            set num = num + udg_saveData[loopA]
        endif
        if (ModuloInteger(loopA, 100) == 0) then
            call TriggerSleepAction(0.01)
        endif
        set loopA = loopA + 1
    endloop

    // Due to the nature of Warcraft, when the loop returns a certain amount, it waits for a while because the function is forcibly terminated.
    call TriggerSleepAction(0.01)


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Verify that the encryption value is correct. (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    set num = 0
    set num2 = 0

    // Adds an overall number to the decimal encryption value.
    set loopA = 1
    loop
        exitwhen loopA > udg_saveDataN
        if (dataOn[loopA] == 1) and (loopA != udg_saveDataEncryption) then
            set checkNum = checkNum + (ModuloInteger(data[loopA], R2I(Pow(udg_keyLength, 2))) * (ModuloInteger(loopA, 5) + 1))
        endif
        set loopA = loopA + 1
    endloop

    // Add the code version to the decrypted value in decimal.
    if (udg_saveDataVersion > 999) then
        set checkNum = checkNum + ModuloInteger(udg_saveDataVersion, 1000)
    else
        set checkNum = checkNum + udg_saveDataVersion
    endif

    // Adds the name of the map to the decimal encryption value.
    set checkNum = checkNum + NameToInteger(udg_MapName)

    // Adds the player's ID to the decrypted value in decimal.
    set checkNum = checkNum + NameToInteger(GetPlayerName(p))

    // If the encryption value of the decimal number and the value of the input encryption code are different, the loading stops.
    if (checkNum != encryptionData) then
        call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FThe ID is different or the code is wrong.|r")
        set udg_codeTyping[GetConvertedPlayerId(p)] = false
        set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
        return false
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Verify that the data is the correct value. (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // Stops loading if the hero's unit type does not exist in the array set in the setup HeroItem trigger.
    if (udg_saveHero[data[udg_saveDataHeroType]] == 0) then
        call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid unit type.|r")
        set udg_codeTyping[GetConvertedPlayerId(p)] = false
        set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
        return false
    endif

    // Stops loading if the hero's 1st slot item type does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataHeroItem1] != 0) then
        if (udg_saveItem[data[udg_saveDataHeroItem1]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the hero's 2nd slot item type does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataHeroItem2] != 0) then
        if (udg_saveItem[data[udg_saveDataHeroItem2]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the hero's 3rd slot item type does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataHeroItem3] != 0) then
        if (udg_saveItem[data[udg_saveDataHeroItem3]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the hero's 4th slot item type does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataHeroItem4] != 0) then
        if (udg_saveItem[data[udg_saveDataHeroItem4]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the hero's 5th slot item type does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataHeroItem5] != 0) then
        if (udg_saveItem[data[udg_saveDataHeroItem5]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the hero's 6th slot item type does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataHeroItem6] != 0) then
        if (udg_saveItem[data[udg_saveDataHeroItem6]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 1st slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag1Item1] != 0) then
        if (udg_saveItem[data[udg_saveDataBag1Item1]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 2nd slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag1Item2] != 0) then
        if (udg_saveItem[data[udg_saveDataBag1Item2]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 3rd slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag1Item3] != 0) then
        if (udg_saveItem[data[udg_saveDataBag1Item3]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 4th slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag1Item4] != 0) then
        if (udg_saveItem[data[udg_saveDataBag1Item4]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 5th slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag1Item5] != 0) then
        if (udg_saveItem[data[udg_saveDataBag1Item5]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 6th slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag1Item6] != 0) then
        if (udg_saveItem[data[udg_saveDataBag1Item6]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 1st slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag2Item1] != 0) then
        if (udg_saveItem[data[udg_saveDataBag2Item1]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 2nd slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag2Item2] != 0) then
        if (udg_saveItem[data[udg_saveDataBag2Item2]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 3rd slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag2Item3] != 0) then
        if (udg_saveItem[data[udg_saveDataBag2Item3]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 4th slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag2Item4] != 0) then
        if (udg_saveItem[data[udg_saveDataBag2Item4]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 5th slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag2Item5] != 0) then
        if (udg_saveItem[data[udg_saveDataBag2Item5]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif

    // Stops loading if the 6th slot item type of the backpack does not exist in the array set in the setup HeroItem trigger.
    if (data[udg_saveDataBag2Item6] != 0) then
        if (udg_saveItem[data[udg_saveDataBag2Item6]] == 0) then
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cffFF0202Error) |c00DFFB4FInvalid item type.|r")
            set udg_codeTyping[GetConvertedPlayerId(p)] = false
            set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
            return false
        endif
    endif


// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Finish loading. (Load)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    // All the loaded information is stored in a hash table to be applied to the game in the Load trigger.
    set loopA = 1
    loop
        exitwhen loopA > udg_saveDataN
        call SaveInteger(udg_dataHash, GetConvertedPlayerId(p), loopA, data[loopA])
        set loopA = loopA + 1
    endloop

    // Move the camera to the player start position.
    call PanCameraToTimedForPlayer(p, GetLocationX(GetStartLocationLoc(GetPlayerStartLocation(p))), GetLocationY(GetStartLocationLoc(GetPlayerStartLocation(p))), 0.5)

    // Outputs a load completion message.
    call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|c00DFFB4FLoad complete!|r")
    set udg_codeLoadingNow[GetConvertedPlayerId(p)] = false
    set udg_codeTyping[GetConvertedPlayerId(p)] = false
    return true
endfunction

If its too much work to fix then there is no need to change it since the save/load works as it should. But if its just an easy change of text somewhere in the code, it would help alot with players finding the Hero they want to load.

Thanks in advance!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,546
A little bit of Control + Find magic and you should be able to find the file name in the code. (This is a great way to start learning the basics of Jass).

For instance, I found this code which is part of a larger function:
vJASS:
        call Preload("---------------- Chat Message ----------------")
        call Preload(message)
        call Preload("Grabiti's RPG Creator: http://cafe.naver.com/rpgcreator")
        call PreloadGenEnd("ChampionRPG" + "\\" + udg_MapName + "\\" + fileName + ".txt")
        call PreloadEnd(3.0)
        call DisplayTimedTextToPlayer(p, 0.0, 0.0, 10.0, "|cfffffc01\\ChampionRPG\\" + udg_MapName + " _ " + fileName + ".txt.|r\n|c00DFFB4F Grabiti RPG Creator 1.08.|r")
You may recognize some familiar names there. You can modify the text as you see fit, although I'm not sure if that'll break the system or not.

GetPlayerName(p) will get you the Player's name (p is set to a local variable storing the current Player that's saving).
vJASS:
call PreloadGenEnd(GetPlayerName(p) + "\\" + fileName + ".txt")
You can reference the name of your Hero assuming you have a reference to it:
vJASS:
GetUnitName(udg_Player_Hero[GetConvertedPlayerId(p)])
Player_Hero is a Unit array variable. Change it's name to your own hero-tracking variable - assuming you have one.
 
Last edited:
Level 11
Joined
Aug 11, 2009
Messages
594
I am not at a pc right now but found a function MakeFile with loads of local strings, which should be the information within the save file.

And at the bottom was the fileName string which should be where the file name is defined (looking at the part you showed).

Will try and edit these when I get home tonight :D

Thanks alot!
Will report if it worked or not 👍
 
Level 11
Joined
Aug 11, 2009
Messages
594
It was the right place to edit, however "GetUnitName(udg_Player_Hero[GetConvertedPlayerId(p)])" shows the name of the Hero on the experience bar, which I was not after. I need the real name, shown above the experience bar. What is the function for that? :)

EDIT: Nvm, I was too quick to ask, with some logic testing it was "GetHeroProperName(udg_Player_Hero[GetConvertedPlayerId(p)])"

Thanks alot for the help! :D
 
Last edited:
Top