PDA

View Full Version : HELP. Issues in Returning my OnDialogResponse


Mriss
15/05/2014, 07:18 AM
Could someone please correctly return this for me, Im not sure Why i am getting these errors, CODE - 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.pw n(722) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pw n(722) : warning 215: expression has no effect
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pw n(723) : warning 209: function "OnDialogResponse" should return a value
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

iZN
15/05/2014, 07:22 AM
http://wiki.sa-mp.com/wiki/Errors_List#002:_only_a_single_statement_.28or_exp ression.29_can_follow_each_.E2.80.9Ccase.E2.80.9D

And you need to return true with every response.

Mriss
15/05/2014, 07:24 AM
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

rockhopper
15/05/2014, 07:25 AM
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;
}

AroseKhanNiazi
15/05/2014, 07:26 AM
but which line is 722

Mriss
15/05/2014, 07:27 AM
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pw n(716) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pw n(716) : warning 215: expression has no effect
C:\Users\Bradley\Desktop\BradRP\gamemodes\Blank.pw n(717) : warning 209: function "OnDialogResponse" should return a value

EDIT: @ARose... Line 716 - return 0;

AroseKhanNiazi
15/05/2014, 07:30 AM
if(dialogid == (here dialog id or name )
{
//codes
}
better use this no error this way

Mriss
15/05/2014, 07:34 AM
Well I dont just give up like that.

AroseKhanNiazi
15/05/2014, 07:41 AM
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

Mriss
15/05/2014, 07:52 AM
Yes, I did

AroseKhanNiazi
15/05/2014, 08:05 AM
dialog ids ??