strcmp false detection -
AiRaLoKa - 27.08.2014
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
|
Re: strcmp false detection -
redist - 27.08.2014
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;
}
Re: strcmp false detection -
Sarra - 27.08.2014
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?
Re: strcmp false detection -
redist - 27.08.2014
"removed"
?
I'm guessing it worked then.
Edit: sorry, i didn't notice it wasn't the Airaloka
Re: strcmp false detection -
AiRaLoKa - 28.08.2014
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.
Re: strcmp false detection -
cosbraa - 28.08.2014
Make sure both name variables have a name stored in it and are not empty.
Re: strcmp false detection -
AiRaLoKa - 28.08.2014
i already do it before, read my thread before replying.
Re: strcmp false detection -
Dotayuri - 28.08.2014
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);
Re: strcmp false detection -
jihadmeneer - 28.08.2014
Print both the vehicle owner name and the player name and check the differences.
Re: strcmp false detection -
AiRaLoKa - 28.08.2014
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_