What's wrong with this code?
#1

pawn Код:
public WantedColor()
{
    for (new i; i < MAX_PLAYERS; i++)
    {
        switch(GetPlayerWantedLevel(i))
        {
            case 1...3:
            Ticketable[i] = Create3DTextLabel("Suspect - Ticketable",yellow,30.0,40.0,50.0,40.0,0);
            Attach3DTextLabelToPlayer(Ticketable[i], i, 0.0, 0.0, 0.7);
            SetPlayerColor(i,yellow);

            case 4...10:
            Arrestable[i] = Create3DTextLabel("Suspect - Arrestable",red,30.0,40.0,50.0,40.0,0);
            Attach3DTextLabelToPlayer(Arrestable[i], i, 0.0, 0.0, 0.7);
            SetPlayerColor(i,red);
        }
    }
}
2003 : error 001: expected token: ":", but found "..."
2003 : error 029: invalid expression, assumed zero
2003 : error 029: invalid expression, assumed zero
2003 : fatal error 107: too many error messages on one line

Line 2003:

pawn Код:
case 1...3:
Reply
#2

Change

pawn Код:
case 1...3:
to

pawn Код:
case 1 .. 3:

and same for the second one.
Reply
#3

Now i get this:

Quote:

2005 : error 002: only a single statement (or expression) can follow each "case"
2005 : warning 215: expression has no effect
2008 : error 014: invalid statement; not in switch
2008 : warning 215: expression has no effect
2008 : error 001: expected token: ";", but found ".."
2008 : error 029: invalid expression, assumed zero
2008 : fatal error 107: too many error messages on one line

Line 2005:
pawn Код:
Attach3DTextLabelToPlayer(Ticketable[i], i, 0.0, 0.0, 0.7);
Line 2008:
pawn Код:
Arrestable[i] = Create3DTextLabel("Suspect - Arrestable",red,30.0,40.0,50.0,40.0,0);
Reply
#4

pawn Код:
public WantedColor()
{
    for (new i; i < MAX_PLAYERS; i++)
    {
        switch(GetPlayerWantedLevel(i))
        {
            case 1 .. 3: {
                  Ticketable[i] = Create3DTextLabel("Suspect - Ticketable",yellow,30.0,40.0,50.0,40.0,0);
                  Attach3DTextLabelToPlayer(Ticketable[i], i, 0.0, 0.0, 0.7);
                  SetPlayerColor(i,yellow);
            }

            case 4 .. 10: {
                  Arrestable[i] = Create3DTextLabel("Suspect - Arrestable",red,30.0,40.0,50.0,40.0,0);
                  Attach3DTextLabelToPlayer(Arrestable[i], i, 0.0, 0.0, 0.7);
                  SetPlayerColor(i,red);
            }
        }
    }
}
Reply
#5

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Now i get this:



Line 2005:
pawn Код:
Attach3DTextLabelToPlayer(Ticketable[i], i, 0.0, 0.0, 0.7);
Line 2008:
pawn Код:
Arrestable[i] = Create3DTextLabel("Suspect - Arrestable",red,30.0,40.0,50.0,40.0,0);
Basically you must put the brackets open and close after Case, this is how it works. like the following:-

pawn Код:
case 1 .. 3:
{
}
//res of the code
Original topic: https://sampwiki.blast.hk/wiki/Control_Structures#case
Reply
#6

Nope,doesn't work.
Reply
#7

Quote:
Originally Posted by FalconX
Посмотреть сообщение
Basically you must put the brackets open and close after Case, this is how it works. like the following:-

pawn Код:
case 1 .. 3:
{
}
//res of the code
Original topic: https://sampwiki.blast.hk/wiki/Control_Structures#case
This must be like this:
pawn Код:
case 1 .. 3:
{
    //res of the code
}
Reply
#8

Yes mate that's what I meant, I put the "//rest of the code" down so he can continue his code like the above code

Like this:-

pawn Код:
case 1 .. 3:
{
    //rest of the code
}
// rest of your code.

-FalconX
Reply
#9

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Nope,doesn't work.
If my code won't work so I will just leave the earth.
Reply
#10

Quote:
Originally Posted by Mandrakke
Посмотреть сообщение
If my code won't work so I will just leave the earth.
Hahahha made me laugh in real life Well it should work :/

-FalconX
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)