[SOLVED] getsaveinfo and playername issue

I'm trying to write a script that unlocks characters based on what character was used to complete a set. I came across getsaveinfo, where "playername" was supposed to be a property option. But when I test out the output of that property, I keep getting the following error:

Code:
Script function 'getsaveinfo' returned an exception, check the manual for details.
 parameters: 0, "playername",

Does this mean that the information was not saved or something?
 
Hi Digital Brillance Hour, can you post please the script and how do you use it in your character?
There is surely in your error log a value that is undefined or incorrectly defined.
 
Hi kimono

I just used updated.c inside of the main function just to print it out:

Code:
voide main() {
     if (openborvariant("in_titlescreen")) {
      loadgamefile();
      log(getsaveinfo(0, "name"));
      //log(getsaveinfo(1, "health"));
      log(getsaveinfo(1, "playername"));
      log(getsaveinfo(0, "times_completed"));
     }
}

So "name" and "times_completed" print out the right information. But "playername" gives that error in log file. I haven't done anything in the player file yet.
 
Dangit, sorry kimono , those were supposed to be zeros in that paste. I pasted in stuff I was testing out.

So it should've been:

Code:
voide main() {
     if (openborvariant("in_titlescreen")) {
      loadgamefile();
      log(getsaveinfo(0, "name"));
      //log(getsaveinfo(0, "health"));
      log(getsaveinfo(0, "playername"));
      log(getsaveinfo(0, "times_completed"));
     }
}
 
Hi there. I saw some points there
- it's void, not voide
- you are making a reference to something (a variable) that you don't know if it even exists yet and you should avoid to do that. Because you may be target a null point and this is a instant crash.
Frost check of the values exists, then get the values.
 
Digital Brilliance Hour,

Playername is indeed part of save info, but you are overlooking something important - WHICH player? You need to provide that as well (and it is 0 indexed).

Code:
log(getsaveinfo(0, "playername", 0)); // Player 1.
log(getsaveinfo(0, "playername", 1)); // Player 2.
log(getsaveinfo(0, "playername", 2)); // Player 3.
log(getsaveinfo(0, "playername", 3)); // Player 4.

Also, just for the record, I wouldn't use OpenBOR's built in save data if you paid me. There's nothing wrong with it really, but the way it works is more like save states in an emulator. If you want to make a true in game RPG style save system, I suggest you look up filestreams. OpenBOR has full CRUD capability with text/bin files.

DC
 
Actually, Damon Caskey  that information was exactly what I needed. I didn't realize there was a 3rd parameter I could use. Yeah I was aiming for player 1 in my testing.

Sorry about yesterday, was trying to multitask while answer the question and the code I pasted had typos, ugh.. But yes, what you just posted was exactly what I wanted to know.

Thanks so much for this everyone! Sorry for the misinformation.
 
Back
Top Bottom