Dialog cases. - 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: Dialog cases. (
/showthread.php?tid=355344)
Dialog cases. -
Dan. - 29.06.2012
I'm helping a friend to script, but this dialog thing is kind of weird, I'm not used to it.
Code:
pawn Код:
// This callback gets called when a player interacts with a dialog
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
// Select the proper dialog to process
switch (dialogid)
{
case DialogRegister: Dialog_Register(playerid, response, inputtext); // The "Register"-dialog
case DialogLogin: Dialog_Login(playerid, response, inputtext); // The "Login"-dialog
}
return 1;
}
So, how can I put these lines of code into there?
pawn Код:
if(dialogid == D_VARAV)
{
// Do something
}
Because when I copy the lines after the 'cases', then I get error:
pawn Код:
only a single statement (or expression) can follow each "case"
Re: Dialog cases. -
Cxnnor - 29.06.2012
EDIT: Standby I will try to figure it out and then post it.
Re: Dialog cases. -
newbienoob - 29.06.2012
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
// Select the proper dialog to process
switch (dialogid)
{
case /*dialog id here*/:
{
//do something
}
case/*dialog id here*/:
{
//do something here
}
return 1;
}
Re: Dialog cases. -
Cxnnor - 29.06.2012
Sorry for double posting, wouldn't let me edit, but try this.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
// Put your stuff here.
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
// Put your stuff here.
}
}
}
}
return 1;
}
Re: Dialog cases. -
Dan. - 29.06.2012
The other version would be better.. because now I have to change all the cases and the shorter the better.
Re: Dialog cases. -
[KHK]Khalid - 29.06.2012
Use the
Switch Statement it's more easy and efficient.