case help
#1

errors:

pawn Код:
Arko.pwn(27341) : error 036: empty statement
Arko.pwn(27344) : error 002: only a single statement (or expression) can follow each "case"
Arko.pwn(27344 -- 27345) : error 029: invalid expression, assumed zero
Arko.pwn(27346) : error 014: invalid statement; not in switch
Arko.pwn(27346) : warning 215: expression has no effect
Arko.pwn(27346) : error 001: expected token: ";", but found ":"
Arko.pwn(27346) : error 029: invalid expression, assumed zero
Arko.pwn(27346) : fatal error 107: too many error messages on one line
Code:

pawn Код:
command(seatbelt, playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new string[128], vehicleid = GetPlayerVehicleID(playerid);;
            switch(Player[playerid][Seatbelt])
            {
                if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
                {
                    case 0:
                    {
                    Player[playerid][Seatbelt] = 1;
                    format(string, sizeof(string), "* %s take their helmet placing it on their head, straping it tightly.", GetName(playerid));
                    NearByMessage(playerid, PURPLE, string);
                    }
                    case 1:
                    {
                    Player[playerid][Seatbelt] = 0;
                    format(string, sizeof(string), "* %s unstraps their helmet, taking it off.", GetName(playerid));
                    NearByMessage(playerid, PURPLE, string);
                    }
                {
                else
                }
                switch(Player[playerid][Seatbelt])
                {
                    case 0:
                    {
                    Player[playerid][Seatbelt] = 1;
                    format(string, sizeof(string), "* %s slides their seatbelt across their chest, buckling it tightly", GetName(playerid));
                    NearByMessage(playerid, PURPLE, string);
                    }
                    case 1:
                    {
                    Player[playerid][Seatbelt] = 0;
                    format(string, sizeof(string), "* %s unbuckles their seatbelt", GetName(playerid));
                    NearByMessage(playerid, PURPLE, string);
                }
            }
        }
    }
    return 1;
}
Reply
#2

The else is your problem change it to this

pawn Код:
command(seatbelt, playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new string[128], vehicleid = GetPlayerVehicleID(playerid);;
            switch(Player[playerid][Seatbelt])
            {
                if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) {
                    case 0: {
                        Player[playerid][Seatbelt] = 1;
                        format(string, sizeof(string), "* %s take their helmet placing it on their head, straping it tightly.", GetName(playerid));
                        NearByMessage(playerid, PURPLE, string);
                    }
                    case 1: {
                        Player[playerid][Seatbelt] = 0;
                        format(string, sizeof(string), "* %s unstraps their helmet, taking it off.", GetName(playerid));
                        NearByMessage(playerid, PURPLE, string);
                    }
                } else {
                switch(Player[playerid][Seatbelt])
                {
                    case 0:
                    {
                    Player[playerid][Seatbelt] = 1;
                    format(string, sizeof(string), "* %s slides their seatbelt across their chest, buckling it tightly", GetName(playerid));
                    NearByMessage(playerid, PURPLE, string);
                    }
                    case 1:
                    {
                    Player[playerid][Seatbelt] = 0;
                    format(string, sizeof(string), "* %s unbuckles their seatbelt", GetName(playerid));
                    NearByMessage(playerid, PURPLE, string);
                }
            }
        }
    }
    return 1;
}
Reply
#3

Only case statements may appear within a switch statement, but if-statements may appear within a case statement. If that made sense.
Reply
#4

Removed Message
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Only case statements may appear within a switch statement, but if-statements may appear within a case statement. If that made sense.
Yeah I got it thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)