Quote:
Originally Posted by Patrick
I learned this quite a while ago but its worth something sharing. This will avoid you from repeating the code over and over again. Repeating dialogs could be annoying sometimes because you'll have to change everything that you've repeated.
pawn Код:
JustATestFunc(playerid, randomValue, higherValue) { if(playerid == INVALID_PLAYER_ID) { goto RandomDialog; return 1; } if(randomValue < 10 || higherValue > 1000) { goto RandomDialog; return 1; }
RandomDialog: ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, "Example", "Example", "Yes", "No"); return 1; }
Instead of
pawn Код:
JustATestFunc(playerid, randomValue, higherValue) { if(playerid == INVALID_PLAYER_ID) { ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, "Example", "Example", "Yes", "No"); return 1; } if(randomValue < 10 || higherValue > 1000) { ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, "Example", "Example", "Yes", "No"); return 1; }
RandomDialog: ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, "Example", "EXample", "Yes", "No"); return 1; }
|
Or, Here is how I'd do it:
PHP код:
JustATestFunc(playerid, randomValue, higherValue)
{
//Make sure everything is correct.
if(playerid != INVALID_PLAYER_ID) return 1;
if(randomValue > 10 && higherValue < 1000) return 1;
//Show the dialog.
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, "Example", "Example", "Yes", "No");
return 1;
}
Also btw, the line about INVALID_PLAYER_ID should be the opposite but seeing as its only a test function, no problem :P