Help with this
#1

So guys...how i can make this code:

pawn Код:
if(classid == 0)
    {
        GameTextForPlayer(playerid, "~w~Bather", 5000, 5);
    }
    else if(classid == 1)
    {
        GameTextForPlayer(playerid, "~w~Bather", 5000, 5);
    }
    else if(classid == 2)
    {
        GameTextForPlayer(playerid, "~w~Bather", 5000, 5);
    }
    else if(classid == 3)
    {
        GameTextForPlayer(playerid, "~w~Bather", 5000, 5);
    }
    else if(classid == 4)
    {
        GameTextForPlayer(playerid, "~w~Bather", 5000, 5);
    }
    else if(classid == 5)
    {
        GameTextForPlayer(playerid, "~w~Bather", 5000, 5);
    }
    else if(classid == 6)
    {
        GameTextForPlayer(playerid, "~r~Beach Guard", 5000, 5);
    }
    else if(classid == 7)
    {
        GameTextForPlayer(playerid, "~r~Beach Guard", 5000, 5);
    }
    else if(classid == 8)
    {
        GameTextForPlayer(playerid, "~r~Beach Guard", 5000, 5);
    }
With less lines?I remember something with case but i forgot it.

Thanks.
Reply
#2

Use switch
pawn Код:
switch(classid )
{
    case 0..5: GameTextForPlayer(playerid, "~w~Bather", 5000, 5);
    case 6..8: GameTextForPlayer(playerid, "~r~Beach Guard", 5000, 5);
}
Reply
#3

if(classid == 1||classid==2...

or use switch like...

switch(classid){
case 0..8:
GameTextForPlayer(playerid, "~r~Beach Guard", 5000, 5);
}
Reply
#4

Yeah got it,thanks !
Reply
#5

new string[24] = "~r~Bather";
new string2[24] = "~r~Beach guard";
GameTextForPlayer(playerid,(classid > 0 && classid < 6) ? string : string2, 5000, 5);

might work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)