Quote:
Originally Posted by Imperialistic
I noticed an error that I didn't want to happen..
When I load all of the variables from the .txt file, it only loads the last var entered, any clue why?
=EDIT= Can a mod please move this thread out of the Code Gallery?
|
You're only using one name. If you want multiple slots you'd want something like this
PHP Code:
function onActionServerSide(cmd, slot, msg) {
if (cmd == "save") {
temp.vars.loadVars("data/" @ player.account @ ".txt");
vars.(@ slot) = msg;
vars.saveVars("data/" @ player.account @ ".txt", false);
} else if (cmd == "load") {
temp.vars.loadVars("data/"@ player.account @ ".txt");
if (vars.(@ slot) != null) {
player.chat = "You don't have a message with the name '" @ slot @ "'!";
} else {
player.chat = slot @ ": " @ vars.(@ slot);
}
}
}
//#CLIENTSIDE
function onPlayerChats() {
if (player.chat.starts("/load ")) {
temp.load = player.chat.substring(6).trim();
triggerServer("gui", this.name, "load", load);
} else if (player.chat.starts("/save ")) {
temp.tokens = player.chat.tokenize();
temp.msg = player.chat.substring(tokens[0].length() + tokens[1].length() + 2).trim();
triggerServer("gui", this.name, "save", tokens[1], msg);
}
}
Notice how it uses a different variable for each slot.