Banks
Author: Slaydon (udmod.com)Tags: intermediate trigger bank  
Source: http://www.udmod.com/showthread.php...Added 13 years ago 


Summary
Banks are locally saved data, which can be used in all kinds of map depending on its name, therefore a unique name is needed like your own map name. So it won't overwrite banks. There is a problem that these can be edited with notepad, which allows hacking in your map.
Banks are saved here: "C:\Users\UserName\Documents\StarCraft II\Banks"

When you open them with notepad a string saved to it, it will look like this:

<?xml version="1.0" encoding="utf-8"?>
<Bank version="1">
<Section name="1">
<Key name="1">
<Value text="Yo Udmod"/>
</Key>
</Section>
</Bank>


Hopefully the editable part is temporarily. The uses of a bank is a lot of stuff, first of all, it can be used to save stuff in a campaign, or a multiplayer map like scores and such. You can save the most important stuff and more, where the important stuff is

Making of banks
In this chapter you will learn how to save banks on your computer for the player, and save something to it, and see how you load something from it as well.

First you will need to open your trigger editor, and create a new trigger. Give it the event "Chat Message" Game - Player Any Player types a chat message containing "-save", matching Exactly

You will now have an event for the player saving his bank, we will get back to this trigger later.
Create a new global variable, call it Bank and set the array to [14], or your player count.

Create a new trigger, or edit the Map Initialization trigger, call it whatever you want. Set the event to Map Initialization. Pop up a new action and search for "Preload Bank" Set the "Name" to your map name.
Do this for all players.
Now, open up your save trigger which you made earlier.

Pop up a new action, search for Store, or open the Bank tab, I will be using Point.
Set the value to what you want to store, depending on your value, in my case my value will be "Position of (Nova [Cords will stand here])", if you are creating units later in the map, its highly suggested to add the value to a variable, if you do my value would've been "Position of (Hero[Triggering Player])". Variables for the unit is REQUIRED for online.

Set the key to be "HeroData" for example, then set the section to "Point" in bank "Bank(Triggering Player)"

Pop up another action and search for "Save Bank" and set that to "Bank(Triggering Player)", Save Bank is REQUIRED for the bank to be saved onto your computer. When you execute your map and write "-save", you will notice that the bank file is added to your bank folder I mentioned earlier.

That's the Save trigger. NOTE: You can store data without having to use the save action, you can even save all the time, but you can store items in a loop, and save them by typing "-save".

Your trigger will look like this:



Now you need to create a new trigger, call it Load.
Set the event to Chat message, use the same as in the Save trigger, just this time with "-load"
Pop up a new action and search "Open Bank" This will open the bank files, remember to set the Bank name to your map name, or what you set your bank to in your Initialization. Set the player to "Triggering Player" this will load the Bank file in your bank folder.

Then another action, use the Set Variable and set the Bank[Triggering Player] to last opened bank

Then pop up another action with the action of: Move Unit (Instantly) then you choose your hero, in my case Nova [Coords] then you press to Value, and set it to Bank - Load Point Value, and set it to KEY and your SECTION, HeroData and Point. This will load your saved point. Now set the Bank to "Bank[Triggering Player]"

And that's it, you made a Bank, which saves and loads the Unit position, please note that you can load it on map initialization, save it every 1 second, but this is just a preview of what banks can do.


Notes
- Bank files can only go up to 30,000 letters
- Banks are really powerful tools for RPGs, as these can save your whole progress, use it wisely.
- Note that you cant save anything with the players name, this is because blizzard handles cheating a lot.
- There might be a small delay before the bank gets saved, so don't expect the load to work the first second.
- Using small numbers instead of detailed keys is an advantage, as it reduces the file size. Like Key name 1, then you write as a memo that 1 = HeroData in keys, and then Section to 1, then you add to the memo that 1 in sections equals point. Then you create variables for the value in a number, for example you could use 1 for true in booleans and 0 for false.






Star Depot
Contact      Login