02.02.2013, 18:13
When someone is logging in, they can enter any password and get in with any account.
Anyone know how to fix this?
Anyone know how to fix this?
pawn Код:
#include <a_samp>
#include <YSI\y_ini>
#include <zcmd>
#define UserPath "Users/%s.ini"
enum PlayerInfo
{
Pass,
Admin,
Cash
}
new pInfo[MAX_PLAYERS][PlayerInfo],Text:sfrp;
stock Path(playerid)
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),UserPath,name);
return str;
}
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
INI_Int("Password", pInfo[playerid][Pass]);
INI_Int("Admin",pInfo[playerid][Admin]);
INI_Int("Cash",pInfo[playerid][Cash]);
return 1;
}
main() {}
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
if(fexist(Path(playerid)))
{
INI_ParseFile(Path(playerid),"loadaccount_user", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid,1,3,"Login","Type in your password to login","Login","Leave");
}
else
{
ShowPlayerDialog(playerid,2,3,"Registration","Type in a password to register","Register","Cancel");
return 1;
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 2)
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,2,3,"Registration","Type in a password to register","Register","Cancel");
return 1;
}
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Stats");
INI_WriteString(file,"Password",inputtext);
INI_WriteInt(file,"Admin",0);
INI_WriteInt(file,"Cash",0);
INI_Close(file);
return 1;
}
}
if(dialogid == 1)
{
if(!response) return Kick(playerid);
if(response)
{
if(strcmp(inputtext,pInfo[playerid][Pass],true,strlen(inputtext)))
{
INI_ParseFile(Path(playerid),"loadaccount_user",.bExtra = true, .extra = playerid);
GivePlayerMoney(playerid,pInfo[playerid][Cash]);
}
else
{
ShowPlayerDialog(playerid,1,3,"Login","Type in your password to login\nIncorrect password!","Login","Cancel");
return 1;
}
}
}
return 1;
}
public OnPlayerDisconnect(playerid,reason)
{
if(fexist(Path(playerid)))
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Stats");
INI_WriteInt(file,"Admin",pInfo[playerid][Admin]);
INI_WriteInt(file,"Cash",GetPlayerMoney(playerid));
INI_Close(file);
return 1;
}
return 1;
}