SA-MP Forums Archive
help with case - 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)
+--- Thread: help with case (/showthread.php?tid=561261)



help with case - Karolukas123 - 02.02.2015



As the case make it clicks once sent her a message and the second time you sent yet another message


Re: help with case - Schneider - 02.02.2015

You can't use else-statements in a switch. You could however use a default-statement:

pawn Код:
switch(something)
{
    case 0: { if something is '0' }
    case 1: { if something is '1' }
    case 2, 3, 4: { if something is 2, 3 or 4 }
    case 5..20:    { if something is between 5 and 20 }
    default:         { this is like an 'else-statement' if no other matches were found }
}



Re: help with case - Karolukas123 - 02.02.2015


Im get error


Re: help with case - Schneider - 02.02.2015

If you use multiple functions in 1 case, you have to put them between brackets { }

Just do it like you did in the first post, but change 'else' to 'default'.


Re: help with case - Karolukas123 - 02.02.2015

Quote:
Originally Posted by Schneider
Посмотреть сообщение
If you use multiple functions in 1 case, you have to put them between brackets { }

Just do it like you did in the first post, but change 'else' to 'default'.
I did as you said, but I still did not work. I'm running all the choices are not used but not the only one I want.


Re: help with case - F1re - 02.02.2015

Quote:
Originally Posted by Karolukas123
Посмотреть сообщение

Im get error
Код:
RodomGreitaMygtuka = false;
You need to put a comma.

Код:
switch(RodomGreitaMygtuka)
{
    case 0: RodomGreitaMygtuka = false, SendClientMessage(playerid, -1, "...");
    default: RodomGreitaMygtuka = true, SendClientMessage(playerid, -1, "...");
}