dini problems. Stats dont save.
#1

Basically I followed a tutorial found on this forums.
The values I got is;

- AdminLevel
- PlayerSkin
- PlayerMoney
- PlayerScore

For some reason it's only the Adminlevel that fully works.
Money NEVER save.
Skins save on re-log, but not on server restart.
------------------------------------------
pawn Код:
new logged[MAX_PLAYERS];
enum pInfo
{
    AdminLevel,
    PlayerMoney,
    PlayerScore,
    PlayerSkin,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
----------------
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[128];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(file,sizeof(file),"/Users/%s.ini",name);
        if(dini_Exists(file))
        {
            dini_IntSet(file, "PlayerScore", PlayerInfo[playerid][PlayerScore]);
            dini_IntSet(file, "PlayerMoney", PlayerInfo[playerid][PlayerMoney]);
            dini_IntSet(file, "PlayerSkin", PlayerInfo[playerid][PlayerSkin]);
            dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel]);
        }
        logged[playerid] = 0;
    new string[64], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string,sizeof string,"[Join/Quit] %s has left the server.",pName);
    SendClientMessageToAll(color_grey,string);
    return 1;
}
------------------
pawn Код:
public OnPlayerSpawn(playerid)
{
    new file[128];
    SetPlayerPos(playerid, spawnpoint);
    SetPlayerMoney(playerid, dini_Int(file, "PlayerMoney")-GetPlayerMoney(playerid));
    SetPlayerScore(playerid, PlayerInfo[playerid][PlayerScore]);
    SetPlayerSkin(playerid, PlayerInfo[playerid][PlayerSkin]);
    SetPlayerColor(playerid, color_white);
    return 1;
}
---------------------

pawn Код:
dcmd_register(playerid, params[])
{
  new file[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, color_white, "Hint: Use /register [password] to register your character.");
  if(dini_Exists(file)) return SendClientMessage(playerid, color_white, "Hint: You are already registered. If this is your account, use /login.");
  dini_Create(file);
  dini_IntSet(file, "hashPW", udb_hash(params));
  dini_Set(file, "password", params);
  dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel] = 0);
  dini_IntSet(file, "PlayerScore", PlayerInfo[playerid][PlayerScore] = 0);
  dini_IntSet(file, "PlayerMoney", PlayerInfo[playerid][PlayerMoney] = 500);
  dini_IntSet(file, "PlayerSkin", PlayerInfo[playerid][PlayerSkin] = 60);
  new string[128];
  format(string, 128, "Hint: You succesfully registered the nickname %s with password %s.", pname, params);
  SendClientMessage(playerid, color_green, string);
  logged[playerid] = 1;
  SendClientMessage(playerid, color_green, "Hint: You have been automatically logged in!");
  SpawnPlayer(playerid);
  printf("*** USER REGISTERED :: USERNAME: %s || PASSWORD: %s ***", pname, params);
  return 1;
}
pawn Код:
dcmd_login(playerid, params[])
{
  new file[128];
  new string[MAX_STRING], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, color_white, "Hint: Use /login [password] to log into your character account.");
  if(!dini_Exists(file)) return SendClientMessage(playerid, color_white, "Hint: You are not registered, use /register to register a new account.");
  if(logged[playerid]) return SendClientMessage(playerid, color_white, "Hint: You are already logged in.");
  new tmp;
  tmp = dini_Int(file, "hashPW");
  if(udb_hash(params) != tmp)
  {
    format(string, 256, "Error: Wrong password for username: %s.", pname);
    SendClientMessage(playerid, color_red, string);
  }
  else
  {
    TogglePlayerSpectating(playerid, 0);
    logged[playerid] = 1;
    PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
    format(string, 256, "Hint: Successfully logged into account: %s.", pname);
        SendClientMessage(playerid,color_green, string);
    SpawnPlayer(playerid);
    printf("*** USER LOGGED IN :: USERNAME: %s || ID: (%i) || PASSWORD: %s ***", pname, playerid, params);
  }
  return 1;
}
Anyone see the problem? I sure don't.

This is the CMD I use for changing someones skin.

pawn Код:
dcmd_setskin(playerid, params[])
{
    new id, pskin, pname[MAX_PLAYER_NAME];
    new file[128];
    new string[128];
    if(PlayerInfo[playerid][AdminLevel] <2) return SendClientMessage(playerid, color_red, "* You do not have access to execute this command.");
    if(sscanf(params, "ud", id, pskin)) return SendClientMessage(playerid, color_yellow, "* AdmHint: Usage /setskin [id] [skin id]");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid, color_red, "Hint: Player is not connected.");
    SetPlayerSkin(id, pskin);
    pskin = GetPlayerSkin(id);
    dini_IntSet(file, "PlayerSkin",PlayerInfo[playerid][PlayerSkin] = pskin);
    GetPlayerName(id, pname, MAX_PLAYER_NAME);
    format(string, sizeof(string), "* AdmHint: You changed %s's skin to skinID: %d.", pname, pskin);
    SendClientMessage(playerid, color_yellow, string);
    return 1;
}
Reply
#2

Do you have the Users folder in script files?
Reply
#3

Yes. And the stats saves in the userfolder, but if I relog (without restart) I only load the skin, not the money. Even if I put 873498578394 dollars into the Userfolder and onto my name, i'll spawn with 0 dollars. The skin saves on relog, but not on RESTART. And the AdminLevel save properly. Even on RESTART.
Reply
#4

Yo! Can anyone spare a minute to see where I've gone wrong here?
Reply
#5

You need to assign "file" to the destination.
Reply
#6

Could you give me an example? I'm new with dini system.
Reply
#7

*dump*
I've heard that people say dini is easy. How come no one can help me out here?
Reply
#8

I'll give you an example of what Larzi said, Here 'file' is just an empty array.
pawn Код:
dcmd_setskin(playerid, params[])
{
    new id, pskin, pname[MAX_PLAYER_NAME];
    new file[128];//nothing is done with this
    new string[128];
    if(PlayerInfo[playerid][AdminLevel] <2) return SendClientMessage(playerid, color_red, "* You do not have access to execute this command.");
    if(sscanf(params, "ud", id, pskin)) return SendClientMessage(playerid, color_yellow, "* AdmHint: Usage /setskin [id] [skin id]");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid, color_red, "Hint: Player is not connected.");
    SetPlayerSkin(id, pskin);
    pskin = GetPlayerSkin(id);
    dini_IntSet(file, "PlayerSkin",PlayerInfo[playerid][PlayerSkin] = pskin);
    GetPlayerName(id, pname, MAX_PLAYER_NAME);
    format(string, sizeof(string), "* AdmHint: You changed %s's skin to skinID: %d.", pname, pskin);
    SendClientMessage(playerid, color_yellow, string);
    return 1;
}
But if you look at your second piece of code it has this
pawn Код:
format(file,sizeof(file),"/Users/%s.ini",name);
Making 'file' a destination. Hope this helps.
Reply
#9

Alright thanks. I will try that later on today once I get home. Really hope this works!
Reply
#10

Nope, didnt work Iggy1. Still the same stats problem.
PM me your MSN adrs, and i'll send you the whole script so you can have a look if you want. Its just the basic saving system and some test CMD's thats in there anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)