Switch Cases - 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: Switch Cases (
/showthread.php?tid=269770)
Switch Cases -
Roko_foko - 17.07.2011
Hello, I have got an error in this code. What's the mistake, or as a case I can't put Variables?
pawn Код:
HInsurancePickup=CreatePickup(1239, 1, 1619.2758,1821.2875,10.8203);// Health Insurance
CreditCardPickup=CreatePickup(1239, 1, 2316.6211,-9.9971,26.7422);// CreditCart
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
switch(pickupid)
{
case HInsurancePickup:// ERROR is here
{
new string[20];
format(string,sizeof(string),"~g~Price:$%d",floatround((50*gSettings[COEFFICIENT]+50*gSettings[COEFFICIENT]*gSettings[VAT_NUMBER]),floatround_round));
GameTextForPlayer(playerid, string, 3000, 1);
}
case CreditCardPickup: // ERROR is here
{
new string[20];
format(string,sizeof(string),"~g~Price:$%d",floatround((167.6666666666666666666666666666*gSettings[COEFFICIENT]+166.6666666666666666666666666666667*gSettings[COEFFICIENT]*gSettings[VAT_NUMBER]),floatround_round));
GameTextForPlayer(playerid, string, 3000, 1);
}
}
return 1;
}
Quote:
error 008: must be a constant expression; assumed zero
|
Thanks in advance.
Re: Switch Cases -
||123|| - 17.07.2011
This is the format:
Re: Switch Cases -
MadeMan - 17.07.2011
Quote:
Originally Posted by Roko_foko
as a case I can't put Variables?
|
Yes, case values must be constant.
Re: Switch Cases -
Roko_foko - 17.07.2011
doesn't work :S
Quote:
Originally Posted by MadeMan
Yes, case values must be constant.
|
Is there any way I can make these Vars constant in this callback?
Re: Switch Cases -
MadeMan - 17.07.2011
Quote:
Originally Posted by Roko_foko
Is there any way I can make these Vars constant in this callback?
|
No, you can't use switch with variables.
Re: Switch Cases -
Roko_foko - 17.07.2011
Okay, thank you.