GetPVarString And Strcmp problems -
bpeterson - 07.05.2010
Hey everyone,
I was messing with this code for hours now and I still could not figure out what's wrong.
Here's the code:
pawn Код:
else if(LocationStatus[i] == 2)
{
GetPVarString(i,"lastlocation",lastloc,sizeof(lastloc));
if(!strlen(lastloc))
{
format(lastloc, sizeof(lastloc), "%s", zone);
SendAllMsg(RED, "lastloc did not contain anything - set to: '%s'", lastloc);
}
SendAllMsg(RED, "Getting string into lastloc from lastlocation - output: '%s'", lastloc);
format(oldloc, sizeof(oldloc), "%s", lastloc);
if(strcmp(oldloc, zone, true))
{
GameTextForPlayer(i, zone, 1000, 1);
SendAllMsg(RED, "location names are different - oldloc: '%s' new loc: '%s'", lastloc, zone);
}
}
Problem: As you can see I added debug lines to see how stuffs get called. When I'm using this code, the only message I get is SendAllMsg(RED, "Getting string into lastloc from lastlocation - output: '%s'", lastloc); and nothing else. Also, the gametext does not show up. I tried changing strcmp to == 0 but it did not work either.
Please help me!
Thanks,
bpeterson
Re: GetPVarString And Strcmp problems -
dice7 - 07.05.2010
The gametext should be displayed if the names are different. Try this code to see where everything really fails
pawn Код:
else if(LocationStatus[i] == 2)
{
GetPVarString(i,"lastlocation",lastloc,sizeof(lastloc));
printf("1, lastloc= %s", lastloc);
if(!strlen(lastloc))
{
printf("2");
format(lastloc, sizeof(lastloc), "%s", zone);
printf("3, lastloc= %s, zone= %s", lastloc, zone);
SendAllMsg(RED, "lastloc did not contain anything - set to: '%s'", lastloc);
printf("4");
}
printf("5");
SendAllMsg(RED, "Getting string into lastloc from lastlocation - output: '%s'", lastloc);
printf("6");
format(oldloc, sizeof(oldloc), "%s", lastloc);
printf("7, lastloc= %s, oldloc= %s", lastloc, oldloc);
if(strcmp(oldloc, zone, true))
{
printf("8, zone= %s", zone);
GameTextForPlayer(i, zone, 1000, 1);
printf("9");
SendAllMsg(RED, "location names are different - oldloc: '%s' new loc: '%s'", lastloc, zone);
printf("10");
}
printf("11");
}
Re: GetPVarString And Strcmp problems -
bpeterson - 08.05.2010
Ok, I tried that code, here's what did it give:
Код:
[15:22:22] 1, lastloc= Downtown San Fierro
[15:22:22] 5
[15:22:22] 6
[15:22:22] 7, lastloc= Downtown San Fierro, oldloc= Downtown San Fierro
[15:22:22] 11
[15:22:23] 1, lastloc= Downtown San Fierro
[15:22:23] 5
[15:22:23] 6
[15:22:23] 7, lastloc= Downtown San Fierro, oldloc= Downtown San Fierro
[15:22:23] 11
etc...
As you can see, strcmp does not get called.
I still don't know what can be wrong..
Re: GetPVarString And Strcmp problems -
Jefff - 08.05.2010
Should be
Код:
if(strcmp(oldloc, zone, true) == 0)
Re: GetPVarString And Strcmp problems -
bpeterson - 08.05.2010
Yes, I've already tried that but it still shows the gametext, altought it has always the same text.
Output with Jefff's code:
Код:
[15:31:43] 1, lastloc= Esplanade East
[15:31:43] 5
[15:31:43] 6
[15:31:43] 7, lastloc= Esplanade East, oldloc= Esplanade East zone= Esplanade East
[15:31:43] 8, zone= Esplanade East
[15:31:43] 9
[15:31:43] 10
[15:31:43] 11
EDIT: If I change strcmp to if(strcmp(oldloc, zone, true) == 1) it will be the same as with if(strcmp(oldloc, zone, true))
Re: GetPVarString And Strcmp problems -
bpeterson - 08.05.2010
*BUMP*
Re: GetPVarString And Strcmp problems -
dice7 - 09.05.2010
Strcmp doesn't get called, because the location names are the same and you have it set to get called when they aren't
Re: GetPVarString And Strcmp problems -
Jefff - 09.05.2010
So should be
Код:
if(strcmp(oldloc, zone, true) != 0)
xd
Re: GetPVarString And Strcmp problems -
bpeterson - 10.05.2010
I had that too, did not work either, so i removed it. It wasn't so useful anyway. :P
Thanks for the help btw.