pawn Код:
OnPlayerLogin(playerid)
{
ClearChatbox(playerid);
ShowLoginBorders(playerid);
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""EMBED_WHITE"Login", ""EMBED_WHITE"Welcome back on test server!\nType your password below to login.", "Login", "Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""EMBED_WHITE"Register", ""EMBED_WHITE"Welcome on test server!\nThe password needs at least two characters.\nType your password below to register a new account:", "Register", "Quit");
}
}
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_PASSWORD, ""EMBED_WHITE"Register",""EMBED_RED"You must write a new password.\n"EMBED_WHITE"Type your password below to register a new account:","Register","Quit");
if(strlen(inputtext) < 2)
return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""EMBED_WHITE"Register",""EMBED_RED"The password must have at least two characters.\n"EMBED_WHITE"Type your password below to register a new account:","Register","Quit");
SetPVarString(playerid, "PasswordEntered", inputtext);
ShowPlayerDialog(playerid, DIALOG_REGISTER_SECRETWORD, DIALOG_STYLE_PASSWORD, ""EMBED_WHITE"You're one step far to play!", ""EMBED_WHITE"You've created an account successfully.\nFor security reasons, please enter also a secret word that will be used in case you'll login with another IP:","Play!","");
}
return 1;
}
case DIALOG_REGISTER_SECRETWORD:
{
if(!response)
{
DeletePVar(playerid, "PasswordEntered");
return Kick(playerid);
}
if(response)
{
if(!strlen(inputtext))
return ShowPlayerDialog(playerid, DIALOG_REGISTER_SECRETWORD, DIALOG_STYLE_PASSWORD, ""EMBED_WHITE"Secret Word", ""EMBED_RED"You must write a secret word.\n"EMBED_WHITE"Type your secret word below to begin playing:", "Play!", "Quit");
if(strlen(inputtext) < 2)
return ShowPlayerDialog(playerid, DIALOG_REGISTER_SECRETWORD, DIALOG_STYLE_PASSWORD, ""EMBED_WHITE"Secret Word", ""EMBED_RED"The secret word must have at least two characters.\n"EMBED_WHITE"Type your secret word below to begin playing:", "Play!", "Quit");
new
passwordEntered[250];
GetPVarString(playerid, "PasswordEntered", passwordEntered, sizeof(passwordEntered));
DeletePVar(playerid, "PasswordEntered");
new
INI:File = INI_Open(UserPath(playerid)),
HashPass[250],
HashSecretWord[250],
IPAddress[64];
INI_SetTag(File, "PlayerData");
WP_Hash(HashPass, sizeof(HashPass), passwordEntered);
WP_Hash(HashSecretWord, sizeof(HashSecretWord), inputtext);
GetPlayerIp(playerid, IPAddress, sizeof(IPAddress));
INI_WriteString(File, "Password", HashPass);
INI_WriteString(File, "SecretWord", HashSecretWord);
INI_WriteString(File, "IP", IPAddress);
INI_WriteInt(File, "Money", 0);
INI_WriteInt(File, "Admin", 0);
INI_WriteInt(File, "Kills", 0);
INI_WriteInt(File, "KillStreak", 0);
INI_WriteInt(File, "Deaths", 0);
INI_SetTag(File, "WeaponData");
INI_WriteInt(File, "WeaponTime1", 0);
INI_WriteInt(File, "WeaponKills1", 0);
INI_WriteInt(File, "WeaponTime2", 0);
INI_WriteInt(File, "WeaponKills2", 0);
INI_WriteInt(File, "WeaponTime3", 0);
INI_WriteInt(File, "WeaponKills3", 0);
INI_WriteInt(File, "WeaponTime4", 0);
INI_WriteInt(File, "WeaponKills4", 0);
INI_WriteInt(File, "WeaponTime5", 0);
INI_WriteInt(File, "WeaponKills5", 0);
INI_WriteInt(File, "WeaponTime6", 0);
INI_WriteInt(File, "WeaponKills6", 0);
INI_WriteInt(File, "WeaponTime7", 0);
INI_WriteInt(File, "WeaponKills7", 0);
INI_WriteInt(File, "WeaponTime8", 0);
INI_WriteInt(File, "WeaponKills8", 0);
INI_WriteInt(File, "WeaponTime9", 0);
INI_WriteInt(File, "WeaponKills9", 0);
INI_WriteInt(File, "WeaponTime10", 0);
INI_WriteInt(File, "WeaponKills10", 0);
INI_WriteInt(File, "WeaponTime11", 0);
INI_WriteInt(File, "WeaponKills11", 0);
INI_WriteInt(File, "WeaponTime12", 0);
INI_WriteInt(File, "WeaponKills12", 0);
INI_WriteInt(File, "WeaponTime13", 0);
INI_WriteInt(File, "WeaponKills13", 0);
INI_WriteInt(File, "WeaponTime14", 0);
INI_WriteInt(File, "WeaponKills14", 0);
INI_WriteInt(File, "WeaponTime15", 0);
INI_WriteInt(File, "WeaponKills15", 0);
INI_WriteInt(File, "WeaponTime16", 0);
INI_WriteInt(File, "WeaponKills16", 0);
INI_WriteInt(File, "WeaponTime17", 0);
INI_WriteInt(File, "WeaponKills17", 0);
INI_WriteInt(File, "WeaponTime18", 0);
INI_WriteInt(File, "WeaponKills18", 0);
INI_WriteInt(File, "WeaponTime19", 0);
INI_WriteInt(File, "WeaponKills19", 0);
INI_WriteInt(File, "WeaponTime20", 0);
INI_WriteInt(File, "WeaponKills20", 0);
INI_WriteInt(File, "WeaponTime21", 0);
INI_WriteInt(File, "WeaponKills21", 0);
INI_WriteInt(File, "WeaponTime22", 0);
INI_WriteInt(File, "WeaponKills22", 0);
INI_WriteInt(File, "WeaponTime23", 0);
INI_WriteInt(File, "WeaponKills23", 0);
INI_WriteInt(File, "WeaponTime24", 0);
INI_WriteInt(File, "WeaponKills24", 0);
INI_WriteInt(File, "WeaponTime25", 0);
INI_WriteInt(File, "WeaponKills25", 0);
INI_WriteInt(File, "WeaponTime26", 0);
INI_WriteInt(File, "WeaponKills26", 0);
INI_WriteInt(File, "WeaponTime27", 0);
INI_WriteInt(File, "WeaponKills27", 0);
INI_WriteInt(File, "WeaponTime28", 0);
INI_WriteInt(File, "WeaponKills28", 0);
INI_WriteInt(File, "WeaponTime29", 0);
INI_WriteInt(File, "WeaponKills29", 0);
INI_WriteInt(File, "WeaponTime30", 0);
INI_WriteInt(File, "WeaponKills30", 0);
INI_WriteInt(File, "WeaponTime31", 0);
INI_WriteInt(File, "WeaponKills31", 0);
INI_WriteInt(File, "WeaponTime32", 0);
INI_WriteInt(File, "WeaponKills32", 0);
INI_WriteInt(File, "WeaponTime33", 0);
INI_WriteInt(File, "WeaponKills33", 0);
INI_WriteInt(File, "WeaponTime34", 0);
INI_WriteInt(File, "WeaponKills34", 0);
INI_WriteInt(File, "WeaponTime35", 0);
INI_WriteInt(File, "WeaponKills35", 0);
INI_WriteInt(File, "WeaponTime36", 0);
INI_WriteInt(File, "WeaponKills36", 0);
INI_WriteInt(File, "WeaponTime37", 0);
INI_WriteInt(File, "WeaponKills37", 0);
INI_WriteInt(File, "WeaponTime38", 0);
INI_WriteInt(File, "WeaponKills38", 0);
INI_WriteInt(File, "WeaponTime39", 0);
INI_WriteInt(File, "WeaponKills39", 0);
INI_WriteInt(File, "WeaponTime40", 0);
INI_WriteInt(File, "WeaponKills40", 0);
INI_WriteInt(File, "WeaponTime41", 0);
INI_WriteInt(File, "WeaponKills41", 0);
INI_WriteInt(File, "WeaponTime42", 0);
INI_WriteInt(File, "WeaponKills42", 0);
INI_WriteInt(File, "WeaponTime43", 0);
INI_WriteInt(File, "WeaponKills43", 0);
INI_WriteInt(File, "WeaponTime44", 0);
INI_WriteInt(File, "WeaponKills44", 0);
INI_WriteInt(File, "WeaponTime45", 0);
INI_WriteInt(File, "WeaponKills45", 0);
INI_WriteInt(File, "WeaponTime46", 0);
INI_WriteInt(File, "WeaponKills46", 0);
INI_Close(File);
PlayerInfo[playerid][pStatus] = 2; // I JUST logged in.
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
HideLoginBorders(playerid);
ShowPlayerDialog(playerid, DIALOG_REGISTER_SUCCESS, DIALOG_STYLE_MSGBOX, ""EMBED_WHITE"You've made it!", ""EMBED_GREEN"You have successfully made a new account!", "Got it!", "");
}
return 1;
}
case DIALOG_LOGIN:
{
if(!response)
return Kick(playerid);
if(response)
{
new
HashPass[250],
PlayerIP[64];
WP_Hash(HashPass, sizeof(HashPass), inputtext);
//strdel(HashPass, strlen(HashPass)-1, strlen(HashPass));
printf("%s", HashPass);
GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));
if(strmatch(HashPass, PlayerInfo[playerid][pPassword]))
{
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
if(strmatch(PlayerIP, PlayerInfo[playerid][pIP]))
{
PlayerInfo[playerid][pStatus] = 2; // I JUST logged in.
HideLoginBorders(playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN_SUCCESS, DIALOG_STYLE_MSGBOX,""EMBED_WHITE"Success!",""EMBED_GREEN"You have successfully logged in!","Got it!","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN_SECRETWORD, DIALOG_STYLE_PASSWORD, ""EMBED_RED"Secret Word Needed!", ""EMBED_WHITE"Your IP address doesn't match to your last login.\nEnter your secret word:", "Done!", "Quit");
}
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""EMBED_WHITE"Login", ""EMBED_RED"You have entered an incorrect password.\n"EMBED_WHITE"Type your password below to login:", "Login", "Quit");
}
}
return 1;
}
case DIALOG_LOGIN_SECRETWORD:
{
if(!response)
return Kick(playerid);
if(response)
{
new
HashSecretWord[250];
WP_Hash(HashSecretWord, sizeof(HashSecretWord), inputtext);
//strdel(HashSecretWord, strlen(HashSecretWord)-1, strlen(HashSecretWord));
if(strmatch(HashSecretWord, PlayerInfo[playerid][pSecretWord]))
{
PlayerInfo[playerid][pStatus] = 2; // I JUST logged in.
HideLoginBorders(playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN_SUCCESS, DIALOG_STYLE_MSGBOX,""EMBED_WHITE"Success!",""EMBED_GREEN"You have successfully logged in!","Got it!","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""EMBED_WHITE"Login", ""EMBED_RED"You have entered an incorrect secret word.\n"EMBED_WHITE"Type your secret word below to login:", "Done!", "Quit");
}
}
return 1;
}
case DIALOG_LOGIN_SUCCESS:
{
if(response || !response)
SpawnPlayer(playerid);
}
}
return 1;
}