02.01.2016, 23:56
When I finished this register login system I barely faced any problems.
Now, when the player registers to the server, his password gets hashed, but whenever the player leaves the hashed password gets the variable "0"...
system
Now, when the player registers to the server, his password gets hashed, but whenever the player leaves the hashed password gets the variable "0"...
system
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
new string[75], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof string, "%s has left the server.", pName);
SendClientMessageToAll(COLOR_GREY, string);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File, "PlayerData");
INI_WriteInt(File, "Password", PlayerInfo[playerid][Password]);
INI_WriteInt(File, "Admin", PlayerInfo[playerid][AdminLevel]);
INI_WriteInt(File, "Money", PlayerInfo[playerid][Money]);
INI_WriteInt(File, "Vip", PlayerInfo[playerid][VipLevel]);
INI_WriteInt(File, "Mechanic", PlayerInfo[playerid][Mechanic]);
INI_WriteInt(File, "SupportMember", PlayerInfo[playerid][SupportMember]);
INI_WriteInt(File, "Hitman", PlayerInfo[playerid][Hitman]);
INI_WriteInt(File, "Saaf", PlayerInfo[playerid][Saaf]);
INI_WriteInt(File, "Sapd", PlayerInfo[playerid][Sapd]);
INI_WriteInt(File, "Drivinglicense", PlayerInfo[playerid][Drivinglicense]);
INI_Close(File);
PHP код:
public OnDialogResponse()
if(dialogid==6)
{
if(response == 0)
{
SendClientMessage(playerid, COLOR_RED, "You have been kicked automatically.");
SetTimerEx("DelayedKick", 50, false, "i", playerid);
Kick(playerid);
}
if(response == 1)
{
if(strlen(inputtext) < 3) return SendClientMessage(playerid, COLOR_RED, "Error: You must create a password with atleast 3 characters.");
//ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_PASSWORD, "Xtreme Gaming Freeroam/Roleplay - Registration", "Xtreme Gaming Freeroam/Roleplay - Fill a password to register", "Register", "Leave");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File, "PlayerData");
INI_WriteInt(File, "Password", udb_hash(inputtext));
INI_WriteInt(File, "Admin", 0);
INI_WriteInt(File, "Money", 0);
INI_WriteInt(File, "Vip", 0);
INI_WriteInt(File, "Mechanic", 0);
INI_WriteInt(File, "SupportMember", 0);
INI_WriteInt(File, "Hitman", 0);
INI_WriteInt(File, "Saaf", 0);
INI_WriteInt(File, "Sapd", 0);
INI_WriteInt(File, "Drivinglicense", 0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 23, -2654.2371,608.3632,14.4531,358.4422, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
}
if(dialogid==7)
{
if(response == 0)
{
SendClientMessage(playerid, COLOR_RED, "You have been kicked automatically.");
SetTimerEx("DelayedKick", 50, false, "i", playerid);
Kick(playerid);
}
if(response == 1)
{
if(udb_hash(inputtext) == PlayerInfo[playerid][Password])
{
new string[75];
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
format(string, sizeof string, "%s has succesfully registered to our server!", PlayerName(playerid));
ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_PASSWORD, "Xtreme Gaming Freeroam/Roleplay - Login", "Xtreme Gaming Freeroam/Roleplay - Enter your password to login", "Login", "Leave");
SendClientMessage(playerid, -1, "Your account has been succesfully restored.");
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error: Incorrect password.");
ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_PASSWORD, "Xtreme Gaming Freeroam/Roleplay - Login", "Xtreme Gaming Freeroam/Roleplay - Enter your password to login", "Login", "Leave");
}
}
}
PHP код:
forward LoadUser_data(playerid, name[], value[]);
public LoadUser_data(playerid, name[], value[])
{
INI_Int("Password", PlayerInfo[playerid][Password]);
INI_Int("Admin", PlayerInfo[playerid][AdminLevel]);
INI_Int("Money", PlayerInfo[playerid][Money]);
INI_Int("Vip", PlayerInfo[playerid][VipLevel]);
INI_Int("Mechanic", PlayerInfo[playerid][Mechanic]);
INI_Int("SupportMember", PlayerInfo[playerid][SupportMember]);
INI_Int("Hitman", PlayerInfo[playerid][Hitman]);
INI_Int("Saaf", PlayerInfo[playerid][Saaf]);
INI_Int("Sapd", PlayerInfo[playerid][Sapd]);
INI_Int("Drivinglicense", PlayerInfo[playerid][Drivinglicense]);
return 1;
}
stock UserPath(playerid)
{
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof string, "/Users/%s.txt", pName);
return string;
}