undeffined symbol "idx" - 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: undeffined symbol "idx" (
/showthread.php?tid=181625)
undeffined symbol "idx" -
Hamza' - 06.10.2010
pawn Код:
if(!strcmp("/advertissment", cmdtext, false, 9))
{
new tmp[256];
tmp = strtok ( cmdtext, idx );//Thijs is erreur line.
new string[128];
if ( !strlen ( tmp ) )
{
SendClientMessage(playerid, COLOR_RED, "/advertissment [Password]");
}
else
{
format(string, sizeof(string), "%s", cmdtext);
AdvertissmentForward(string);
}
return 1;
}
Quote:
error 017: undefined symbol "idx"
|
I'm not sure why it doesn't work, as I never got that erreur in the past..
Help would be appreciated.
-Hamza
Re: undeffined symbol "idx" -
Jeffry - 06.10.2010
Add:
Re: undeffined symbol "idx" -
Rachael - 06.10.2010
This is horrible code.
1. you are comparing the first 9 characters of a string that is 14 characters long
2. you have defined a string 256 characters long to hold a string that you don't even use
3. the string you are displaying the result in is only 128 characters long, and you don't even need it anyway
4. if you are using strtok, idx should already be defined under OnPlayerCommandText
5. idx should already have a value from when you used strtok to get the /advertissment command
pawn Код:
public OnPlayerCOmmandText(playerid,cmdtext[])
{
new tmp[128],idx;
tmp = strtok(cmdtext, idx);
if(!strcmp(tmp,"/advertissment",true))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
//message
}
AdvertissmentForward(tmp);
}
return 0;
}