Dini problem -
Twinki1993 - 28.02.2012
Aight, I've got a problem with Dini. It's just simply not saving things at all...
I tried using many things bellow OnPlayerDissconect but aint helping.. Please gimme some help here...
Code for the reg and log
PHP код:
if(strcmp(cmd, "/register", true) == 0)
{
new name[MAX_PLAYER_NAME];
tmp = strtok(cmdtext, idx);
GetPlayerName(playerid, name, sizeof(name));
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /register [password]");
format(file,sizeof(file),"%s.ini",name);
if(!fexist(file))
{
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(tmp));
dini_IntSet(file,"AdminLevel", 0);
dini_IntSet(file,"Cash", 0);
dini_IntSet(file,"Score", 0);
SendClientMessage(playerid, COLOR_WHITE, "[System]: Account Created!");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
GetPlayerName(playerid, name, sizeof(name));
printf("%s has registered a account!", name);
}
else
{
SendClientMessage(playerid, COLOR_RED, " Account Already Found In Database");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
}
}
if(strcmp(cmd, "/login", true) == 0)
{
new PlayerName[24];
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /login [password]");
new name[MAX_PLAYER_NAME];
if(IsLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "You already are logged in!");
return 1;
}
else
{
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"%s.ini",name);
if(fexist(file))
{
tmp2 = dini_Get(file, "Password");
if(udb_hash(tmp) != strval(tmp2))
{
SendClientMessage(playerid, COLOR_RED, "Login Failed!");
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
printf("%s has failed to login", name);
}
else
{
IsLogged[playerid] = 1;
SetPlayerMoney(playerid, dini_Int(file, "Cash"));
SetPlayerScore(playerid, dini_Int(file, "Score"));
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
SendClientMessage(playerid, COLOR_WHITE, "[System]: Account Logged into!");
}
}
}
return 1;
}
Re: Dini problem -
iGetty - 28.02.2012
Try to set a timer for when someone's logged in.
Say:
pawn Код:
forward SaveTimer(playerid);
SetTimerEx("SaveTimer", 1000, 1, "i", playerid); // Under /login command
public SaveTimer(playerid)
{
//Your dini stuff here.
return 1;
}
Just a suggestion.
Re: Dini problem -
Twinki1993 - 28.02.2012
Tried with that stuff to. Well the thing is happening is that it's sometimes saving it when I make it just it's creating new folders... It's not saving in the current ones.
Re: Dini problem -
iGetty - 28.02.2012
Hmmm. Have you checked the whole code?
Re: Dini problem -
Twinki1993 - 28.02.2012
Yeah. The thing is, when player registers it makes his file. Then when he goes off it makes an empty folder called "Score".
Re: Dini problem -
Twinki1993 - 28.02.2012
This is my dissconect code.
PHP код:
new string[128], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Scores/%s.ini", PlayerName);
if(fexist(string))
{
dini_IntSet(string, "Score", GetPlayerScore(playerid));
}
else
{
dini_Create(string);
dini_IntSet(string, "Score", GetPlayerScore(playerid));
}
Re: Dini problem -
milanosie - 28.02.2012
dudeu, why Scores/%s.ini?
The other file is just %s.ini
Re: Dini problem -
StreetGT - 28.02.2012
i use a public in OnPlayerDisconnect for Save, look:
pawn Код:
public OnPlayerStatsUpdate(playerid)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid])
{
new conta[128];
conta = UserPath(playerid); // tenta
if(dini_Exists(conta))
{
dini_Create(conta);
dini_IntSet(conta,"Level",PInfo[playerid][Level]);
dini_IntSet(conta,"Admin",PInfo[playerid][Admin]);
dini_IntSet(conta,"Idade",PInfo[playerid][Age]);
dini_IntSet(conta,"Sexo",PInfo[playerid][Sexo]);
dini_IntSet(conta,"FactionL",PInfo[playerid][FactionL]);
dini_IntSet(conta,"FactionM",PInfo[playerid][FactionM]);
dini_IntSet(conta,"Telemovel",PInfo[playerid][Telemovel]);
dini_IntSet(conta,"TelNR",PInfo[playerid][TelNR]);
dini_IntSet(conta,"TipoCard",PInfo[playerid][TipoCard]);
dini_IntSet(conta,"Rank",PInfo[playerid][Rank]);
dini_IntSet(conta,"Job",PInfo[playerid][Job]);
dini_IntSet(conta,"WLevel",PInfo[playerid][WantedLevel]);
dini_IntSet(conta,"Jail",PInfo[playerid][Jail]);
dini_IntSet(conta,"JailID",PInfo[playerid][JailID]);
dini_IntSet(conta,"JailTime",PInfo[playerid][JailTime]);
PInfo[playerid][Cash] = PlayerGetMoney(playerid);
dini_IntSet(conta,"Cash",PInfo[playerid][Cash]);
dini_IntSet(conta,"Bank",PInfo[playerid][Bank]);
dini_IntSet(conta,"ChaveCasa",PInfo[playerid][ChaveCasa]);
dini_IntSet(conta,"Registed",PInfo[playerid][Reg]);
dini_IntSet(conta,"Skin",PInfo[playerid][Skin]);
dini_IntSet(conta,"Kills",PInfo[playerid][Kills]);
dini_IntSet(conta,"Deaths",PInfo[playerid][Deaths]);
dini_IntSet(conta,"LSpawn",PInfo[playerid][LSpawn]);
dini_IntSet(conta,"Tempo",PInfo[playerid][Tempo]);
dini_IntSet(conta,"CarroL",PInfo[playerid][CarroL]);
dini_IntSet(conta,"MotaL",PInfo[playerid][MotaL]);
dini_IntSet(conta,"VehPID",PInfo[playerid][VehPID]);
dini_IntSet(conta,"Tutorial",PInfo[playerid][Tutorial]);
dini_IntSet(conta,"Limite",PInfo[playerid][Limite]);
if ((PInfo[playerid][pPos_x]==0.0 && PInfo[playerid][pPos_y]==0.0 && PInfo[playerid][pPos_z]==0.0))
{
PInfo[playerid][pPos_x] = 1684.9;
PInfo[playerid][pPos_y] = -2244.5;
PInfo[playerid][pPos_z] = 13.5;
}
dini_FloatSet(conta,"Pos_x",PInfo[playerid][pPos_x]);
dini_FloatSet(conta,"Pos_y",PInfo[playerid][pPos_y]);
dini_FloatSet(conta,"Pos_z",PInfo[playerid][pPos_z]);
}
}
}
}
Re: Dini problem -
Twinki1993 - 29.02.2012
Still dont get it how to make it
Re: Dini problem -
Nuke547 - 29.02.2012
I believe it is just dini_int. Not dini_intset