Saving dini stats in new folder
#1

How to make in script like this:
Код:
public OnPlayerDisconnect(playerid, reason)
{
  new file[MAX_PLAYER_NAME+5], name[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name, sizeof(name));
  format(file, sizeof(file), SAVE_FILE, name);
  dini_IntSet(file, "Score", GetPlayerScore(playerid));
return 1;
}
that this stats would save in /scriptfiles/mygamemode/users

now it just saves in scriptfiles folder
Reply
#2

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  new file[MAX_PLAYER_NAME+25], name[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name, sizeof(name));
  format(file, sizeof(file), "mygamemode/users/%s.txt", name);
  dini_IntSet(file, "Score", GetPlayerScore(playerid));
  return 1;
}
Don't forget to create that directory!
Reply
#3

And how to load it when the player re-connects?
Reply
#4

The same way, just with loading and not setting.

pawn Код:
public OnPlayerConnect(playerid, reason)
{
  new file[MAX_PLAYER_NAME+25], name[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name, sizeof(name));
  format(file, sizeof(file), "mygamemode/users/%s.txt", name);
  SetPlayerScore(playerid, dini_IntGet(file, "Score"));    //Is it Get? not sure about dini
  return 1;
}
Reply
#5

pawn Код:
public OnPlayerConnect(playerid)
{
  new file[MAX_PLAYER_NAME + 25];
  GetPlayerName(playerid, file, sizeof file);
  format(file, sizeof file, "mygamemode/users/%s", file);
  SetPlayerScore(playerid, dini_Int(file, "Score"));
}
Obvious

Dunno if this is correct dini usage, I hate it anyways lol.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)