Invalid expression, assumed zero
#1

What is the problem ? I got invalid expression and assumed zero

Код:
if( response )
	{
		new string1[30];
		if(udb_hash(inputtext) == PlayerInfo[playerid][PASSWORD])
		{
			INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
			GivePlayerMoney(playerid, PlayerInfo[playerid][MONEY]);
		}
		else
		{
            		DeletePVar(playerid, "FailedLoginAttempt");
			ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login", string1, "Login", "Cancel");
		}
  		else //HERE--------------
		{
  		  	if(GetPVarInt(playerid, "FailedLoginAttempt") == 0)
            		{
   				SetPVarInt(playerid, "FailedLoginAttempt", 1);
   				SendClientMessage(playerid, -1, "SERVER: asdasdsad.");
			}
			else if(GetPVarInt(playerid, "FailedLoginAttempt") == 1)
			{
   				SetPVarInt(playerid, "FailedLoginAttempt", 2);
   				SendClientMessage(playerid, -1, "SERVER: sadsad.");
			}
			else if(GetPVarInt(playerid, "FailedLoginAttempt") == 2)
			{
   				SetPVarInt(playerid, "FailedLoginAttempt", 3);
   				SendClientMessage(playerid, -1, "SERVER: asdsad.");
			}
			else if(GetPVarInt(playerid, "FailedLoginAttempt") == 3)
			{
   				DeletePVar(playerid, "FailedLoginAttempt");
   				SendClientMessage(playerid, -1, "SERVER: asdasd.");
			    Kick(playerid);
			}
   			ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login", string1, "Login", "Cancel");
   		}
	
	}
}
}
return 1;
}
Reply
#2

Probably this line is causing error:

Quote:

if(udb_hash(inputtext) == PlayerInfo[playerid][PASSWORD])

You have to use strcmp to compare strings.

https://sampwiki.blast.hk/wiki/Strcmp


Also, you can't use "else" twice. There is only one "if". And you have too much closing brackets.
Reply
#3

Any example ? please
Reply
#4

Because string1 is empty ?, it does not make sense to define it if you are not going to use it as such. Also the logic you used is wrong, depending on what you want to achieve is in the following code:

PHP код:
if(udb_hash(inputtext) == PlayerInfo[playerid][PASSWORD])
        {
            
// PASSWORD CORRECT
            
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
            
GivePlayerMoney(playeridPlayerInfo[playerid][MONEY]);
        }
        else
        {
            
// WRONG PASSWORD
            
if(GetPVarInt(playerid"FailedLoginAttempt") == 0)
            {
                   
SetPVarInt(playerid"FailedLoginAttempt"1);
                   
SendClientMessage(playerid, -1"SERVER: Password wrong.");
            }
            else if(
GetPVarInt(playerid"FailedLoginAttempt") == 1)
            {
                   
SetPVarInt(playerid"FailedLoginAttempt"2);
                   
SendClientMessage(playerid, -1"SERVER: Password wrong.");
            }
            else if(
GetPVarInt(playerid"FailedLoginAttempt") == 2)
            {
                   
SetPVarInt(playerid"FailedLoginAttempt"3);
                   
SendClientMessage(playerid, -1"SERVER: Password wrong.");
            }
            else if(
GetPVarInt(playerid"FailedLoginAttempt") == 3)
            {
                   
DeletePVar(playerid"FailedLoginAttempt");
                   
SendClientMessage(playerid, -1"SERVER: asdasd.");
                
Kick(playerid);
            }
            
ShowPlayerDialog(playeridLOGINDIALOG_STYLE_PASSWORD"Login""Type your password""Login""Cancel");
        } 
Reply
#5

PHP код:
if(!strcmp(udb_hash(inputtext), PlayerInfo[playerid][PASSWORD], true)) {
    
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
    
GivePlayerMoney(playeridPlayerInfo[playerid][MONEY]);
} else {
      new 
fla GetPVarInt(playerid"FailedLoginAttempt");
      if(
fla == 3) {
        
SendClientMessage(playerid, -1"SERVER: asdasd");
        
Kick(playerid);
        return 
1;
    }  else {
        
SetPVarInt(playerid"FailedLoginAttempt"fla 1);
        
SendClientMessage(playerid, -1"SERVER: Password wrong.");
      }
      
ShowPlayerDialog(playeridLOGINDIALOG_STYLE_PASSWORD"Login""Type your password""Login""Cancel");

I don't know why people check the same variable for different values if it's always the same outcome... it's a waste of coding time + lines.
Reply
#6

Quote:
Originally Posted by Bwandon
Посмотреть сообщение
I don't know why people check the same variable for different values if it's always the same outcome... it's a waste of coding time + lines.
Quote:
Originally Posted by Bojaa
Посмотреть сообщение
if(PlayerInfo[playerid][pFaction] == PlayerInfo[playerid][pFaction])

ye ye
Reply
#7

Now i have this problem, when i have to register, requirment is password with 6 lenght, but when i type only 1 it god registered and i got message "The password you enter is invalid must be 6 lenght!

Код:
if(!response)
 {
  	SendClientMessage(playerid, -1, "You have been kicked out of the server because you failed to respond!");
    	Kick(playerid);
    }
    if(!IsValidPassword(inputtext))
    {
		new string1[30];
    	SendClientMessage(playerid, -1, "SERVER: The password you entered is invalid" );
    	return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_PASSWORD, "Register", string1, "Register", "Cancel");
	}
	if(strlen(inputtext) < 6 || strlen(inputtext) > 24)
    {
        new string1[30];
    	SendClientMessage(playerid, -1, "SERVER: The password you entered is invalid. The length of the password should be between 6-24 characters" );
    	return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_PASSWORD, "Register", string1, "Register", "Cancel");
    }
	if(response)
	{
		new string1[30];
		if(!strlen(inputtext)) return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_PASSWORD, "Register", string1, "Register", "Cancel");
		
		new INI:File = INI_Open(UserPath(playerid));
		INI_SetTag(File,"Data");
		INI_WriteInt(File,"Password",udb_hash(inputtext));
		INI_WriteInt(File,"Cash",0);
		INI_WriteInt(File,"Admin",0);
		INI_WriteInt(File,"Score",0);
		INI_WriteInt(File,"Deaths",0);
		INI_WriteInt(File,"Kills",0);
		INI_Close(File);
	}
}
Reply
#8

as i know you have to check
if(strlen(inputtext) < 6 || strlen(inputtext) > 24)
in if(response) statement

your code is so mixed up dude
Reply
#9

Quote:
Originally Posted by khRamin78
Посмотреть сообщение
as i know you have to check
if(strlen(inputtext) < 6 || strlen(inputtext) > 24)
in if(response) statement

your code is so mixed up dude
I don't get you man I did try it as far and i'm confused too

Help me anyone +REP
Reply
#10

anyone ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)