Another pawno bug - 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: Another pawno bug (
/showthread.php?tid=138131)
Another pawno bug -
¤Adas¤ - 31.03.2010
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.
Re: Another pawno bug -
Finn - 31.03.2010
Learn to indent your code, that's surely caused by bad indentation.
Re: Another pawno bug -
¤Adas¤ - 31.03.2010
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!
Re: Another pawno bug -
Westie - 31.03.2010
That's not a Pawno bug.
Re: Another pawno bug -
¤Adas¤ - 31.03.2010
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?
Re: Another pawno bug -
Joe Staff - 31.03.2010
I've witnessed this before. It is a Pawno bug. Just work around it by changing it's name.
Re: Another pawno bug -
Mr L - 31.03.2010
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;
}
Re: Another pawno bug -
¤Adas¤ - 31.03.2010
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.
Re: Another pawno bug -
RSX - 31.03.2010
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.