HELP. Issues in Returning my OnDialogResponse
#1

Could someone please correctly return this for me, Im not sure Why i am getting these errors, CODE -
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new File[50];
    format(File, sizeof(File), PFiles, pName(playerid));
    switch(dialogid)
    {
        case LOGIN:
        {
            if(response)
            {
                if(strlen(inputtext) == 0)
                {
                    new
                        iStr[128];

                    format(iStr, sizeof(iStr), ""#CBLUE"Welcome back: "#CDGREEN"%s(%d)\n"#CBLUE"Enter your password to login:", pName(playerid), playerid);
                    return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, ""#CBLUE"Login", iStr, "Login", "Leave");
                }
                if(strcmp(inputtext, dj(File, "Password", 40), true) == 0)
                {
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "You are now logged in!");
               
                    PVar[playerid][pKills]      = djInt     (File, "Kills");
                    PVar[playerid][pDeaths]     = djInt     (File, "Deaths");
                    PVar[playerid][pLevel]      = djInt     (File, "Level");
                    PVar[playerid][pMuted]      = djInt     (File, "Muted");
                    format(PVar[playerid][pMutedReason], 52, "%s", dj(File, "MutedReason"));
                   
                    PVar[playerid][pLastX]      = djFloat   (File, "LastX");
                    PVar[playerid][pLastY]      = djFloat   (File, "LastY");
                    PVar[playerid][pLastZ]      = djFloat   (File, "LastZ");
                }
                else
                {
                    new
                        iStr[128];

                    format(iStr, sizeof(iStr), ""#CBLUE"Welcome back: "#CDGREEN"%s(%d)\n"#CBLUE"Enter your password to login:", pName(playerid), playerid);
                    return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, ""#CBLUE"Login", iStr, "Login", "Leave");
                }
            }
            else Kick(playerid);
        }
        case REGISTER:
        {
            if(response)
            {
                if(strlen(inputtext) == 0)
                {
                    new
                        iStr[128];

                    format(iStr, sizeof(iStr), ""#CBLUE"Welcome: "#CDGREEN"%s(%d)\n"#CBLUE"This account has not been registered! Please enter a password:", pName(playerid), playerid);
                    return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, ""#CDGREEN"Register", iStr, "Register", "Leave");
                }
                djCreateFile(File);
               
                djSet           (File, "Password",  inputtext);
                djSetInt        (File, "Kills",     0);
                djSetInt        (File, "Deaths",    0);
                djSetInt        (File, "Level",     0);
                djSetInt        (File, "Muted",     0);
                djSet           (File, "MutedReason", "Not Muted!");
               
                djSetFloat      (File, "LastX",     0.0);
                djSetFloat      (File, "LastY",     0.0);
                djSetFloat      (File, "LastZ",     0.0);
           
                djCommit(File);
           
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have been registered and logged in!");
            }
            else Kick(playerid);
        }
   
     case DIALOG_VEH:
        {
                   new VehicleID;
                   VehicleID = GetVehicleModelIDFromName(inputtext);
                   if(VehicleID != 425 && VehicleID != 432 && VehicleID != 447 &&
                   VehicleID != 430 && VehicleID != 417 && VehicleID != 435 &&
                   VehicleID != 446 && VehicleID != 449 && VehicleID != 450 &&
                   VehicleID != 452 && VehicleID != 453 && VehicleID != 454 &&
                   VehicleID != 460 && VehicleID != 464 && VehicleID != 465 &&
                   VehicleID != 469 && VehicleID != 472 && VehicleID != 473 &&
                   VehicleID != 476 && VehicleID != 484 && VehicleID != 487 &&
                   VehicleID != 488 && VehicleID != 493 && VehicleID != 497 &&
                   VehicleID != 501 && VehicleID != 511 && VehicleID != 512 &&
                   VehicleID != 513 && VehicleID != 519 && VehicleID != 520 &&
                   VehicleID != 537 && VehicleID != 538 && VehicleID != 548 &&
                   VehicleID != 553 && VehicleID != 563 && VehicleID != 564 &&
                   VehicleID != 569 && VehicleID != 570 && VehicleID != 577 &&
                   VehicleID != 584 && VehicleID != 590 && VehicleID != 591 &&
                   VehicleID != 592 && VehicleID != 593 && VehicleID != 594 &&
                   VehicleID != 595 && VehicleID != 606 && VehicleID != 607 &&
                   VehicleID != 608 && VehicleID != 610 && VehicleID != 611) {
                        if(VehicleID == -1 )
                        {
                                VehicleID = strval(inputtext);

                                if(VehicleID < 400 || VehicleID > 611 )
                                {
                                        return SendClientMessage(playerid, COLOR_GREY, "You entered an invalid vehiclename!");
                                }
                        }

                        GetPlayerPos(playerid, pX, pY, pZ);
                        GetPlayerFacingAngle(playerid, pAngle);

                        DestroyVehicle(PVar[playerid][pSpawnVehicle]);
                        PVar[playerid][pSpawnVehicle] = CreateVehicle(VehicleID, pX, pY, pZ+2.0, pAngle, 0, 0, -1);
                        LinkVehicleToInterior(PVar[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
                        PutPlayerInVehicle(playerid, PVar[playerid][pSpawnVehicle], 0);

  }
    }
    return 0;
}
Errors -
Код:
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pwn(722) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pwn(722) : warning 215: expression has no effect
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pwn(723) : warning 209: function "OnDialogResponse" should return a value
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

https://sampwiki.blast.hk/wiki/Errors_Li...Ccase.E2.80.9D

And you need to return true with every response.
Reply
#3

I dont get it, could u fix it up and send me? I like to learn by looking at the fixed and the wrong one
Reply
#4

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new File[50];
    format(File, sizeof(File), PFiles, pName(playerid));
    switch(dialogid)
    {
        case LOGIN:
        {
            if(response)
            {
                if(strlen(inputtext) == 0)
                {
                    new
                        iStr[128];

                    format(iStr, sizeof(iStr), ""#CBLUE"Welcome back: "#CDGREEN"%s(%d)\n"#CBLUE"Enter your password to login:", pName(playerid), playerid);
                    return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, ""#CBLUE"Login", iStr, "Login", "Leave");
                }
                if(strcmp(inputtext, dj(File, "Password", 40), true) == 0)
                {
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "You are now logged in!");
                
                    PVar[playerid][pKills]      = djInt     (File, "Kills");
                    PVar[playerid][pDeaths]     = djInt     (File, "Deaths");
                    PVar[playerid][pLevel]      = djInt     (File, "Level");
                    PVar[playerid][pMuted]      = djInt     (File, "Muted");
                    format(PVar[playerid][pMutedReason], 52, "%s", dj(File, "MutedReason"));
                    
                    PVar[playerid][pLastX]      = djFloat   (File, "LastX");
                    PVar[playerid][pLastY]      = djFloat   (File, "LastY");
                    PVar[playerid][pLastZ]      = djFloat   (File, "LastZ");
                }
                else
                {
                    new
                        iStr[128];

                    format(iStr, sizeof(iStr), ""#CBLUE"Welcome back: "#CDGREEN"%s(%d)\n"#CBLUE"Enter your password to login:", pName(playerid), playerid);
                    return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, ""#CBLUE"Login", iStr, "Login", "Leave");
                }
            }
            else Kick(playerid);
        }}
        case REGISTER:
        {
            if(response)
            {
                if(strlen(inputtext) == 0)
                {
                    new
                        iStr[128];

                    format(iStr, sizeof(iStr), ""#CBLUE"Welcome: "#CDGREEN"%s(%d)\n"#CBLUE"This account has not been registered! Please enter a password:", pName(playerid), playerid);
                    return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, ""#CDGREEN"Register", iStr, "Register", "Leave");
                }
                djCreateFile(File);
                
                djSet           (File, "Password",  inputtext);
                djSetInt        (File, "Kills",     0);
                djSetInt        (File, "Deaths",    0);
                djSetInt        (File, "Level",     0);
                djSetInt        (File, "Muted",     0);
                djSet           (File, "MutedReason", "Not Muted!");
                
                djSetFloat      (File, "LastX",     0.0);
                djSetFloat      (File, "LastY",     0.0);
                djSetFloat      (File, "LastZ",     0.0);
            
                djCommit(File);
            
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have been registered and logged in!");
            }
            else Kick(playerid);
        }}
    
     case DIALOG_VEH:
        {
                   new VehicleID;
                   VehicleID = GetVehicleModelIDFromName(inputtext);
                   if(VehicleID != 425 && VehicleID != 432 && VehicleID != 447 &&
                   VehicleID != 430 && VehicleID != 417 && VehicleID != 435 &&
                   VehicleID != 446 && VehicleID != 449 && VehicleID != 450 &&
                   VehicleID != 452 && VehicleID != 453 && VehicleID != 454 &&
                   VehicleID != 460 && VehicleID != 464 && VehicleID != 465 &&
                   VehicleID != 469 && VehicleID != 472 && VehicleID != 473 &&
                   VehicleID != 476 && VehicleID != 484 && VehicleID != 487 &&
                   VehicleID != 488 && VehicleID != 493 && VehicleID != 497 &&
                   VehicleID != 501 && VehicleID != 511 && VehicleID != 512 &&
                   VehicleID != 513 && VehicleID != 519 && VehicleID != 520 &&
                   VehicleID != 537 && VehicleID != 538 && VehicleID != 548 &&
                   VehicleID != 553 && VehicleID != 563 && VehicleID != 564 &&
                   VehicleID != 569 && VehicleID != 570 && VehicleID != 577 &&
                   VehicleID != 584 && VehicleID != 590 && VehicleID != 591 &&
                   VehicleID != 592 && VehicleID != 593 && VehicleID != 594 &&
                   VehicleID != 595 && VehicleID != 606 && VehicleID != 607 &&
                   VehicleID != 608 && VehicleID != 610 && VehicleID != 611) {
                        if(VehicleID == -1 )
                        {
                                VehicleID = strval(inputtext);

                                if(VehicleID < 400 || VehicleID > 611 )
                                {
                                        return SendClientMessage(playerid, COLOR_GREY, "You entered an invalid vehiclename!");
                                }
                        }

                        GetPlayerPos(playerid, pX, pY, pZ);
                        GetPlayerFacingAngle(playerid, pAngle);

                        DestroyVehicle(PVar[playerid][pSpawnVehicle]);
                        PVar[playerid][pSpawnVehicle] = CreateVehicle(VehicleID, pX, pY, pZ+2.0, pAngle, 0, 0, -1);
                        LinkVehicleToInterior(PVar[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
                        PutPlayerInVehicle(playerid, PVar[playerid][pSpawnVehicle], 0);

  }
    }
    return 0;
}
Reply
#5

but which line is 722
Reply
#6

Код:
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pwn(716) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pwn(716) : warning 215: expression has no effect
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pwn(717) : warning 209: function "OnDialogResponse" should return a value
EDIT: @ARose... Line 716 - return 0;
Reply
#7

pawn Код:
if(dialogid == (here dialog id or name )
{
//codes
}
better use this no error this way
Reply
#8

Well I dont just give up like that.
Reply
#9

Quote:
Originally Posted by rockhopper
Посмотреть сообщение
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new File[50];
    format(File, sizeof(File), PFiles, pName(playerid));
    switch(dialogid)
    {
        case LOGIN:
        {
            if(response)
            {
                if(strlen(inputtext) == 0)
                {
                    new
                        iStr[128];

                    format(iStr, sizeof(iStr), ""#CBLUE"Welcome back: "#CDGREEN"%s(%d)\n"#CBLUE"Enter your password to login:", pName(playerid), playerid);
                    return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, ""#CBLUE"Login", iStr, "Login", "Leave");
                }
                if(strcmp(inputtext, dj(File, "Password", 40), true) == 0)
                {
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "You are now logged in!");
                
                    PVar[playerid][pKills]      = djInt     (File, "Kills");
                    PVar[playerid][pDeaths]     = djInt     (File, "Deaths");
                    PVar[playerid][pLevel]      = djInt     (File, "Level");
                    PVar[playerid][pMuted]      = djInt     (File, "Muted");
                    format(PVar[playerid][pMutedReason], 52, "%s", dj(File, "MutedReason"));
                    
                    PVar[playerid][pLastX]      = djFloat   (File, "LastX");
                    PVar[playerid][pLastY]      = djFloat   (File, "LastY");
                    PVar[playerid][pLastZ]      = djFloat   (File, "LastZ");
                }
                else
                {
                    new
                        iStr[128];

                    format(iStr, sizeof(iStr), ""#CBLUE"Welcome back: "#CDGREEN"%s(%d)\n"#CBLUE"Enter your password to login:", pName(playerid), playerid);
                    return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, ""#CBLUE"Login", iStr, "Login", "Leave");
                }
            }
            else Kick(playerid);
        }}
        case REGISTER:
        {
            if(response)
            {
                if(strlen(inputtext) == 0)
                {
                    new
                        iStr[128];

                    format(iStr, sizeof(iStr), ""#CBLUE"Welcome: "#CDGREEN"%s(%d)\n"#CBLUE"This account has not been registered! Please enter a password:", pName(playerid), playerid);
                    return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, ""#CDGREEN"Register", iStr, "Register", "Leave");
                }
                djCreateFile(File);
                
                djSet           (File, "Password",  inputtext);
                djSetInt        (File, "Kills",     0);
                djSetInt        (File, "Deaths",    0);
                djSetInt        (File, "Level",     0);
                djSetInt        (File, "Muted",     0);
                djSet           (File, "MutedReason", "Not Muted!");
                
                djSetFloat      (File, "LastX",     0.0);
                djSetFloat      (File, "LastY",     0.0);
                djSetFloat      (File, "LastZ",     0.0);
            
                djCommit(File);
            
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have been registered and logged in!");
            }
            else Kick(playerid);
        }}
    
     case DIALOG_VEH:
        {
                   new VehicleID;
                   VehicleID = GetVehicleModelIDFromName(inputtext);
                   if(VehicleID != 425 && VehicleID != 432 && VehicleID != 447 &&
                   VehicleID != 430 && VehicleID != 417 && VehicleID != 435 &&
                   VehicleID != 446 && VehicleID != 449 && VehicleID != 450 &&
                   VehicleID != 452 && VehicleID != 453 && VehicleID != 454 &&
                   VehicleID != 460 && VehicleID != 464 && VehicleID != 465 &&
                   VehicleID != 469 && VehicleID != 472 && VehicleID != 473 &&
                   VehicleID != 476 && VehicleID != 484 && VehicleID != 487 &&
                   VehicleID != 488 && VehicleID != 493 && VehicleID != 497 &&
                   VehicleID != 501 && VehicleID != 511 && VehicleID != 512 &&
                   VehicleID != 513 && VehicleID != 519 && VehicleID != 520 &&
                   VehicleID != 537 && VehicleID != 538 && VehicleID != 548 &&
                   VehicleID != 553 && VehicleID != 563 && VehicleID != 564 &&
                   VehicleID != 569 && VehicleID != 570 && VehicleID != 577 &&
                   VehicleID != 584 && VehicleID != 590 && VehicleID != 591 &&
                   VehicleID != 592 && VehicleID != 593 && VehicleID != 594 &&
                   VehicleID != 595 && VehicleID != 606 && VehicleID != 607 &&
                   VehicleID != 608 && VehicleID != 610 && VehicleID != 611) {
                        if(VehicleID == -1 )
                        {
                                VehicleID = strval(inputtext);

                                if(VehicleID < 400 || VehicleID > 611 )
                                {
                                        return SendClientMessage(playerid, COLOR_GREY, "You entered an invalid vehiclename!");
                                }
                        }

                        GetPlayerPos(playerid, pX, pY, pZ);
                        GetPlayerFacingAngle(playerid, pAngle);

                        DestroyVehicle(PVar[playerid][pSpawnVehicle]);
                        PVar[playerid][pSpawnVehicle] = CreateVehicle(VehicleID, pX, pY, pZ+2.0, pAngle, 0, 0, -1);
                        LinkVehicleToInterior(PVar[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
                        PutPlayerInVehicle(playerid, PVar[playerid][pSpawnVehicle], 0);

  }
    }
    return 0;
}
did u try his code
Reply
#10

Yes, I did
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)