Need some help with if, else if or else -
MSI - 31.01.2012
Helloww, I made a dialog for a class. If a player not have enough score it says: You must have atleast rank 2 to be a Sniper! Than the dialog must be show again and that isn't.
pawn Код:
case DIALOG_SNIPER:
{
if( response )
{
if(GetPlayerScore(playerid) <= 5) return echo(playerid,COLOR_DARKRED,"You must have atleast Rank 2 to be a Sniper! ");
gPlayerClass[playerid] = SNIPER_CLASS;
GivePlayerWeapon(playerid, 4, 1);//knife
GivePlayerWeapon(playerid, 22, 15);//9mm
GivePlayerWeapon(playerid, 25, 25);//shotgun
GivePlayerWeapon(playerid, 44, 1);//night vision goggles
GivePlayerWeapon(playerid, 41, 43);//spraycan
SetPlayerHealth(playerid, 75);
return 1;
}
else return ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_LIST, "Select your Class 3/4", "{00CC33}Assault \n{00CC33}Sniper \n{00CC33}Medic \n{00CC33}Flame Thrower \n{00CC33}Pilot \n{00CC33}Engineer \n{00CC33}Spy \n{00CC33}Scout ", "Continue", "Back");
}
Re: Need some help with if, else if or else -
milanosie - 31.01.2012
pawn Код:
case DIALOG_SNIPER:
{
if( response )
{
if(GetPlayerScore(playerid) >= 6)
{
gPlayerClass[playerid] = SNIPER_CLASS;
GivePlayerWeapon(playerid, 4, 1);//knife
GivePlayerWeapon(playerid, 22, 15);//9mm
GivePlayerWeapon(playerid, 25, 25);//shotgun
GivePlayerWeapon(playerid, 44, 1);//night vision goggles
GivePlayerWeapon(playerid, 41, 43);//spraycan
SetPlayerHealth(playerid, 75);
return 1;
}
else return ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_LIST, "Select your Class 3/4", "{00CC33}Assault \n{00CC33}Sniper \n{00CC33}Medic \n{00CC33}Flame Thrower \n{00CC33}Pilot \n{00CC33}Engineer \n{00CC33}Spy \n{00CC33}Scout ", "Continue", "Back");
}
return 1;
}
Re: Need some help with if, else if or else -
Jochemd - 31.01.2012
pawn Код:
case DIALOG_SNIPER:
{
if( response )
{
if(GetPlayerScore(playerid) <= 5)
{
echo(playerid,COLOR_DARKRED,"You must have atleast Rank 2 to be a Sniper! ");
ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_LIST, "Select your Class 3/4", "{00CC33}Assault \n{00CC33}Sniper \n{00CC33}Medic \n{00CC33}Flame Thrower \n{00CC33}Pilot \n{00CC33}Engineer \n{00CC33}Spy \n{00CC33}Scout ", "Continue", "Back");
return 1;
}
gPlayerClass[playerid] = SNIPER_CLASS;
GivePlayerWeapon(playerid, 4, 1);//knife
GivePlayerWeapon(playerid, 22, 15);//9mm
GivePlayerWeapon(playerid, 25, 25);//shotgun
GivePlayerWeapon(playerid, 44, 1);//night vision goggles
GivePlayerWeapon(playerid, 41, 43);//spraycan
SetPlayerHealth(playerid, 75);
return 1;
}
else return ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_LIST, "Select your Class 3/4", "{00CC33}Assault \n{00CC33}Sniper \n{00CC33}Medic \n{00CC33}Flame Thrower \n{00CC33}Pilot \n{00CC33}Engineer \n{00CC33}Spy \n{00CC33}Scout ", "Continue", "Back");
}
Do you see what is changed?
Re: Need some help with if, else if or else -
MSI - 31.01.2012
Yeah thanks
Look at you rep+
Re: Need some help with if, else if or else -
[ABK]Antonio - 31.01.2012
You can do it this way or the way you had it...basically what it does is check if their score is less than or equal to 5, if it is we send them a message, if not we continue
pawn Код:
case DIALOG_SNIPER:
{
if( response )
{
if(GetPlayerScore(playerid) <= 5)
{
ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_LIST, "Select your Class 3/4", "{00CC33}Assault \n{00CC33}Sniper \n{00CC33}Medic \n{00CC33}Flame Thrower \n{00CC33}Pilot \n{00CC33}Engineer \n{00CC33}Spy \n{00CC33}Scout ", "Continue", "Back");
echo(playerid,COLOR_DARKRED,"You must have atleast Rank 2 to be a Sniper!");
}
else
{
gPlayerClass[playerid] = SNIPER_CLASS;
GivePlayerWeapon(playerid, 4, 1);//knife
GivePlayerWeapon(playerid, 22, 15);//9mm
GivePlayerWeapon(playerid, 25, 25);//shotgun
GivePlayerWeapon(playerid, 44, 1);//night vision goggles
GivePlayerWeapon(playerid, 41, 43);//spraycan
SetPlayerHealth(playerid, 75);
}
}
else return ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_LIST, "Select your Class 3/4", "{00CC33}Assault \n{00CC33}Sniper \n{00CC33}Medic \n{00CC33}Flame Thrower \n{00CC33}Pilot \n{00CC33}Engineer \n{00CC33}Spy \n{00CC33}Scout ", "Continue", "Back");
return 1;
}
If you notice, we force them right back into the previous dialog (well, what you put if they don't respond) and then we send them a client message. If that isn't true, we'll then set their class.