Another pawno bug
#1

Hello, I have found a bug with multi-index non-global variables.

Here is the example:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[100], i;
cmd = strtok(cmdtext, i);
if(!strcmp(cmd, "/XYZ", true))
{
new pos[3][50];
for(new a; a<3; a++) pos[a] = strtok(cmdtext, i);
if(!strlen(pos[2])) return true;
return SetPlayerPos(playerid, floatstr(pos[0]), floatstr(pos[1]), floatstr(pos[2]));
}
if(!strcmp(cmd, "/XYZ_LOL", true))
{
new pos[3][50];
for(new a; a<3; a++) pos[a] = strtok(cmdtext, i);
if(!strlen(pos[2])) return true;
return SetPlayerPos(playerid, floatstr(pos[0]), floatstr(pos[1]), floatstr(pos[2]));
}
return false;
}
Compiler shows an error:

Код:
Symbol already defined ("pos").
When I remove the "new pos[3][50];" from second command, it compiles good, but...
In-game, when you type "/XYZ_LOL" it teleports you to coords 0.0 0.0 0.0. It means, that variable "pos" does no longer exist.

I would be glad, if this can be fixed.
Thanks.
Reply
#2

Learn to indent your code, that's surely caused by bad indentation.
Reply
#3

Quote:
Originally Posted by Finn
Learn to indent your code, that's surely caused by bad indentation.
You are lame! Identation has nothing to do with this!
Reply
#4

That's not a Pawno bug.
Reply
#5

Quote:
Originally Posted by /^We(stie|z+[e|a
r)$/ ]
That's not a Pawno bug.
No, that is probably your bug.
And what do you think then?
Reply
#6

I've witnessed this before. It is a Pawno bug. Just work around it by changing it's name.
Reply
#7

use this:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[100], i;
cmd = strtok(cmdtext, i);
new pos[3][50];
if(!strcmp(cmd, "/XYZ", true))
{
for(new a; a<3; a++) pos[a] = strtok(cmdtext, i);
if(!strlen(pos[2])) return true;
return SetPlayerPos(playerid, floatstr(pos[0]), floatstr(pos[1]), floatstr(pos[2]));
}
if(!strcmp(cmd, "/XYZ_LOL", true))
{
for(new a; a<3; a++) pos[a] = strtok(cmdtext, i);
if(!strlen(pos[2])) return true;
return SetPlayerPos(playerid, floatstr(pos[0]), floatstr(pos[1]), floatstr(pos[2]));
}
return false;
}
Reply
#8

Quote:
Originally Posted by Kinto
use this:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[100], i;
cmd = strtok(cmdtext, i);
new pos[3][50];
if(!strcmp(cmd, "/XYZ", true))
{
for(new a; a<3; a++) pos[a] = strtok(cmdtext, i);
if(!strlen(pos[2])) return true;
return SetPlayerPos(playerid, floatstr(pos[0]), floatstr(pos[1]), floatstr(pos[2]));
}
if(!strcmp(cmd, "/XYZ_LOL", true))
{
for(new a; a<3; a++) pos[a] = strtok(cmdtext, i);
if(!strlen(pos[2])) return true;
return SetPlayerPos(playerid, floatstr(pos[0]), floatstr(pos[1]), floatstr(pos[2]));
}
return false;
}
You probably missed the point. I am not stupid. I was only reporting a bug.
Reply
#9

Sorry for saying this, but you should really use zcmd and sscanf.. it would be easier, sscanf can even put it array directly (and not as text but floats) so... it couldn't have these dumb glitches, whitch i guess comes from this "pos" usage, what usually trips me when using it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)