[NOT FIXED] What's wrong with this?
#1

Okay. I was making a menu to buy a license for a RP server and I figured out that there's something wrong with one part of the script. I think it's this part:

pawn Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:CurrentMenu = GetPlayerMenu(playerid);

    if(CurrentMenu == BuyLicenses)
    {
        switch(row)
        {
        case 0: //Driving License
        {
        if(GetPlayerMoney(playerid) >= 50)
                {
                GivePlayerMoney(playerid, -50);
                    PlayerInfo[playerid][pCarLic] = 1;
            }
            else
            {
            SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a driver's license.");
            }
            case 1: //Firearms License
        {
              if(GetPlayerMoney(playerid) >= 800)
                {
                GivePlayerMoney(playerid, -800);
                    PlayerInfo[playerid][pGunLic] = 1;
            }
            else
            {
            SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a firearms license.");
            }
            case 2: //Boating License
        {
        if(GetPlayerMoney(playerid) >= 800)
                {
                GivePlayerMoney(playerid, -800);
                    PlayerInfo[playerid][pBoatLic] = 1;
            }
            else
            {
            SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a boat license.");
            }
            case 3: //Flying License
        {
              if(GetPlayerMoney(playerid) >= 3200)
                {
                GivePlayerMoney(playerid, -3200);
                    PlayerInfo[playerid][pGunLic] = 1;
            }
            else
            {
            SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a flying license.");
        }
        }
    }
    return 1;
}
I think I'm missing a bracket or a ;

Please help me find what's wrong. If you don't find anything, tell me that too. THANKS!

Note: The indent is actually normal. I don't know why it's weird when I post it here.
Reply
#2

you are not closing case 0
Reply
#3

Quote:
Originally Posted by Daren_Jacobson
you are not closing case 0
Actually, I am. But, since the indentation is messed up, you can't tell...
Reply
#4

Quote:
Originally Posted by [GTA
Rockstar ]
Actually, I am.
No you don't.
Reply
#5

Quote:
Originally Posted by 0rb
Quote:
Originally Posted by [GTA
Rockstar ]
Actually, I am.
No you don't.
Well, if I'm not, what exactly do I write to fix it? Where do I put a } or { or whatever?

Sorry, I'm a noob.
Reply
#6

You forgot to use ending brackets after else. By the way, sorry for the indenting, the code tags messed it up.

Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:CurrentMenu = GetPlayerMenu(playerid);

	if(CurrentMenu == BuyLicenses)
	{
		switch(row)
		{
    	case 0: //Driving License
    	{
        if(GetPlayerMoney(playerid) >= 50)
		{
    		GivePlayerMoney(playerid, -50);
			PlayerInfo[playerid][pCarLic] = 1;
  		}
  		else
  		{
    		SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a driver's license.");
		}
		}
			case 1: //Firearms License
    	{
			  if(GetPlayerMoney(playerid) >= 800)
				{
    			GivePlayerMoney(playerid, -800);
					PlayerInfo[playerid][pGunLic] = 1;
  			}
  			else
  			{
    			SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a firearms license.");
				}
			}
			case 2: //Boating License
    	{
        if(GetPlayerMoney(playerid) >= 800)
				{
    			GivePlayerMoney(playerid, -800);
					PlayerInfo[playerid][pBoatLic] = 1;
  			}
  			else
  			{
    			SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a boat license.");
				}
			}
			case 3: //Flying License
    	{
			  if(GetPlayerMoney(playerid) >= 3200)
				{
    			GivePlayerMoney(playerid, -3200);
					PlayerInfo[playerid][pGunLic] = 1;
  			}
  			else
  			{
    			SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a flying license.");
				}
    	}
		}
	}
	return 1;
}
Reply
#7

Quote:
Originally Posted by zyx
You forgot to use ending brackets after else. By the way, sorry for the indenting, the code tags messed it up.

Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:CurrentMenu = GetPlayerMenu(playerid);

	if(CurrentMenu == BuyLicenses)
	{
		switch(row)
		{
    	case 0: //Driving License
    	{
        if(GetPlayerMoney(playerid) >= 50)
		{
    		GivePlayerMoney(playerid, -50);
			PlayerInfo[playerid][pCarLic] = 1;
  		}
  		else
  		{
    		SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a driver's license.");
		}
		}
			case 1: //Firearms License
    	{
			  if(GetPlayerMoney(playerid) >= 800)
				{
    			GivePlayerMoney(playerid, -800);
					PlayerInfo[playerid][pGunLic] = 1;
  			}
  			else
  			{
    			SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a firearms license.");
				}
			}
			case 2: //Boating License
    	{
        if(GetPlayerMoney(playerid) >= 800)
				{
    			GivePlayerMoney(playerid, -800);
					PlayerInfo[playerid][pBoatLic] = 1;
  			}
  			else
  			{
    			SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a boat license.");
				}
			}
			case 3: //Flying License
    	{
			  if(GetPlayerMoney(playerid) >= 3200)
				{
    			GivePlayerMoney(playerid, -3200);
					PlayerInfo[playerid][pGunLic] = 1;
  			}
  			else
  			{
    			SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a flying license.");
				}
    	}
		}
	}
	return 1;
}
If I put the ending brackets after else, my pawno compiler says: "Pawn Compiler Library has stopped working..." and doesn't compile..
Reply
#8

Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:CurrentMenu = GetPlayerMenu(playerid);

	if(CurrentMenu == BuyLicenses)
	{
		switch(row)
		{
    	case 0: //Driving License
    	{
        if(GetPlayerMoney(playerid) >= 50)
				{
    			GivePlayerMoney(playerid, -50);
					PlayerInfo[playerid][pCarLic] = 1;
  			}else SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a driver's license.");
			}
			case 1: //Firearms License
    	{
			  if(GetPlayerMoney(playerid) >= 800)
				{
    			GivePlayerMoney(playerid, -800);
					PlayerInfo[playerid][pGunLic] = 1;
  			}else SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a firearms license.");
			}
			case 2: //Boating License
    	{
        if(GetPlayerMoney(playerid) >= 800)
				{
    			GivePlayerMoney(playerid, -800);
					PlayerInfo[playerid][pBoatLic] = 1;
  			}else SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a boat license.");
			}
			case 3: //Flying License
    	{
			  if(GetPlayerMoney(playerid) >= 3200)
				{
    			GivePlayerMoney(playerid, -3200);
					PlayerInfo[playerid][pGunLic] = 1;
  			}else SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a flying license.");
    	}
		}
	}
	return 1;
}
Check the difference :P
Reply
#9

Quote:
Originally Posted by Jefff
Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:CurrentMenu = GetPlayerMenu(playerid);

	if(CurrentMenu == BuyLicenses)
	{
		switch(row)
		{
    	case 0: //Driving License
    	{
        if(GetPlayerMoney(playerid) >= 50)
				{
    			GivePlayerMoney(playerid, -50);
					PlayerInfo[playerid][pCarLic] = 1;
  			}else SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a driver's license.");
			}
			case 1: //Firearms License
    	{
			  if(GetPlayerMoney(playerid) >= 800)
				{
    			GivePlayerMoney(playerid, -800);
					PlayerInfo[playerid][pGunLic] = 1;
  			}else SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a firearms license.");
			}
			case 2: //Boating License
    	{
        if(GetPlayerMoney(playerid) >= 800)
				{
    			GivePlayerMoney(playerid, -800);
					PlayerInfo[playerid][pBoatLic] = 1;
  			}else SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a boat license.");
			}
			case 3: //Flying License
    	{
			  if(GetPlayerMoney(playerid) >= 3200)
				{
    			GivePlayerMoney(playerid, -3200);
					PlayerInfo[playerid][pGunLic] = 1;
  			}else SendClientMessage(playerid, COLOR_GRAD1, "You do not have enough cash to buy a flying license.");
    	}
		}
	}
	return 1;
}
Check the difference :P
Message shows up: "Pawn Compiler Library has stopped working..."
Reply
#10

So u must have error with brackets but not in this public
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)