Strange? What's Wrong With This
#1

Something's not working in my OnPlayerLogin function, When you join the server you will get a dialog saying to login, When you type it in(Your password, whtever) Nothing happens. Code Below for (OnPlayerLogin):

Код:
public OnPlayerLogin(playerid,password[])
{
  new string2[128];
  new name[MAX_PLAYER_NAME], string[48];
  GetPlayerName(playerid, name, sizeof(name));
	format(string2, sizeof(string2), "South-WestRP/%s.ini", name);
	new File: UserFile = fopen(string2, io_read);
	if ( UserFile )
	{
	  new PassData[256];
	  new keytmp[256], valtmp[256];
	  fread( UserFile , PassData , sizeof( PassData ) );
	  keytmp = ini_GetKey( PassData );
	  if( strcmp( keytmp , "Key" , true ) == 0 )
		{
			valtmp = ini_GetValue( PassData );
			strmid(PlayerInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 255);
		}
		if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
		{
			  new key[ 256 ] , val[ 256 ];
			  new Data[ 256 ];
			  while ( fread( UserFile , Data , sizeof( Data ) ) )
				{
					key = ini_GetKey( Data );
					if( strcmp( key , "Age" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAge] = strval( val ); }
					if( strcmp( key , "Religon" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pReligon] = strval( val ); }
        }
        fclose(UserFile);
		}
		else
		{

			ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Login to your account","Note - A account with this name was found inside the database,\n If this is your account,type in your password\n if not press cancel!","Login","Cancel");
		  SendClientMessage(playerid, 0xFFFFFFFF, "Password does not match the username!");
		  LoginTry[playerid] += 1;
		  if(LoginTry[playerid] == MAX_TRY)
		  {
		    SendClientMessage(playerid, COLOR_SYSTEM, "-------------------------------");
		    SendClientMessage(playerid, COLOR_SYSTEM, "    You Were Banned     ");
		    SendClientMessage(playerid, COLOR_SYSTEM, "Admin who banned you - SYSTEM");
		    SendClientMessage(playerid, COLOR_SYSTEM, "Reason - Failure to login to account maximum times");
		    SendClientMessage(playerid, COLOR_SYSTEM, "Type - Perma. Ban");
		    SendClientMessage(playerid, COLOR_SYSTEM, "   Press F8 to take a picture of this");
		    SendClientMessage(playerid, COLOR_SYSTEM, "-------------------------------");
		    BanEx(playerid, "Failure to login 3 times");
		  }
	    fclose(UserFile);
	    return 1;
		}
	}
	return 1;
}
'

Here is the code on OnDialogResponse
Код:
if(dialogid == 2)
  {
    if(!strlen(inputtext))
    {
      SendClientMessage(playerid, 0xFFFFFFFF, "Your Password Cannot be left Blank");
      return 1;
    }
    if(!response){ SendClientMessage(playerid, 0xFFFFFFFF, "You canceled!"); Kick(playerid); return 0; }
    OnPlayerLogin(playerid,inputtext);
	}
Reply
#2

It seems that your password your entering (or the password it is returning) is incorrect, since the only place that OnPlayerLogin wouldn't do anything, is after the password is incorrect. (It would only close the file, thus no indication)
Reply
#3

Try this:
pawn Код:
if(dialogid == 2)
{
  if(response)
  {
    if(!strlen(inputtext))
    {
      SendClientMessage(playerid, 0xFFFFFFFF, "Your Password Cannot be left Blank");
      return 1;
    }
    OnPlayerLogin(playerid, inputtext);
  }
  else
  {
    SendClientMessage(playerid, 0xFFFFFFFF, "You canceled!");
    Kick(playerid);
  }
}
Reply
#4

Quote:
Originally Posted by Don Correlli
Try this:
pawn Код:
if(dialogid == 2)
{
  if(response)
  {
    if(!strlen(inputtext))
    {
      SendClientMessage(playerid, 0xFFFFFFFF, "Your Password Cannot be left Blank");
      return 1;
    }
    OnPlayerLogin(playerid, inputtext);
  }
  else
  {
    SendClientMessage(playerid, 0xFFFFFFFF, "You canceled!");
    Kick(playerid);
  }
}
Nope

Quote:
Originally Posted by _Xerxes_
It seems that your password your entering (or the password it is returning) is incorrect, since the only place that OnPlayerLogin wouldn't do anything, is after the password is incorrect. (It would only close the file, thus no indication)
If you study the code my closely, you will see that, when i put the incorrect code in, a message will come and so will a dialog.
Reply
#5

Then try to debug your dialog-code and OnPlayerLogin callback.
Reply
#6

Your right, my bad. Hard to read with those indentions.
Reply
#7

Quote:
Originally Posted by Don Correlli
Then try to debug your dialog-code and OnPlayerLogin callback.
I debuged it, and found out that the code stopped at:

Код:
if ( UserFile )
	{
This is the code around it:
Код:
new File: UserFile = fopen(string2, io_read);
	if ( UserFile )
	{
Reply
#8

Fixed
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)