[Ajuda] error 002: only a single statement (or expression) can follow each "case"
#1

PHP код:
D:\UNIPORTANTES\PenDrive\Pen Draivi\SA-MP\Estou Fazendo\gamemodes\gm.pwn(797) : error 002only a single statement (or expressioncan follow each "case" 
linhajs
PHP код:

public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_REGISTER:
        {
            if(
strlen(inputtext) < 2){
            new 
string[128];
                 
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD,"! REGISTER"string"Register","Quit");
        } else{
        new 
query[1024], name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnameMAX_PLAYER_NAME);
        
format(querysizeof(query), "INSERT INTO `apocalypse` (username, password) VALUES ('%s', '%s')"nameinputtext);
        
mysql_function_query(mysqlqueryfalse"","");
        }
    }
    return 
1;

Reply
#2

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) 
{ 
    switch(dialogid) 
    { 
        case 0: DIALOG_REGISTER: 
        { 
            if(strlen(inputtext) < 2){ 
            new string[128]; 
                 ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"! REGISTER", string, "Register","Quit"); 

        } else{ 
        new query[1024], name[MAX_PLAYER_NAME]; 
        GetPlayerName(playerid, name, MAX_PLAYER_NAME); 
        format(query, sizeof(query), "INSERT INTO `apocalypse` (username, password) VALUES ('%s', '%s')", name, inputtext); 
        mysql_function_query(mysql, query, false, "",""); 
        } 
    } 
    return 1; 
}
Reply
#3

Switch nгo se pode utilizar if, else if e else para verificar o valor da variбvel. A 'case' tem funзгo jб de substituir essas verificaзхes, deve-se utilizar dessa forma:

PHP код:
new rand random(9);
switch(
rand) {
    case 
0: print("rand й igual a zero.");
    case 
3: print("rand й igual a trкs.");
    case 
5: print("rand й igual a cinco.");
    default: print(
"rand й diferente de zero, trкs e cinco.");

Acesse para entender como funciona a switch
https://sampwiki.blast.hk/wiki/Control_Structures#switch
Reply
#4

Quote:
Originally Posted by SaDaN
Посмотреть сообщение
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) 
{ 
    switch(dialogid) 
    { 
        case 0: DIALOG_REGISTER: 
        { 
            if(strlen(inputtext) < 2){ 
            new string[128]; 
                 ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"! REGISTER", string, "Register","Quit"); 

        } else{ 
        new query[1024], name[MAX_PLAYER_NAME]; 
        GetPlayerName(playerid, name, MAX_PLAYER_NAME); 
        format(query, sizeof(query), "INSERT INTO `apocalypse` (username, password) VALUES ('%s', '%s')", name, inputtext); 
        mysql_function_query(mysql, query, false, "",""); 
        } 
    } 
    return 1; 
}
ja resolvi man , seu codigo nгo funcionou mas vlw pela ajuda
fiz assim

PHP код:
    if(dialogid == DIALOG_REGISTER)
    {
        if(
response)
        { 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)