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];
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_String("Password", pInfo[playerid][Pass]);
INI_Int("Admin",pInfo[playerid][Admin]);
INI_Int("Cash",pInfo[playerid][Cash]);
return 1;
}
main() {}
public OnGameModeInit()
{
EnableStuntBonusForAll(0);
DisableInteriorEnterExits();
SetGameModeText("SF:RP 1.0");
SFRP = TextDrawCreate(30,430,"San Fierro Roleplay");
TextDrawFont(SFRP,0);
return 1;
}
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
if(fexist(Path(playerid)))
{
INI_ParseFile(Path(playerid),"loadaccount_%s", .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","Leave");
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","Leave");
return 1;
}
//If they have entered a correct password for his/her account...
new pass;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Stats");
INI_WriteString(file,"Password",pass);
INI_WriteInt(file,"Admin",0);
INI_WriteInt(file,"Cash",25);
INI_Close(file);
//Tell to them that they have successfully registered a new account
return 1;
}
}
if(dialogid == 1)
{
if(!response) return Kick(playerid);
if(response)
{
if(!strcmp(pass,pInfo[playerid][Pass])) //If they have insert their correct password
{
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
GivePlayerMoney(playerid,pInfo[playerid][Cash]);
}
else
{
ShowPlayerDialog(playerid,1,3,"Login","Type in your password to login\nIncorrect password!","Login","Leave");
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,"Money",GetPlayerMoney(playerid));
INI_Close(file);
return 1;
}
return 1;
}