strcmp false detection
#1

hi all...

i got a problem while making my dealership system

when i loop trough all vehicle, i compare the vehicle owner's name. but, when the name are the same with my nickname, it's detected as different name :/

pawn Код:
// inside of loop
                if(!strcmp(pName(playerid), vInfo[SavedVeh[d]][Name], false))
                {
                    printf("%s",vInfo[SavedVeh[d]][Name]);
                    continue;
                }
it's print a blank value, but i can see my nickname there.

i meant like this

Quote:
Originally Posted by samp.exe
blank
blank
blank

AiRa_
blank
blank
blank
blank
Reply
#2

Try

pawn Код:
// inside of loop
                if(strcmp(pName(playerid), vInfo[SavedVeh[d]][Name], false) == 1) // if the comparison tells you that they are the same
                {
                    printf("%s",vInfo[SavedVeh[d]][Name]);
                    continue;
                }
Reply
#3

I'm sorry for the edits, I have to learn reading the hole thread before posting a reply!
------
You got your name printed there, which means it works?
Reply
#4

"removed" ?

I'm guessing it worked then.

Edit: sorry, i didn't notice it wasn't the Airaloka
Reply
#5

Quote:
Originally Posted by Sarra
Посмотреть сообщение
I'm sorry for the edits, I have to learn reading the hole thread before posting a reply!
------
You got your name printed there, which means it works?
yeah, it's printed, but it's printed becouse of it's is NOT the same with my nickname. meanwhile what i want is if it has a different name with my nickname, it's continue the loop. and if it has the same name with my nickname, it's stop the loop.
Reply
#6

Make sure both name variables have a name stored in it and are not empty.
Reply
#7

i already do it before, read my thread before replying.
Reply
#8

Quote:
Originally Posted by AiRaLoKa
Посмотреть сообщение
i already do it before, read my thread before replying.
That code is correct, I copy and paste and tested it. Check pName(playerid);
Reply
#9

Print both the vehicle owner name and the player name and check the differences.
Reply
#10

fixed the old problem, got a new problem

pawn Код:
//still inside the loop
if(!strcmp(pName(playerid), vInfo[d][Name], false))
                    {
                        printf("same name detected");
                        format(temp, sizeof(temp), "%s\n", vehName[vInfo[d][vModel] - 400]);
                        printf("formatting success");
                        strcat(str, temp);
                        printf("strcat success");
                    }
it's print
Код:
[16:04:33] loop trough slots
[16:04:33] used slot detected
[16:04:33] same name detected
i printed the variables when the vehicle spawned

pawn Код:
printf("%d:> %d (%s) || %s",Id, vInfo[Id][vModel], vehName[vInfo[Id][vModel] - 400], vInfo[Id][Name]);
Код:
[16:03:46] 549:> 411 (Infernus) || AiRa_
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)