Switch Cases
#1

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.
Reply
#2

This is the format:
pawn Код:
case(HInsurancePickup)
Reply
#3

Quote:
Originally Posted by Roko_foko
Посмотреть сообщение
as a case I can't put Variables?
Yes, case values must be constant.
Reply
#4

pawn Код:
case(HInsurancePickup):
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?
Reply
#5

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.
Reply
#6

Okay, thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)