Need help with switching
#1

I made wanted levels for robstore command. Each time the player types it he will gain 1 wanted level. But my switch case isn't working.
Код:
CMD:robstore(playerid, params[])
{
	if(gTeam[playerid] == ROBBERS)
	{
	    if(Robbing[playerid] == 0)
	    {
			if (StoreHasBeenRobbed > gettime())
			{
			SCM(playerid, COLOR_GREEN, "[ERROR]: This Store has been robbed in the last 5 minutes.");
			Robbing[playerid] = 1;
			return 1;
			}
			if (BankHasBeenRobbed > gettime())
			{
			SCM(playerid, COLOR_GREEN, "[ERROR]: The Bank has been robbed in the last 1 hour.");
			Robbing[playerid] = 1;
			return 1;
			}
			if(RobBank(playerid))
			{
		    new string[120];
		    SetPlayerWantedLevelEx(playerid, 1);
		    format(string, sizeof(string), "[ROBBERY]: %s is trying to rob Bank(Market)", PN(playerid));
		    Robbing[playerid] = 1;
		    SCMToAll(COLOR_GREEN, string);
		    Robbing[playerid] = 1;
			}
			else if(RobRustyDonuts(playerid))
			{
		    new string[120];
		    SetPlayerWantedLevelEx(playerid, 1);
		    format(string, sizeof(string), "[ROBBERY]: %s is trying to rob Rusty Donuts(Market)", PN(playerid));
		    Robbing[playerid] = 1;
		    SCMToAll(COLOR_GREEN, string);
		    Robbing[playerid] = 1;
	 		}
	 		else if(RobPizzaStacks(playerid))
	 		{
		    new string[120];
		    SetPlayerWantedLevelEx(playerid, 1);
		    format(string, sizeof(string), "[ROBBERY]: %s is trying to rob Pizza Stacks(Market)", PN(playerid));
		    Robbing[playerid] = 1;
		    SCMToAll(COLOR_GREEN, string);
		    Robbing[playerid] = 1;
	 		}
	 		else if(RobLSPDBinco(playerid))
	 		{
		    new string[120];
		    SetPlayerWantedLevelEx(playerid, 1);
		    format(string, sizeof(string), "[ROBBERY]: %s is trying to rob Binco(Market Road)", PN(playerid));
		    Robbing[playerid] = 1;
		    SCMToAll(COLOR_GREEN, string);
		    Robbing[playerid] = 1;
	 		}
	 		else if(RobVeronaBinco(playerid))
	 		{
	 	    new string[120];
	 	    SetPlayerWantedLevelEx(playerid, 1);
		    format(string, sizeof(string), "[ROBBERY]: %s is trying to rob Binco(Verona Beach)", PN(playerid));
		    Robbing[playerid] = 1;
		    SCMToAll(COLOR_GREEN, string);
		    Robbing[playerid] = 1;
			}
			else if(Rob247(playerid))
			{
	 		new string[120];
	 		SetPlayerWantedLevelEx(playerid, 1);
		    format(string, sizeof(string), "[ROBBERY]: %s is trying to rob 24/7(Temple)", PN(playerid));
		    Robbing[playerid] = 1;
		    SCMToAll(COLOR_GREEN, string);
		    Robbing[playerid] = 1;
			}
			else if(RobBurgerShot2(playerid))
			{
	 		new string[120];
	 		SetPlayerWantedLevelEx(playerid, 1);
		    format(string, sizeof(string), "[ROBBERY]: %s is trying to rob Burger Shot(Temple)", PN(playerid));
		    Robbing[playerid] = 1;
		    SCMToAll(COLOR_GREEN, string);
		    Robbing[playerid] = 1;
			}
			else if(RobBurgerShot2(playerid))
			{
	 		new string[120];
	 		SetPlayerWantedLevelEx(playerid, 1);
		    format(string, sizeof(string), "[ROBBERY]: %s is trying to rob Burger Shot(Verona)", PN(playerid));
		    Robbing[playerid] = 1;
		    SCMToAll(COLOR_GREEN, string);
		    Robbing[playerid] = 1;
			}
			else if(RobArmyBinco(playerid))
			{
	 		new string[120];
	 		SetPlayerWantedLevelEx(playerid, 1);
		    format(string, sizeof(string), "[ROBBERY]: %s is trying to rob Binco(Rodeo)", PN(playerid));
		    Robbing[playerid] = 1;
		    SCMToAll(COLOR_GREEN, string);
		    Robbing[playerid] = 1;
			}
			else if(RobSexShop(playerid))
			{
			new string[120];
			SetPlayerWantedLevelEx(playerid, 1);
		    format(string, sizeof(string), "[ROBBERY]: %s is trying to rob Sex Shop(Temple)", PN(playerid));
		    Robbing[playerid] = 1;
		    SCMToAll(COLOR_GREEN, string);
		    Robbing[playerid] = 1;
			}
			if(Robbing[playerid] == 1)
			{
			SetTimerEx("Robbing2", 45000, false, "i", playerid);
			SendClientMessage(playerid, COLOR_YELLOW, "[INFORMATION]: Robbery has been started, please wait 45 seconds!");
			}
		}
		else
		{
		SCM(playerid, -1, "  You are already robbing a store!");
		}
  	}
	else if(gTeam[playerid] == LSPD)
	{
	SCM(playerid, COLOR_RED, "[ERROR]: COPS can't perform this action!");
	return 1;
	}
	return 1;
}
Код:
stock SetPlayerWantedLevelEx(playerid, level)
{
   switch(level)
   {
        case 0: SetPlayerColor(playerid, -1);
        case 1: SetPlayerColor(playerid, COLOR_YELLOW);
        case 2: SetPlayerColor(playerid, COLOR_YELLOW);
        case 3: SetPlayerColor(playerid, COLOR_ORANGE);
        case 4: SetPlayerColor(playerid, COLOR_ORANGE);
        case 5: SetPlayerColor(playerid, COLOR_RED);
        default: SetPlayerColor(playerid, COLOR_RED);
   }
   return SetPlayerWantedLevel(playerid, level);
}
Reply
#2

What not working explain your problem more.
Reply
#3

That is each time player types /robstore he will gain 1 more wanted level
Reply
#4

You always setting wanted level as 1 use GetPlayerWantedLevel(playerid); to get current wanted level and add 1 to it and use this as in calling parameter
Eg

PHP код:
SetPlayerWantedLevelEx(playeridGetPlayerWantedLevel(playerid)+1); 
Reply
#5

thx <3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)