Got a case problem.
#1

Yo everyone, Uhm my problem is with this code:

pawn Код:
IsPlayerHR313SRCar(playerid)
{
  switch(GetPlayerVehicleID(playerid))
  {
        case HR313SR[0], HR313SR[1], HR313SR[2], HR313SR[3], HR313SR[4]:
        return 1;
    }
  return 1;
}
I get this error:

Код:
error 008: must be a constant expression; assumed zero
Reply
#2

Quote:

IsPlayerHR313SRCar(playerid)
{
switch(GetPlayerVehicleID(playerid))
case HR313SR[0], HR313SR[1], HR313SR[2], HR313SR[3], HR313SR[4]:

return 1;
}

Try now.
Reply
#3

Brings up like 9 errors most because of it not being closed with a return 1; - return 0; after the other return, anyways, got any other ideas?
Reply
#4

I don't think you can use arrays in switch case statements.

Reply
#5

Quote:
Originally Posted by Baked-Banana
I don't think you can use arrays in switch case statements.

What kind of way should I then do this? Could you help me out please
Reply
#6

I'm not sure. Maybe just don't use arrays for those vehicle ids? Or you could assign them to variables at the switch case statement. Or you could just not use a switch case. Take your pick.
Reply
#7

I might seem extremely noobish at this but really I'm a beginner.

However is this what you meant? If yes then it's not working
pawn Код:
IsPlayerHR313SRCar(playerid)
{
    HR313SR[0];
    HR313SR[1];
  HR313SR[2];
    HR313SR[3];
    HR313SR[4];
  return 0;
}
Reply
#8

pawn Код:
IsPlayerHR313SRCar(playerid)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    for(new i=0; i < sizeof(HR313SR); i++)
    {
        if(vehicleid == HR313SR[i])
        {
            return 1;
        }
    }
    return 0;
}
Reply
#9

Quote:
Originally Posted by MadeMan
pawn Код:
IsPlayerHR313SRCar(playerid)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    for(new i=0; i < sizeof(HR313SR); i++)
    {
        if(vehicleid == HR313SR[i])
        {
            return 1;
        }
    }
    return 0;
}
Thanks! Helped me out there ^^ Running smooth now, also thanks to Flashy and Baked-Banana for giving it a try
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)