Yeah its me again, im gonna try to use this for all questions related for this systeem for here on out
Heres my current code
Ok, obviously 2 things
1) cut out a bunch of stuff you didnt need to see
2) There is no function for clicking a load button dialog
3) Exit dialog button has no text, its just elseif .. endif
Heres my current 4 problems
1) "Other Page" and "Exit Menu" dont display, the button is there but there isnt text
2) I dont think its writing properly. If i save a hero and than try to save again, the slot still says empty
3) It prints the debug "lol" (in the save on click trigger) a ton of times
4) Other Page functions as if it was a save slot, printing lol a ton
Heres my current code
JASS:
struct Demo extends array
private static Base encryptionKey
private static method saveWithLocal takes nothing returns boolean
local NumberStack stack = BigInt.create(encryptionKey)
local string encrypted
local integer i = 21
local string s
set SaveTriggers[GetPlayerId(GetTriggerPlayer())] = CreateTrigger()
set SaveDialog[GetPlayerId(GetTriggerPlayer())] = DialogCreate()
call TriggerAddAction(SaveTriggers[GetPlayerId(GetTriggerPlayer())], function thistype.onSaveDialogClick)
//push numbers on to stack (save two values)
//value max
call SaveHeroLevel(udg_PlayerUnit[GetConvertedPlayerId(GetTriggerPlayer())], stack)
call SaveGold(stack, GetTriggerPlayer())
call SaveCustomInventory(stack, GetTriggerPlayer())
call SaveHero(stack, GetTriggerPlayer())
//display numbers in stack
call DisplayTimedTextToPlayer(GetTriggerPlayer(),0,0,60,"Saving: 10,20")
//encryption
//EncryptNumber takes BigInt number, integer security, integer shuffles,
// integer forPlayerId, string playerSalt, real checksumVariance
// returns string
///////////////////////////////////////////////////////////////////////////////////////////////
//numbers checksum (1 out of xxxx codes work) shuffles (1-3)
// if freeze, lower
set encrypted=EncryptNumber(stack, 1000000, 3, /*
//player to save for //password //don't change
*/ GetPlayerId(GetTriggerPlayer()), "salt value", .85)
//add dashes
set encrypted=AddRepeatedString(encrypted,"-",4,0) //add "-" every 4 characters starting at 0
//color //number lowercase uppercase special char (! ? *) start
//colors are hexadecimal color codes december.com/html/spec/color2.html
set encrypted=ColorCodeString(encrypted, "40e0d0", "ff69b4", "00AA00", "ffff00", 0)
//display code code string
call AddBoolean(101, true, GetTriggerPlayer())
call SaveData("f9ksl0ALS", GetTriggerPlayer())
call LoadData("f9ksl0ALS", GetTriggerPlayer())
if ReadBoolean(101, GetTriggerPlayer()) != true then
call print("Your computer does not have localized storing enabled. Type '-write' and you will get further instructions to enable. Untill then, this code will overwrite your first slot")
call AddString(1, encrypted, GetTriggerPlayer())
call SaveData("f9ksl0ALS", GetTriggerPlayer())
else
loop
set s = ReadString(i, GetTriggerPlayer())
if StringLength(s) < 5 then
set SaveButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)] = DialogAddButton(SaveDialog[GetPlayerId(GetTriggerPlayer())], "Empty Slot", i - 20)
call TriggerRegisterDialogButtonEvent(SaveTriggers[GetPlayerId(GetTriggerPlayer())], SaveButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)])
else
set SaveButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)] = DialogAddButton(SaveDialog[GetPlayerId(GetTriggerPlayer())], s, i - 20)
call TriggerRegisterDialogButtonEvent(SaveTriggers[GetPlayerId(GetTriggerPlayer())], SaveButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)])
endif
set i = i + 1
exitwhen i == 31
endloop
set SaveButtonArray[(21) + (GetPlayerId(GetTriggerPlayer()) * 20)] = DialogAddButton(SaveDialog[GetPlayerId(GetTriggerPlayer())], s, 21)
call TriggerRegisterDialogButtonEvent(SaveTriggers[GetPlayerId(GetTriggerPlayer())], SaveButtonArray[(21) + (GetPlayerId(GetTriggerPlayer()) * 20)])
set SaveButtonArray[(22) + (GetPlayerId(GetTriggerPlayer()) * 20)] = DialogAddButton(SaveDialog[GetPlayerId(GetTriggerPlayer())], s, 22)
call TriggerRegisterDialogButtonEvent(SaveTriggers[GetPlayerId(GetTriggerPlayer())], SaveButtonArray[(22) + (GetPlayerId(GetTriggerPlayer()) * 20)])
call DialogDisplay(GetTriggerPlayer(), SaveDialog[GetPlayerId(GetTriggerPlayer())], true)
set EncryptionString[GetPlayerId(GetTriggerPlayer())] = encrypted
endif
call print("The")
//destroy stack (clean up, prevent leaks)
call stack.destroy()
return false
endmethod
private static method loadWithCode takes nothing returns boolean
local player GP=GetTriggerPlayer()
local string s=GetEventPlayerChatString()
local NumberStack stack
set s=RemoveString(s,GetEventPlayerChatStringMatched(),1, 0)
set s=RemoveString(s," ",0,0)
set s=RemoveString(s,"-",0,0)
if (0<StringLength(s)) then
set stack = DecryptNumber(s, encryptionKey, 1000000,/*
shuffles used in encryption played id to decrypt for
*/ 3, GetPlayerId(GetTriggerPlayer()),/*
password used in encryption don't change
*/ "salt value", .85)
if (0!=stack) then
call RemoveUnit(udg_PlayerUnit[GetConvertedPlayerId(GP)])
call LoadHero(stack, GP)
call SetHeroMain(GetLastCreatedUnit(),GP)
call LoadCustomInventory(stack, GP)
call LoadGold(stack, GP)
call LoadHeroLevel(udg_PlayerUnit[GetConvertedPlayerId(GetTriggerPlayer())], stack)
private static method loadWithBank takes nothing returns boolean
local integer i = 20
local string s
set LoadTriggers[GetPlayerId(GetTriggerPlayer())] = CreateTrigger()
set LoadDialog[GetPlayerId(GetTriggerPlayer())] = DialogCreate()
loop
set s = ReadString(i, GetTriggerPlayer())
if StringLength(s) < 5 then
set LoadButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)] = DialogAddButton(LoadDialog[GetPlayerId(GetTriggerPlayer())], "Empty Slot", i - 20)
call TriggerRegisterDialogButtonEvent(LoadTriggers[GetPlayerId(GetTriggerPlayer())], LoadButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)])
else
set LoadButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)] = DialogAddButton(LoadDialog[GetPlayerId(GetTriggerPlayer())], s, i - 20)
call TriggerRegisterDialogButtonEvent(LoadTriggers[GetPlayerId(GetTriggerPlayer())], LoadButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)])
endif
set i = i + 1
exitwhen i == 31
endloop
set LoadButtonArray[(21) + (GetPlayerId(GetTriggerPlayer()) * 20)] = DialogAddButton(LoadDialog[GetPlayerId(GetTriggerPlayer())], "Other Page", 21)
call TriggerRegisterDialogButtonEvent(LoadTriggers[GetPlayerId(GetTriggerPlayer())], LoadButtonArray[(21) + (GetPlayerId(GetTriggerPlayer()) * 20)])
set LoadButtonArray[(22) + (GetPlayerId(GetTriggerPlayer()) * 20)] = DialogAddButton(LoadDialog[GetPlayerId(GetTriggerPlayer())], "Exit Menu", 22)
call TriggerRegisterDialogButtonEvent(LoadTriggers[GetPlayerId(GetTriggerPlayer())], LoadButtonArray[(22) + (GetPlayerId(GetTriggerPlayer()) * 20)])
call DialogDisplay(GetTriggerPlayer(), LoadDialog[GetPlayerId(GetTriggerPlayer())], true)
return false
endmethod
private static method onInit takes nothing returns nothing
local integer i = 0
set encryptionKey=Base["0123456789abcdefghijklmnopqrstuvwxyz"]
call InitSave("-savecode", "-loadcode", Condition(function thistype.saveWithCode),/*
load function
*/Condition(function thistype.loadWithCode))
call InitSave("-savebank", "-loadbank", Condition(function thistype.saveWithLocal),/*
load function
*/Condition(function thistype.loadWithBank))
loop
call CreateData(Player(i))
call LoadData("f9ksl0ALS", Player(i))
set i = i + 1
exitwhen i == 11
endloop
endmethod
private static method onSaveDialogClick takes nothing returns nothing
local integer i2 = 0
local integer i = 30
local string s
if GetClickedDialog() == SaveButtonArray[21 + (20 * GetPlayerId(GetTriggerPlayer()))] then
loop
set s = ReadString(i, GetTriggerPlayer())
if StringLength(s) < 5 then
set SaveButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)] = DialogAddButton(SaveDialog[GetPlayerId(GetTriggerPlayer())], "Empty Slot", i - 20)
call TriggerRegisterDialogButtonEvent(SaveTriggers[GetPlayerId(GetTriggerPlayer())], SaveButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)])
else
set SaveButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)] = DialogAddButton(SaveDialog[GetPlayerId(GetTriggerPlayer())], s, i - 20)
call TriggerRegisterDialogButtonEvent(SaveTriggers[GetPlayerId(GetTriggerPlayer())], SaveButtonArray[(i - 20) + (GetPlayerId(GetTriggerPlayer()) * 20)])
endif
set i = i + 1
exitwhen i == 41
endloop
elseif GetClickedDialog() == SaveButtonArray[21 + (20 * GetPlayerId(GetTriggerPlayer()))] then
endif
loop
if GetClickedDialog() == SaveButtonArray[i2 + (20 * GetPlayerId(GetTriggerPlayer()))] then
call AddString(i2, EncryptionString[GetPlayerId(GetTriggerPlayer())], GetTriggerPlayer())
call AddString(i2 + 20, "Level " + I2S(GetHeroLevel(udg_PlayerUnit[GetPlayerId(GetTriggerPlayer())])) + " " + GetUnitName(udg_PlayerUnit[GetPlayerId(GetTriggerPlayer())]), GetTriggerPlayer())
call print("lol")
set i2 = 500
endif
set i2 = i + 1
exitwhen i2 == 21
endloop
endmethod
endstruct
Ok, obviously 2 things
1) cut out a bunch of stuff you didnt need to see
2) There is no function for clicking a load button dialog
3) Exit dialog button has no text, its just elseif .. endif
Heres my current 4 problems
1) "Other Page" and "Exit Menu" dont display, the button is there but there isnt text
2) I dont think its writing properly. If i save a hero and than try to save again, the slot still says empty
3) It prints the debug "lol" (in the save on click trigger) a ton of times
4) Other Page functions as if it was a save slot, printing lol a ton