string warning -
SumX - 12.02.2012
Hey,what's wrong here?
![Cheesy](images/smilies/biggrin.png)
i've searched it on ******,i've deleted the new string,renamed,but,the same problem."local variable "string" shadows a variable at a preceding level"; that line is this one,new string[1024]
pawn Код:
if(strcmp(cmd, "/vhelp", true) == 0)
{
new string[1024];
if(PlayerInfo[playerid][pVIP] >= 1)return SendClientMessage(playerid, red, "You must have a V.I.P. Account to use this command! ");
{
strcat( string, "{FFD700}/vhelp\t\t\t{FFD700}/vrespawn\n" );
strcat( string, "{FFD700}/vips\t\t\t{FFD700}/vgoto\n" );
strcat( string, "{FFD700}/vnos\t\t\t{FFD700}/vgethere\n" );
strcat( string, "{FFD700}/sultantune\t\t{FFD700}/vweapons\n" );
strcat( string, "{FFD700}/jestertune\t\t{FFD700}/vammo\n" );
strcat( string, "{FFD700}/elegytune\t\t{FFD700}/vclub\n" );
strcat( string, "{FFD700}/othertune\n" );
strcat( string, "{FFD700}Use '/vc' in front of text.This is the V.I.P. chat." );
ShowPlayerDialog( playerid, VIPCMDS, DIALOG_STYLE_MSGBOX, "V.I.P. Commands:", string, "Quit", "" );
}
return 1;
}
Re: string warning -
lorigio - 12.02.2012
It means string is already used before.
Example
new string[1024];
public example()
{
new string[1024]; <-- error
}
Re: string warning -
Konstantinos - 12.02.2012
That happens because you have already defined it.
An example to understand what I mean.
pawn Код:
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
new string[ 128 ]; // 1st string
if(strcmp(cmd, "/vhelp", true) == 0)
{
new string[1024]; //2nd string
if(PlayerInfo[playerid][pVIP] >= 1)return SendClientMessage(playerid, red, "You must have a V.I.P. Account to use this command! ");
{
strcat( string, "{FFD700}/vhelp\t\t\t{FFD700}/vrespawn\n" );
strcat( string, "{FFD700}/vips\t\t\t{FFD700}/vgoto\n" );
strcat( string, "{FFD700}/vnos\t\t\t{FFD700}/vgethere\n" );
strcat( string, "{FFD700}/sultantune\t\t{FFD700}/vweapons\n" );
strcat( string, "{FFD700}/jestertune\t\t{FFD700}/vammo\n" );
strcat( string, "{FFD700}/elegytune\t\t{FFD700}/vclub\n" );
strcat( string, "{FFD700}/othertune\n" );
strcat( string, "{FFD700}Use '/vc' in front of text.This is the V.I.P. chat." );
ShowPlayerDialog( playerid, VIPCMDS, DIALOG_STYLE_MSGBOX, "V.I.P. Commands:", string, "Quit", "" );
}
return 1;
}
return 0;
}
// Result: local variable "string" shadows a variable at a preceding level
Re: string warning -
ReneG - 12.02.2012
Holy shit. Don't use
Use
Re: string warning -
SumX - 12.02.2012
SOLVED,it's right?... i've compiled it and i dont have any warnings,errors
pawn Код:
if(strcmp(cmd, "/vhelp", true) == 0)
{
new GMstring[128];
if(PlayerInfo[playerid][pVIP] >= 1)return SendClientMessage(playerid, red, "You must have a V.I.P. Account to use this command! ");
{
strcat( GMstring, "{FFD700}/vhelp\t\t\t{FFD700}/vrespawn\n" );
strcat( GMstring, "{FFD700}/vips\t\t\t{FFD700}/vgoto\n" );
strcat( GMstring, "{FFD700}/vnos\t\t\t{FFD700}/vgethere\n" );
strcat( GMstring, "{FFD700}/sultantune\t\t{FFD700}/vweapons\n" );
strcat( GMstring, "{FFD700}/jestertune\t\t{FFD700}/vammo\n" );
strcat( GMstring, "{FFD700}/elegytune\t\t{FFD700}/vclub\n" );
strcat( GMstring, "{FFD700}/othertune\n" );
strcat( GMstring, "{FFD700}Use '/vc' in front of text.This is the V.I.P. chat." );
ShowPlayerDialog( playerid, VIPCMDS, DIALOG_STYLE_MSGBOX, "V.I.P. Commands:", string, "Quit", "" );
}
return 1;
}
Re: string warning -
lorigio - 12.02.2012
Quote:
Originally Posted by SumX
SOLVED,it's right?... i've compiled it and i dont have any warnings,errors
pawn Код:
if(strcmp(cmd, "/vhelp", true) == 0) { new GMstring[128];
if(PlayerInfo[playerid][pVIP] >= 1)return SendClientMessage(playerid, red, "You must have a V.I.P. Account to use this command! "); { strcat( GMstring, "{FFD700}/vhelp\t\t\t{FFD700}/vrespawn\n" ); strcat( GMstring, "{FFD700}/vips\t\t\t{FFD700}/vgoto\n" ); strcat( GMstring, "{FFD700}/vnos\t\t\t{FFD700}/vgethere\n" ); strcat( GMstring, "{FFD700}/sultantune\t\t{FFD700}/vweapons\n" ); strcat( GMstring, "{FFD700}/jestertune\t\t{FFD700}/vammo\n" ); strcat( GMstring, "{FFD700}/elegytune\t\t{FFD700}/vclub\n" ); strcat( GMstring, "{FFD700}/othertune\n" ); strcat( GMstring, "{FFD700}Use '/vc' in front of text.This is the V.I.P. chat." ); ShowPlayerDialog( playerid, VIPCMDS, DIALOG_STYLE_MSGBOX, "V.I.P. Commands:", string, "Quit", "" ); } return 1; }
|
Yes it is
Re: string warning -
ReneG - 12.02.2012
Quote:
Originally Posted by SumX
SOLVED,it's right?... i've compiled it and i dont have any warnings,errors
pawn Код:
if(strcmp(cmd, "/vhelp", true) == 0) { new GMstring[128];
if(PlayerInfo[playerid][pVIP] >= 1)return SendClientMessage(playerid, red, "You must have a V.I.P. Account to use this command! "); { strcat( GMstring, "{FFD700}/vhelp\t\t\t{FFD700}/vrespawn\n" ); strcat( GMstring, "{FFD700}/vips\t\t\t{FFD700}/vgoto\n" ); strcat( GMstring, "{FFD700}/vnos\t\t\t{FFD700}/vgethere\n" ); strcat( GMstring, "{FFD700}/sultantune\t\t{FFD700}/vweapons\n" ); strcat( GMstring, "{FFD700}/jestertune\t\t{FFD700}/vammo\n" ); strcat( GMstring, "{FFD700}/elegytune\t\t{FFD700}/vclub\n" ); strcat( GMstring, "{FFD700}/othertune\n" ); strcat( GMstring, "{FFD700}Use '/vc' in front of text.This is the V.I.P. chat." ); ShowPlayerDialog( playerid, VIPCMDS, DIALOG_STYLE_MSGBOX, "V.I.P. Commands:", string, "Quit", "" ); } return 1; }
|
Only way to find out if it works is to test it out IG. Let us know how it goes.
Re: string warning -
SumX - 12.02.2012
Ok,thank you!
Re: string warning -
[ABK]Antonio - 13.02.2012
Quote:
Originally Posted by VincentDunn
|
He needs more than 128, he's using strcat so the size is going to be greater than 128.
Re: string warning -
Tannz0rz - 13.02.2012
Quote:
Originally Posted by [ABK]Antonio
He needs more than 128, he's using strcat so the size is going to be greater than 128.
|
strcat itself is irrelevant to the size of the array. Whether or not he requires 128 cells depends on how many characters he must store (if anything, the string itself is unnecessary).