strcmp with inputtext problem. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: strcmp with inputtext problem. (
/showthread.php?tid=263099)
strcmp with inputtext problem. -
toyota - 20.06.2011
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