strfind isn't working correctly.
#1

Evening.
I want to check if the strings from the master account are 'empty'.

Код:
					if(strfind(MasterInfo[playerid][mName], "Empty", true) != -1 || strfind(MasterInfo[playerid][mName2], "Empty", true) != -1 || strfind(MasterInfo[playerid][mName3], "Empty", true) != -1)
					{
					SendClientMessage(playerid, COLOR_YELLOW, "INFO: You don't have any characters yet, please create a new one by clicking on the arrow.");
                    SendClientMessage(playerid, COLOR_YELLOW, "INFO: For security reasons characters can't be deleted.");
					}
					else
					{
					SendClientMessage(playerid, COLOR_YELLOW, "INFO: Please select your character or create a new one by clicking on the arrow.");
                    SendClientMessage(playerid, COLOR_YELLOW, "INFO: For security reasons characters can't be deleted.");
					}
Still, the strings are set to 'Empty', but it still shows the second message.
Reply
#2

In order to say that the player does not have any character yet, all three of them should be "Empty" thus you should use && (AND) instead of || (OR)

By the way, why strfind? strcmp is fine.
Reply
#3

Thank you, also.. I found an another problem. I think it's simply not saving.

If I register it isn't creating any ini file.

Код:
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
			{
	            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Continue","Quit");
                new string[128];
                format(string,sizeof(string),PATH,inputtext);
   				if(fexist(string)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: That name is already in use.","Continue","Quit");
                format(MasterInfo[playerid][tempname], 34, inputtext);
                SetPlayerName(playerid, inputtext);
                format(string, sizeof(string), "{3BB9FF}Your master account name is {3BB9FF}%s{FFFFFF}\nFill in a password to continue.", inputtext);
      			ShowPlayerDialog(playerid, DIALOG_REGISTER2, DIALOG_STYLE_INPUT, "World of Darkness Roleplay",string,"Register","Quit");
				return 1;
	        }
        }
        case DIALOG_REGISTER2:
        {
            if (!response) return Kick(playerid);
            if(response)
			{
			    new string[128];
   				format(string, sizeof(string), "Your master account name is {3BB9FF}%s{FFFFFF}\nFill in a password to continue.\n{AA3333}ERROR: Invalid password, try again.", inputtext);
	            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER2, DIALOG_STYLE_INPUT, "World of Darkness Roleplay",string,"Register","Quit");
	            /*if(strfind(inputtext, "_", true) == -1 || strfind(inputtext, "_", true) == -1) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    if(strfind(inputtext,"[",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,".",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"]",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"$",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"(",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,")",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"=",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"@",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"1",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"2",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"3",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"4",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"5",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"6",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"7",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"8",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");
			    else if(strfind(inputtext,"9",true) != (-1)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "World of Darkness Roleplay","Please type in your master account name:\n{AA3333AA}WARNING: You must use this name the next time you connect to our server.\nError: You have entered an invalid name, try again.","Register","Quit");*/
                format(string,sizeof(string),PATH,MasterInfo[playerid][tempname]);
				new INI:File = INI_Open(string);
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password2",udb_hash(inputtext));
                INI_WriteString(File, "Name", "Empty");
                INI_WriteString(File, "Name2", "Empty");
                INI_WriteString(File, "Name3", "Empty");
                INI_Close(File);
				new accname[MAX_PLAYER_NAME];
				GetPlayerName(playerid, accname, sizeof(accname));
  				format(string, sizeof(string), "{3BB9FF}Type your password below to login into your master account. {3BB9FF}(%s):", accname);
        		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"World of Darkness Roleplay",string,"Login","Quit");
				// Now -> Character Selection system
                //ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_MSGBOX, "- Sex -","What gender are you?","Male","Female");
				return 1;
	        }
        }
        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == MasterInfo[playerid][mPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    /*new
                        tmp2[ 256 ],
                        playername2[ MAX_PLAYER_NAME ]
					;*/
					ShowCharacterSelectionTextdraws(playerid);
					SelectTextDraw(playerid, -176);
					if(strfind(MasterInfo[playerid][mName], "Empty", true) != -1 || strfind(MasterInfo[playerid][mName2], "Empty", true) != -1 || strfind(MasterInfo[playerid][mName3], "Empty", true) != -1)
					{
					SendClientMessage(playerid, COLOR_YELLOW, "INFO: You don't have any characters yet, please create a new one by clicking on the arrow.");
                    SendClientMessage(playerid, COLOR_YELLOW, "INFO: For security reasons characters can't be deleted.");
					}
					else
					{
					SendClientMessage(playerid, COLOR_YELLOW, "INFO: Please select your character or create a new one by clicking on the arrow.");
                    SendClientMessage(playerid, COLOR_YELLOW, "INFO: For security reasons characters can't be deleted.");
					}
	    			/*GetPlayerName(playerid, playername2, sizeof(playername2));
   					format(tmp2, sizeof(tmp2), "~w~Welcome ~n~~g~%s", playername2);
					GameTextForPlayer(playerid, tmp2, 5000, 1);
					SetTimerEx("UnsetFirstSpawn", 5000, false, "i", playerid);
                    GivePlayerCash(playerid, PlayerInfo[playerid][pCash]);
                    TogglePlayerSpectating(playerid, 0);
   					SetSpawnInfo(playerid, 255, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);*/
				}
                else
                {
                new string[128];
                new accname[MAX_PLAYER_NAME];
				GetPlayerName(playerid, accname, sizeof(accname));
                format(string, sizeof(string), "Type your password below to login into your master account. (%s):\n{AA3333}Error: Invalid password, try again.", accname);
        		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"World of Darkness Roleplay",string,"Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)