strcmp with inputtext problem.
#1

Hi, I'm having a problem with strcmp on the inputtext of a List Dialog. Here is the code I am using.

Код:
if (dialogid==9009)
	{
	    if(response)
	    {
	        new tempslotnumlc;
	        for (new tsnlc=0; tsnlc<MAX_OWNED_CARS; tsnlc++)
	        {
	            if (!strcmp(Carlist[playerid][tsnlc][carname], inputtext, false))
	            {
	                printf("numbercounter: %i", tsnlc);
	                tempslotnumlc=tsnlc;
	                print(inputtext);
	                print(Carlist[playerid][tsnlc][carname]);
	                printf("number: %i", tempslotnumlc);
	                break;
	            }
	            else
	            {
	                printf("numberintheelse: %i", tsnlc);
	                tempslotnumlc=-1;
	                print(inputtext);
	                print(Carlist[playerid][tsnlc][carname]);
	            }
	        }
	        if (tempslotnumlc!=-1)
	        {
		        Lock code is here.
		}
	    }
	    else {SendClientMessage( playerid, COLOR_RED, "ERROR: {FFFFFF}You cancelled!");}
	}
The dialog is a list type, and the code fails on the strcmp line. When the 2 strings are the same, it fails. When the 2 strings are different, it fails. However, when the counter jumps to a blank slot, so carname is (null), the strcmp passes.

Ignore the spam prints, I added those so I could see what is going on. I also removed the actual lock code as that works fine.

I'm sure it is obvious, but I can't see what I've done wrong.

Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)