if(dialogid == 1) { //Register
if(response) {
new PlayerName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Elimination/Accounts/%s.json", PlayerName);
if(!djIsSet(string,"Key"))
{
registerPlayer(playerid,inputtext);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
return 1;
}
else return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Invalid Password!", "Warning: This server contains alot of action, and is not for the faint of heart.\nBe advised.\nPlease enter your password below:", "Submit", "Cancel");
}
else
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Invalid Password!", "Warning: This server contains alot of action, and is not for the faint of heart.\nBe advised.\nPlease enter your password below:", "Submit", "Cancel");
}
}
else if(dialogid == 2) { //Login
if(response) {
new PlayerName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Elimination/Accounts/%s.json", PlayerName);
if(djIsSet(string,"Key"))
{
if(playerLoggedIn[playerid] == 1) return SendClientMessage(playerid, sc_LightRed, "ERROR: You are already logged in.");
loginPlayer(playerid,inputtext);
return 1;
}
else return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Invalid Password!", "Warning: This server contains alot of action, and is not for the faint of heart.\nBe advised.\nPlease enter your password below:", "Submit", "Cancel");
}
else
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Invalid Password!", "Warning: This server contains alot of action, and is not for the faint of heart.\nBe advised.\nPlease enter your password below:", "Submit", "Cancel");
}
}
public loginPlayer(playerid,password[])
{
new string[80], CharName[MAX_PLAYER_NAME];
GetPlayerName(playerid, CharName, sizeof(CharName));
format(string, sizeof(string), "Elimination/Accounts/%s.json", CharName);
if(strcmp(dj(string,"Key"),password, true ) == 0 )
{
playerInfo[playerid][IsRegistered]=djInt(string,"IsRegistered");
playerInfo[playerid][Administrator]=djInt(string,"Administrator");
playerInfo[playerid][Cash]=djInt(string,"Cash");
playerInfo[playerid][Skin]=djInt(string,"Skin");
playerInfo[playerid][Experience]=djInt(string,"Experience");
playerInfo[playerid][TimeOnline]=djInt(string,"TimeOnline");
playerInfo[playerid][AccountStatus]=djInt(string,"AccountStatus");
}
else { GameTextForPlayer(playerid, "~w~Authentication~n~~r~rejected", 3000, 1); return 1; }
if(playerInfo[playerid][IsRegistered] == 0)
{
playerInfo[playerid][Cash]=250;
playerInfo[playerid][IsRegistered] = 1;
playerInfo[playerid][AccountStatus] = 0;
playerInfo[playerid][Administrator] = 0;
playerInfo[playerid][TimeOnline] = 0;
playerInfo[playerid][Experience] = 0;
playerInfo[playerid][Skin] = random(300);
}
playerLoggedIn[playerid] = 1;
format(string, sizeof(string), "[script] %s has logged in.", ReturnPlayerName(playerid));
printf(string);
SetPlayerColor(playerid, sc_White);
SetPlayerScore(playerid, playerInfo[playerid][Experience]);
SendClientMessage(playerid, sc_White, " Account found...");
SendClientMessage(playerid, sc_White, " Password correct...");
format(string, sizeof(string), " You have been logged in as '%s'!", ReturnPlayerName(playerid));
SendClientMessage(playerid, sc_Lime, string);
return 1;
}
public registerPlayer(playerid, password[])
{
new string[50], CharName[MAX_PLAYER_NAME];
GetPlayerName(playerid, CharName, sizeof(CharName));
format(string, sizeof(string), "Elimination/Accounts/%s.json", CharName);
djCreateFile(string);
djSet(string,"Key",password);
djSetInt(string,"IsRegistered\n",playerInfo[playerid][IsRegistered]);
djSetInt(string,"AdminLevel\n",playerInfo[playerid][Administrator]);
djSetInt(string,"Cash\n",playerInfo[playerid][Cash]);
djSetInt(string,"Skin\n",playerInfo[playerid][Skin]);
djSetInt(string,"TimeOnline\n",playerInfo[playerid][TimeOnline]);
djSetInt(string,"Experience\n",playerInfo[playerid][Experience]);
djSetInt(string,"AccountStatus\n",playerInfo[playerid][AccountStatus]);
djCommit(string);
loginPlayer(playerid,password);
return 1;
}
What is (not?) happening?
Explain deeper please. [This forum requires that you wait 120 seconds between posts. Please try again in 79 seconds.] I know I'm whining alot, but seriously.. This is ANNOYING! |
#define DIALOG_REGISTER (0)
#define DIALOG_LOGIN (1)
if( dialogid == DIALOG_REGISTER )
Show us where you show the dialogs to the player.
I recommend defining names to the dialogids Example: pawn Code:
|
public OnPlayerConnect(playerid)
{
new string[128];
if(djIsSet(string,"Key")) { //Register
SendClientMessage(playerid, sc_Lime, "Welcome to the Elimination Server!");
SendClientMessage(playerid, sc_White, " This server is currently running version 1.0_R1 of 'Elimination'");
SendClientMessage(playerid, sc_Grey, " Analyzing account status...");
SendClientMessage(playerid, sc_Grey, " Showing register dialog...");
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Welcome to the Elimination Server!", "Warning: This server contains alot of action, and is not for the faint of heart.\nBe advised.\nPlease enter your password below:", "Submit", "Cancel");
playerLoggedIn[playerid] = 0;
}
else { //Login
SendClientMessage(playerid, sc_Lime, "Welcome to the Elimination Server!");
SendClientMessage(playerid, sc_White, "This server is currently running version 1.0_R1 of 'Elimination'");
SendClientMessage(playerid, sc_Grey, " Analyzing account status...");
SendClientMessage(playerid, sc_Grey, " Showing login dialog...");
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Welcome to the Elimination Server!", "Warning: This server contains alot of action, and is not for the faint of heart.\nBe advised.\nPlease enter your password below:", "Submit", "Cancel");
playerLoggedIn[playerid] = 0;
}
return 1;
}
if(!djIsSet(string,"Key"))