Got a case problem. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Got a case problem. (
/showthread.php?tid=153192)
Got a case problem. -
oliverrud - 07.06.2010
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
Re: Got a case problem. -
Flashy - 07.06.2010
Quote:
IsPlayerHR313SRCar(playerid)
{
switch(GetPlayerVehicleID(playerid))
case HR313SR[0], HR313SR[1], HR313SR[2], HR313SR[3], HR313SR[4]:
return 1;
}
|
Try now.
Re: Got a case problem. -
oliverrud - 07.06.2010
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?
Re: Got a case problem. -
Backwardsman97 - 07.06.2010
I don't think you can use arrays in switch case statements.
Re: Got a case problem. -
oliverrud - 07.06.2010
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
Re: Got a case problem. -
Backwardsman97 - 07.06.2010
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.
Re: Got a case problem. -
oliverrud - 07.06.2010
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;
}
Re: Got a case problem. -
MadeMan - 07.06.2010
pawn Код:
IsPlayerHR313SRCar(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
for(new i=0; i < sizeof(HR313SR); i++)
{
if(vehicleid == HR313SR[i])
{
return 1;
}
}
return 0;
}
Re: Got a case problem. -
oliverrud - 07.06.2010
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