Register system problem -
arjanforgames - 12.07.2013
Hello,
I have a problem.
If the player joins the game and is asked to register and he presses quit, he will get kicked.
But the system still save's his information exept for his password, so if he relogs his account is "registered" but it has no password. How can I fix this?
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response)
{
Kick(playerid);
}
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Registering",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type a password below to register a new account.","Register","Quit");
}
else
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Level",0);
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"VIP",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Ores", 0);
INI_WriteInt(File,"Metal", 0);
INI_WriteInt(File,"Wood", 0);
INI_WriteInt(File,"Rocks", 0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, -80.8000000,-1134.5999800,0.7000000, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SendClientMessage(playerid, COLOR_GREEN, "* Succesfully registered!");
}
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SetSpawnInfo(playerid, 0, 0, -80.8000000,-1134.5999800,0.7000000, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SendClientMessage(playerid, COLOR_GREEN, "* Succesfully logged in!");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login","Login","Quit");
}
return 1;
}
}
}
return 0;
}
Re: Register system problem -
arjanforgames - 12.07.2013
I dont like bumping but..
BUMP
Re: Register system problem -
TheStreetsRP - 12.07.2013
Код:
if (response != 1)
{
return Kick(playerid);
}
Re: Register system problem -
CrazyChoco - 12.07.2013
Quote:
Originally Posted by TheStreetsRP
Код:
if (response != 1)
{
return Kick(playerid);
}
|
It should be
pawn Код:
if(!response) return Kick(playerid);
if(response)
{
//Your code here
}
What do you have under onplayerdisconnect?
Re: Register system problem -
TheStreetsRP - 12.07.2013
They're effectively the exact same thing.
Re: Register system problem -
arjanforgames - 12.07.2013
I had that at first but I'm having the same result.
Re: Register system problem -
SilverKiller - 12.07.2013
Make a variable like :
pawn Код:
new Block[MAX_PLAYERS]; // At the top of the gamemode under #include lines.
Then in OnPlayerConnect put :
And :
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response)
{
Kick(playerid);
}
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Registering",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type a password below to register a new account.","Register","Quit");
}
else
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Level",0);
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"VIP",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Ores", 0);
INI_WriteInt(File,"Metal", 0);
INI_WriteInt(File,"Wood", 0);
INI_WriteInt(File,"Rocks", 0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, -80.8000000,-1134.5999800,0.7000000, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SendClientMessage(playerid, COLOR_GREEN, "* Succesfully registered!");
Block[playerid] = 1;
}
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SetSpawnInfo(playerid, 0, 0, -80.8000000,-1134.5999800,0.7000000, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SendClientMessage(playerid, COLOR_GREEN, "* Succesfully logged in!");
Block[playerid] = 0;
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login","Login","Quit");
}
return 1;
}
}
}
return 0;
}
Then in OnPlayerDisconnect add this line before any other code in the callback :
pawn Код:
if(Block[playerid] == 1) return 1;
And everything should work..
Hope i helped.
Re: Register system problem -
arjanforgames - 12.07.2013
Already fixed thanks to:
Quote:
Originally Posted by CrazyChoco
What do you have under onplayerdisconnect?
|
Thanks for helping, +rep