Accounts not working
#1

Hi i am using dini and making a saving system but nothing is saving when i set it in the file..

The skin spawns as CJ too.


pawn Код:
stock SavePlayerStats(playerid)
{
 pName = GetPlayerNameEx(playerid);
 new file[128];
 format(file, sizeof(file), "%s.ini", pName);
 if(dini_Exists(file))
 PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
 PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
 dini_IntSet(file,"Cash",PlayerInfo[playerid][pCash]);
 dini_IntSet(file,"Kills",PlayerInfo[playerid][pKills]);
 dini_IntSet(file,"Deaths",PlayerInfo[playerid][pDeaths]);
 dini_IntSet(file,"AdminLevel",PlayerInfo[playerid][pAdmin]);
 dini_IntSet(file,"Phone",PlayerInfo[playerid][pPhone]);
 dini_IntSet(file,"Phonebook",PlayerInfo[playerid][pPhonebook]);
 dini_IntSet(file,"Suicides",PlayerInfo[playerid][pSuicides]);
 dini_IntSet(file,"Skin",PlayerInfo[playerid][pSkin]);
 dini_IntSet(file,"Team",PlayerInfo[playerid][pTeam]);
 dini_IntSet(file,"Drugs",PlayerInfo[playerid][pDrugs]);
 dini_IntSet(file,"Rank",PlayerInfo[playerid][pRank]);
 dini_IntSet(file,"Muted",PlayerInfo[playerid][pMuted]);
 dini_IntSet(file,"Cked",PlayerInfo[playerid][pCked]);
 return 1;
}

stock SaveAllPlayerStats()
{
 for(new i = 0; i < MAX_PLAYERS; i++)
 {
  pName = GetPlayerNameEx(i);
  new file[128];
  format(file, sizeof(file), "%s.ini", pName);
  if(dini_Exists(file))
  PlayerInfo[i][pSkin] = GetPlayerSkin(i);
  PlayerInfo[i][pCash] = GetPlayerMoney(i);
  dini_IntSet(file,"Cash",PlayerInfo[i][pCash]);
  dini_IntSet(file,"Kills",PlayerInfo[i][pKills]);
  dini_IntSet(file,"Deaths",PlayerInfo[i][pDeaths]);
  dini_IntSet(file,"AdminLevel",PlayerInfo[i][pAdmin]);
  dini_IntSet(file,"Phone",PlayerInfo[i][pPhone]);
  dini_IntSet(file,"Phonebook",PlayerInfo[i][pPhonebook]);
  dini_IntSet(file,"Suicides",PlayerInfo[i][pSuicides]);
  dini_IntSet(file,"Skin",PlayerInfo[i][pSkin]);
  dini_IntSet(file,"Team",PlayerInfo[i][pTeam]);
  dini_IntSet(file,"Drugs",PlayerInfo[i][pDrugs]);
  dini_IntSet(file,"Rank",PlayerInfo[i][pRank]);
  dini_IntSet(file,"Muted",PlayerInfo[i][pMuted]);
  dini_IntSet(file,"Cked",PlayerInfo[i][pCked]);
  return 1;
 }
}
If you need more code just let me know.
Reply
#2

You must create register command.
For reading files log in command.
Reply
#3

Yes i have made register and login and all the commands to go with it.
Reply
#4

So,post commands.
Reply
#5

Register & Login.

pawn Код:
// ***** EOF Admin Commands *****

dcmd_register(playerid,params[])
{
 new file[MAX_NAME],pass[15];
 pName = GetPlayerNameEx(playerid);
 format(file, sizeof(file), "%s.ini", pName);
 if(dini_Exists(file)) return SendClientMessage(playerid,COLOR_GREY,"SERVER: This account is already registered!");
 else if(sscanf(params,"s",pass)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /register [password]");
 else
 {
    dini_Create(file);
    format(str, MAX_STRING,"SERVER: You have registered the name %s with the password %s, you may now login", pName, pass);
  SendClientMessage(playerid, COLOR_GREY, str);
  PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
  PlayerInfo[playerid][pAdmin] = 0;
    PlayerInfo[playerid][pPhone] = 0;
    PlayerInfo[playerid][pPhonebook] = 0;
    PlayerInfo[playerid][pKills] = 0;
    PlayerInfo[playerid][pDeaths] = 0;
    PlayerInfo[playerid][pSuicides] = 0;
    PlayerInfo[playerid][pCash] = 0;
    PlayerInfo[playerid][pSkin] = 22;
    PlayerInfo[playerid][pTeam] = 0;
    PlayerInfo[playerid][pRank] = 0;
    PlayerInfo[playerid][pCked] = 0;
    PlayerInfo[playerid][pDrugs] = 0;
    PlayerInfo[playerid][pMuted] = 0;
  dini_Set(file,"Password", pass);
  dini_IntSet(file,"Cash",PlayerInfo[playerid][pCash]);
  dini_IntSet(file,"Kills",PlayerInfo[playerid][pKills]);
  dini_IntSet(file,"Deaths",PlayerInfo[playerid][pDeaths]);
  dini_IntSet(file,"AdminLevel",PlayerInfo[playerid][pAdmin]);
  dini_IntSet(file,"Phone",PlayerInfo[playerid][pPhone]);
  dini_IntSet(file,"Phonebook",PlayerInfo[playerid][pPhonebook]);
  dini_IntSet(file,"Suicides",PlayerInfo[playerid][pSuicides]);
  dini_IntSet(file,"Skin",PlayerInfo[playerid][pSkin]);
  dini_IntSet(file,"Team",PlayerInfo[playerid][pTeam]);
  dini_IntSet(file,"Drugs",PlayerInfo[playerid][pDrugs]);
  dini_IntSet(file,"Rank",PlayerInfo[playerid][pRank]);
  dini_IntSet(file,"Muted",PlayerInfo[playerid][pMuted]);
  dini_IntSet(file,"Cked",PlayerInfo[playerid][pCked]);
  return 1;
 }
}
dcmd_login(playerid,params[])
{
 new file[128],pass[128],rPass[128];
 pName = GetPlayerNameEx(playerid);
 if(sscanf(params,"s",pass)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /login [password]");
 else if(PlayerInfo[playerid][pLogged] == 1) return SendClientMessage(playerid,COLOR_GREY,"SERVER: You are already logged in !");
 format(rPass, 128, "%s", dini_Get(file, "Password"));
 if(strcmp(rPass,pass,false) != 0) return SendClientMessage(playerid,COLOR_GREY,"SERVER: The password you specified is wrong.");
 else
 {
    PlayerInfo[playerid][pLogged] = 1;
    PlayerInfo[playerid][pCash] = dini_Int(file,"Cash");
  PlayerInfo[playerid][pKills] = dini_Int(file,"Kills");
  PlayerInfo[playerid][pDeaths] = dini_Int(file,"Deaths");
  PlayerInfo[playerid][pAdmin] = dini_Int(file,"AdminLevel");
  PlayerInfo[playerid][pPhone] = dini_Int(file,"Phone");
  PlayerInfo[playerid][pPhonebook] = dini_Int(file,"Phonebook");
  PlayerInfo[playerid][pSuicides] = dini_Int(file,"Suicides");
  PlayerInfo[playerid][pSkin] = dini_Int(file,"Skin");
  PlayerInfo[playerid][pTeam] = dini_Int(file,"Team");
  PlayerInfo[playerid][pDrugs] = dini_Int(file,"Drugs");
  PlayerInfo[playerid][pRank] = dini_Int(file,"Rank");
  PlayerInfo[playerid][pMuted] = dini_Int(file,"Muted");
  PlayerInfo[playerid][pCked] = dini_Int(file,"Cked");
  SendClientMessage(playerid,COLOR_GREY,"SERVER: You have sucessfully logged in!");
  SetPlayerSpawnParams(playerid);
  SpawnPlayer(playerid);
  return 1;
 }
}

Reply
#6

try this
pawn Код:
stock SavePlayerStats(playerid)
{
 pName = GetPlayerNameEx(playerid);
 new file[128];
 format(file, sizeof(file), "%s.ini", pName);
 if(dini_Exists(file))
 {
 PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
 PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
 dini_IntSet(file,"Cash",PlayerInfo[playerid][pCash]);
 dini_IntSet(file,"Kills",PlayerInfo[playerid][pKills]);
 dini_IntSet(file,"Deaths",PlayerInfo[playerid][pDeaths]);
 dini_IntSet(file,"AdminLevel",PlayerInfo[playerid][pAdmin]);
 dini_IntSet(file,"Phone",PlayerInfo[playerid][pPhone]);
 dini_IntSet(file,"Phonebook",PlayerInfo[playerid][pPhonebook]);
 dini_IntSet(file,"Suicides",PlayerInfo[playerid][pSuicides]);
 dini_IntSet(file,"Skin",PlayerInfo[playerid][pSkin]);
 dini_IntSet(file,"Team",PlayerInfo[playerid][pTeam]);
 dini_IntSet(file,"Drugs",PlayerInfo[playerid][pDrugs]);
 dini_IntSet(file,"Rank",PlayerInfo[playerid][pRank]);
 dini_IntSet(file,"Muted",PlayerInfo[playerid][pMuted]);
 dini_IntSet(file,"Cked",PlayerInfo[playerid][pCked]);
 }
 else
 {
   dini_Create(file);
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
 PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
 dini_IntSet(file,"Cash",PlayerInfo[playerid][pCash]);
 dini_IntSet(file,"Kills",PlayerInfo[playerid][pKills]);
 dini_IntSet(file,"Deaths",PlayerInfo[playerid][pDeaths]);
 dini_IntSet(file,"AdminLevel",PlayerInfo[playerid][pAdmin]);
 dini_IntSet(file,"Phone",PlayerInfo[playerid][pPhone]);
 dini_IntSet(file,"Phonebook",PlayerInfo[playerid][pPhonebook]);
 dini_IntSet(file,"Suicides",PlayerInfo[playerid][pSuicides]);
 dini_IntSet(file,"Skin",PlayerInfo[playerid][pSkin]);
 dini_IntSet(file,"Team",PlayerInfo[playerid][pTeam]);
 dini_IntSet(file,"Drugs",PlayerInfo[playerid][pDrugs]);
 dini_IntSet(file,"Rank",PlayerInfo[playerid][pRank]);
 dini_IntSet(file,"Muted",PlayerInfo[playerid][pMuted]);
 dini_IntSet(file,"Cked",PlayerInfo[playerid][pCked]);
 }
return 1;
Reply
#7

That`s same action.
Better delete
pawn Код:
if(dini_Exist(file))
Reply
#8

Still doesnt work, Umm..

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)