SA-MP Forums Archive
Declaration locar variable error - 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)
+--- Thread: Declaration locar variable error (/showthread.php?tid=396658)



Declaration locar variable error - DaRoderick - 01.12.2012

Код:
error 003: declaration of a local variable must appear in a compound block
The error is for 'new string[20];'
pawn Код:
if(!udb_Exists(PlayerName2(playerid)))
    //SendClientMessage(playerid,orange, "SERVER: Your account is not registered, please register by spawning your character.");
    new string[20];
     format(string, sizeof(string), "Register new Account: '%s'\n\nEnter the password to Register your Account:",pName(playerid));
    ShowPlayerDialog(playerid,DIALOGID+66,DIALOG_STYLE_INPUT,"Register Account",string,"Register","Quit");
So, could anyone be so kind to give me a helping hand on why it doesn't work?


Re: Declaration locar variable error - NumbSkull - 01.12.2012

you can try putting brackets around your if function
pawn Код:
if(!udb_Exists(PlayerName2(playerid)))
{
    //SendClientMessage(playerid,orange, "SERVER: Your account is not registered, please register by spawning your character.");
    new string[20];
     format(string, sizeof(string), "Register new Account: '%s'\n\nEnter the password to Register your Account:",pName(playerid));
    ShowPlayerDialog(playerid,DIALOGID+66,DIALOG_STYLE_INPUT,"Register Account",string,"Register","Quit");
}



Re: Declaration locar variable error - Plovix - 01.12.2012

Try this:
Код:
if(!udb_Exists(PlayerName2(playerid)))
{
    //SendClientMessage(playerid,orange, "SERVER: Your account is not registered, please register by spawning your character.");
}else{
    new string[20];
     format(string, sizeof(string), "Register new Account: '%s'\n\nEnter the password to Register your Account:",pName[playerid]);
    ShowPlayerDialog(playerid,DIALOGID+66,DIALOG_STYLE_INPUT,"Register Account",string,"Register","Quit");
}



Re: Declaration locar variable error - mamorunl - 01.12.2012

Quote:
Originally Posted by Plovix
Посмотреть сообщение
Try this:
Код:
if(!udb_Exists(PlayerName2(playerid)))
{
    //SendClientMessage(playerid,orange, "SERVER: Your account is not registered, please register by spawning your character.");
}else{
    new string[20];
     format(string, sizeof(string), "Register new Account: '%s'\n\nEnter the password to Register your Account:",pName[playerid]);
    ShowPlayerDialog(playerid,DIALOGID+66,DIALOG_STYLE_INPUT,"Register Account",string,"Register","Quit");
}
Dude, check your code. It really doesn't make any sense. Go over it and you'll find out why