#1

Код:
stock Faction(playerid)
{
	switch(PlayerInfo[playerid][pFactionStat])
 	{
 		if(PlayerInfo[playerid][pFactionID] == 1)
 		{
			case 0: Tmp = "Non-Cadet";
			case 1: Tmp = "Cadet2";
			case 2: Tmp = "Cadet3";
			case 3: Tmp = "Cadet4";
			case 4: Tmp = "Cadet5";
		}
	}
	return Tmp;
}
It gives me these errors:
Код:
C:\(6344) : error 002: only a single statement (or expression) can follow each "case"
C:\(6344 -- 6345) : error 029: invalid expression, assumed zero
C:\(6346) : error 014: invalid statement; not in switch
C:\(6346) : warning 215: expression has no effect
C:\(6346) : error 001: expected token: ";", but found ":"
C:\(6346) : error 029: invalid expression, assumed zero
C:\(6346) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#2

I guess...
pawn Код:
stock Faction(playerid)
{
    switch(PlayerInfo[playerid][pFactionStat])
    {
    if(PlayerInfo[playerid][pFactionID] == 1)
    {
        case 0:
            {
                Tmp = "Non-Cadet";
            }
        case 1:
            {
                Tmp = "Cadet2";
            }
        case 2:
            {
                Tmp = "Cadet3";
            }
        case 3:
            {
                Tmp = "Cadet4";
            }
        case 4:
            {
                Tmp = "Cadet5";
            }
        }
    }
    return Tmp;
}
Noot sure.
Reply
#3

Still makes same errors
Reply
#4

Try this:
Код:
stock Faction(playerid)
{
	switch(PlayerInfo[playerid][pFactionStat])
 	{
 		case 1:
 		{
			switch(PlayerInfo[playerid][pRank])
			{
				case 0: Tmp = "Non-Cadet";
				case 1: Tmp = "Cadet2";
				case 2: Tmp = "Cadet3";
				case 3: Tmp = "Cadet4";
				case 4: Tmp = "Cadet5";
			}
		}
		//case 2:// faction 2.. 
		//.... with ranks.. etc
		
	}
	return Tmp;
}
Reply
#5

The solution above won't work either.

pawn Код:
stock Faction(playerid)
{
    new
        Tmp[10] = "Nothing"; // You never created a string for "Tmp" - "Nothing" will be returned if the switch statement sets nothing
       
    if(PlayerInfo[playerid][pFactionID] == 1) { // You can't put if statements loosely inside switch statements
        switch(PlayerInfo[playerid][pFactionStat]) {
            case 0: Tmp = "Non-Cadet";
            case 1: Tmp = "Cadet2";
            case 2: Tmp = "Cadet3";
            case 3: Tmp = "Cadet4";
            case 4: Tmp = "Cadet5";
        }
    }
   
    return Tmp; // Return an actual string now!
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)