09.08.2013, 18:11
Hello,
i have already did a topic on the french part of the forum:
No solution so i decided to post here, ^^, so, in game, i have a dialog who tell me to register, it work, but on my deconnection nothing appear in the .ini, but one is created with pseudo.ini
there are the differents script:
full game mode: http://pastebin.com/D1zS6YaD
Thanks in advance for helping ! And tell me if you didn't understand something !
i have already did a topic on the french part of the forum:
Quote:
a command /removeadmin, but when the player reconnect, he's admin again conclusion: writing problem in the .ini |
there are the differents script:
pawn Код:
enum pInfo
{
pMdp, // pPassword in english
pArgent, // pCash
pAdmin,
pKills,
pDeaths,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,COL_WHITE"Login",COL_WHITE"Entrez votre mot de passe pour vous connecter.","Login","Quitter");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,COL_WHITE"Enregistrement",COL_WHITE"Entrez un mot de passe pour votre compte.","Valider","Quitter");
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
gJob[playerid] = 0;
PlayerInfo[playerid][pAdmin] = 0;
checkpoint = 0;
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Enregistrement",""COL_RED"Il faut inserer un mot de passe !\n"COL_WHITE"Entrez votre password ci dessous pour enregistrer votre compte","Valider","Quitter");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);
SaveAccount(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Validй !",""COL_GREEN"Bienvenue ! Reconnectez vous pour sauvegarder vos stats","Ok","");
}
}
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
if(response)
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pMdp] )
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pArgent]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Validй!",""COL_GREEN"Connexion rйussie ! Bon jeu !","Ok","");
if(PlayerInfo[playerid][pAdmin] == 1)
{
new playername[MAX_PLAYER_NAME];
new str[124];
GetPlayerName(playerid, playername, sizeof(playername));
format(str, sizeof(str), "L'administrateur %s vient de se connecter !", playername);
SendClientMessageToAll(COLOR_ADMIN, str);
}
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"Vous avez entrй un mot de passe incorrect.\n"COL_WHITE"Entre votre mot de passe ci dessous pour vous connecter.","Login","Quitter");
}
return 1;
}
}
}
return 1;
}
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pMdp]);
INI_Int("Cash",PlayerInfo[playerid][pArgent]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
Thanks in advance for helping ! And tell me if you didn't understand something !