public loadaccount(playerid, name[], value[])
{
INI_String("Password", pInfo[playerid][Pass],129);
INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);
INI_Int("DonatorLevel",pInfo[playerid][DonatorLevel]);
INI_Int("Money",pInfo[playerid][Money]);
INI_Int("BankMoney",pInfo[playerid][BankMoney]);
INI_Int("Level",pInfo[playerid][Level]);
INI_Int("Experience",pInfo[playerid][Experience]);
INI_Int("Kills",pInfo[playerid][Kills]);
INI_Int("Deaths",pInfo[playerid][Deaths]);
INI_Int("Military",pInfo[playerid][Military]);
INI_Int("MilitaryRank",pInfo[playerid][MilitaryRank]);
INI_Int("MilitaryCustomRank",pInfo[playerid][MilitaryCustomRank]);
INI_Int("SpawnSelection",pInfo[playerid][SpawnSelection]);
INI_Int("Skin",pInfo[playerid][Skin]);
INI_Int("Citizenship",pInfo[playerid][Citizenship]);
return 1;
}
forward loadaccount(playerid, name[], value[]);
public OnPlayerConnect(playerid)
{
SetPlayerColor(playerid, -1);
new string[128], Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
format(string, sizeof(string), "Users/%s.ini", Name);
INI_ParseFile(Path(playerid),"loadaccount", .bExtra = true, .extra = playerid);
SetSpawnInfo(playerid, -1, pInfo[playerid][Skin], -1, -1, -1, 0, -1, -1, -1, -1, -1, -1);
new string3[128];
new string2[128];
format(string3, sizeof(string3), "Welcome to Call of Vengeance Roleplay, %s! {00FF00}[CoV:RP V0.0.1.2 | Copyright© 2012 Nathan Mader]", getFirstName(playerid));
SendClientMessage(playerid, 0xBFBFBFFF, string3);
if(fexist(string))
{
format(string2, sizeof(string2), "Welcome back to Call of Vengeance Roleplay, {00FFFF}%s!\n{FFFFFF}You have an account, please enter your password to continue!", pRPName(Name));
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string2, "Login", "Quit");
}
if(!fexist(string))
{
format(string2, sizeof(string2), "Welcome to Call of Vengeance Roleplay, {00FFFF}%s!\n{FFFFFF}Please enter a desired password below to continue!", pRPName(Name));
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register...", string2, "Register", "Cancel");
}
return 1;
}
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
SendClientMessage(playerid, 0x6F6F6FFF, "ERROR: You must entered a password! (No attempts have been legitimately made)");
new string2[128];
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
format(string2, sizeof(string2), "Welcome back to Call of Vengeance Roleplay, {0000FF}%s!\n{FFFFFF}You have an account, please enter your password to continue!", pRPName(Name));
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string2, "Login", "Quit");
}
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass,pInfo[playerid][Pass]))
{
SetPlayerScore(playerid,pInfo[playerid][Level]);
GivePlayerMoney(playerid,pInfo[playerid][Money]);
SpawnPlayer(playerid);
pInfo[playerid][PlayerLoggedIn] = 1;
}
else
{
if(pInfo[playerid][WrongPass] >= 3)
{
Kick(playerid);
}
else if(pInfo[playerid][WrongPass] < 3)
{
pInfo[playerid][WrongPass]++;
new string2[128];
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
SendClientMessage(playerid, 0x6F6F6FFF, "ERROR: You have entered an invalid password!");
format(string2, sizeof(string2), "Welcome back to Call of Vengeance Roleplay, {0000FF}%s!\n{FFFFFF}You have an account, please enter your password to continue!", pRPName(Name));
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string2, "Login", "Quit");
return 1;
}
}
}
}
case DIALOG_REGISTER:
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
SendClientMessage(playerid, 0x6F6F6FFF, "ERROR: You must entered a password to register under!");
}
else
{
if(strlen(inputtext) >= 5 && strlen(inputtext) < 20)
{
ShowPlayerDialog(playerid, DIALOG_ORIGIN, DIALOG_STYLE_LIST, "Select your citizenship...", "American\nGerman\nChinese\nFrench\nOther/None", "Okay", "Quit");
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteString(file,"Password",hashpass);
INI_WriteInt(file,"Age",0);
INI_WriteInt(file,"AdminLevel",0);
INI_WriteInt(file,"DonatorLevel",0);
INI_WriteInt(file,"Money",500);
INI_WriteInt(file,"BankMoney", 2500);
INI_WriteInt(file,"Level",1);
INI_WriteInt(file,"Kills",0);
INI_WriteInt(file,"Deaths",0);
INI_WriteInt(file,"Military",0);
INI_WriteInt(file,"MilitaryRank",0);
INI_WriteInt(file,"MilitaryCustomRank",0);
INI_WriteInt(file,"SpawnSelection",0);
INI_WriteInt(file,"Citizenship",0);
INI_Close(file);
return 1;
}
else
{
new string2[128], Name[MAX_PLAYER_NAME];
SendClientMessage(playerid, 0x7F7F7FFF, "Passwords must be longer than 4 characters but less than 20!");
format(string2, sizeof(string2), "Welcome to Call of Vengeance Roleplay, {00FFFF}%s!\n{FFFFFF}Please enter a desired password below to continue!", pRPName(Name));
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register...", string2, "Register", "Cancel");
}
}
}
}
INI_ParseFile(Path(playerid),"loadaccount", .bExtra = true, .extra = playerid, .bPassTag = true);
forward loadaccount(playerid, tag[], name[], value[]);
public loadaccount(playerid, tag[], name[], value[])
Ah yes. You've set a tag "Player's Data", so you'll have to make a callback with that tag-name in it - or simply just load all tags.
If you wanna do the last part, you can simply change your ParseFile line to this: pawn Код:
pawn Код:
|