Switch issue -
[TC]XxJuggaloxX - 07.03.2013
Okay, So I have this switch statement, it has no errors what so ever, and it seems to only show case 3 and not any other case inside the switch. Is there an error in here somewhere? When I compile it shows no errors..
pawn Код:
switch(groupVariables[playerVariables[playerid][pGroup]][gGroupType])
{
case 0: { switch(playerVariables[playerid][pGroupRank]) {
case 5: SendClientMessage(playerid, COLOR_GRAD5,"[Family] {FFFFFF}- /g /gdeposit /gwithdraw /showmotd /invite /uninvite /changerank /gwithdraw /gdeposit /gmotd /lockhq /listmygroup");
case 6: SendClientMessage(playerid, COLOR_GRAD5,"[Family] {FFFFFF}- /g /gdeposit /gwithdraw /showmotd /invite /uninvite /changerank /gwithdraw /gdeposit /gmotd /lockhq /listmygroup \n/granknames /gname /gsafepos");
default: SendClientMessage(playerid, COLOR_GRAD5,"[Family] {FFFFFF}- /g /gdeposit /showmotd"); }
}
case 1: { switch(playerVariables[playerid][pGroupRank]) {
case 4: SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike\n/listmygroup /swatinv /spikes");
case 5: SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike\n/gwithdraw /listmygroup /swatinv /spikes /invite /uninvite /changerank /gwithdraw /gmotd /lockhq /gov");
case 6: SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike\n/gwithdraw /listmygroup /swatinv /spikes /invite /uninvite /changerank /gwithdraw /gmotd /lockhq /gov /granknames /gname /gsafepos");
default: SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike"); }
}
case 2: { switch(groupVariables[playerVariables[playerid][pGroup]][gDeptAble]) {
case 1: { switch(groupVariables[playerVariables[playerid][pGroup]][gRadioAble])
{ case 1: { switch(playerVariables[playerid][pGroupRank]) { case 6: SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /r /d /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /taxrate /gsafepos"); default: SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /r /d /showmotd /gdeposit"); }
} default: { switch(playerVariables[playerid][pGroupRank]) { case 6: SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /d /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /taxrate /gsafepos"); default: SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /d /showmotd /gdeposit"); } } } }
default: { switch(groupVariables[playerVariables[playerid][pGroup]][gRadioAble])
{ case 1: { switch(playerVariables[playerid][pGroupRank]) { case 6: SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /r /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /taxrate /gsafepos"); default: SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /r /showmotd /gdeposit"); }
} default: { switch(playerVariables[playerid][pGroupRank]) { case 6: SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /taxrate /gsafepos"); default: SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /showmotd /gdeposit"); } } } } }
}
case 3: { switch(groupVariables[playerVariables[playerid][pGroup]][gDeptAble]) {
case 1: { switch(groupVariables[playerVariables[playerid][pGroup]][gRadioAble])
{ case 1: { switch(playerVariables[playerid][pGroupRank]) { case 6: SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /r /d /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /gsafepos"); default: SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /r /d /showmotd /gdeposit"); }
} default: { switch(playerVariables[playerid][pGroupRank]) { case 6: SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /d /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /gsafepos"); default: SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /d /showmotd /gdeposit"); } } } }
default: { switch(groupVariables[playerVariables[playerid][pGroup]][gRadioAble])
{ case 1: { switch(playerVariables[playerid][pGroupRank]) { case 6: SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /r /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /gsafepos"); default: SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /r /showmotd /gdeposit"); }
} default: { switch(playerVariables[playerid][pGroupRank]) { case 6: SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /gsafepos"); default: SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /showmotd /gdeposit"); } } } } }
}
}
Re: Switch issue -
Bakr - 07.03.2013
Due to the horribly placed braces, I would predict one is unaligned and is throwing an error somewhere. Otherwise make sure the variable you are checking is actually a different number than 3.
Re: Switch issue -
Babul - 07.03.2013
look how beautiful that looks now:
pawn Код:
switch(groupVariables[playerVariables[playerid][pGroup]][gGroupType])
{
case 0:
{
switch(playerVariables[playerid][pGroupRank])
{
case 5:
SendClientMessage(playerid, COLOR_GRAD5,"[Family] {FFFFFF}- /g /gdeposit /gwithdraw /showmotd /invite /uninvite /changerank /gwithdraw /gdeposit /gmotd /lockhq /listmygroup");
case 6:
SendClientMessage(playerid, COLOR_GRAD5,"[Family] {FFFFFF}- /g /gdeposit /gwithdraw /showmotd /invite /uninvite /changerank /gwithdraw /gdeposit /gmotd /lockhq /listmygroup \n/granknames /gname /gsafepos");
default:
SendClientMessage(playerid, COLOR_GRAD5,"[Family] {FFFFFF}- /g /gdeposit /showmotd");
}
}
case 1:
{
switch(playerVariables[playerid][pGroupRank])
{
case 4:
SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike\n/listmygroup /swatinv /spikes");
case 5:
SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike\n/gwithdraw /listmygroup /swatinv /spikes /invite /uninvite /changerank /gwithdraw /gmotd /lockhq /gov");
case 6:
SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike\n/gwithdraw /listmygroup /swatinv /spikes /invite /uninvite /changerank /gwithdraw /gmotd /lockhq /gov /granknames /gname /gsafepos");
default:
SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike");
}
}
case 2:
{
switch(groupVariables[playerVariables[playerid][pGroup]][gDeptAble])
{
case 1:
{
switch(groupVariables[playerVariables[playerid][pGroup]][gRadioAble])
{
case 1:
{
switch(playerVariables[playerid][pGroupRank])
{
case 6:
SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /r /d /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /taxrate /gsafepos");
default:
SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /r /d /showmotd /gdeposit");
}
}
default:
{
switch(playerVariables[playerid][pGroupRank])
{
case 6:
SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /d /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /taxrate /gsafepos");
default:
SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /d /showmotd /gdeposit");
}
}
}
}
default:
{
switch(groupVariables[playerVariables[playerid][pGroup]][gRadioAble])
{
case 1:
{
switch(playerVariables[playerid][pGroupRank])
{
case 6:
SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /r /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /taxrate /gsafepos");
default:
SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /r /showmotd /gdeposit");
}
}
default:
{
switch(playerVariables[playerid][pGroupRank])
{
case 6:
SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /taxrate /gsafepos");
default:
SendClientMessage(playerid, COLOR_GRAD5,"[Government] {FFFFFF}- /showmotd /gdeposit");
}
}
}
}
}
}
case 3:
{
switch(groupVariables[playerVariables[playerid][pGroup]][gDeptAble])
{
case 1:
{
switch(groupVariables[playerVariables[playerid][pGroup]][gRadioAble])
{
case 1:
{
switch(playerVariables[playerid][pGroupRank])
{
case 6:
SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /r /d /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /gsafepos");
default:
SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /r /d /showmotd /gdeposit");
}
}
default:
{
switch(playerVariables[playerid][pGroupRank])
{
case 6:
SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /d /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /gsafepos");
default:
SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /d /showmotd /gdeposit");
}
}
}
}
default:
{
switch(groupVariables[playerVariables[playerid][pGroup]][gRadioAble])
{
case 1:
{
switch(playerVariables[playerid][pGroupRank])
{
case 6:
SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /r /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /gsafepos");
default:
SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /r /showmotd /gdeposit");
}
}
default:
{
switch(playerVariables[playerid][pGroupRank])
{
case 6:
SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /showmotd /gdeposit /gwithdraw /listmygroup /invite /uninvite /changerank /gmotd /granknames /gname /lockhq /gsafepos");
default:
SendClientMessage(playerid, COLOR_GRAD5,"[Medic] {FFFFFF}- /showmotd /gdeposit");
}
}
}
}
}
}
1 } missing at the end?
Re: Switch issue -
[TC]XxJuggaloxX - 07.03.2013
Nope that didn't work. And the only reason it looked like that is because I put it like that to make it so I could see it better. It was like that on purpose.
Re: Switch issue -
[TC]XxJuggaloxX - 07.03.2013
Wow, So I feel like a HUGE DURP. Anyone else? No? Let me tell you why you and I are derps.
Check out the SendClientMessage lines. Notice anything?
No?
pawn Код:
case 6:
{
SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /gname");
SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /backup /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike\n/gwithdraw /gsafepos");
SendClientMessage(playerid, COLOR_GRAD5,"[Police] {FFFFFF}- /listmygroup /swatinv /spikes /invite /uninvite /changerank /gwithdraw /gmotd /lockhq /gov /granknames");
}
How about now? Yeah you do. The friggin lines were HUGE.
This topic can be closed now.
Re: Switch issue -
Babul - 08.03.2013
hehe, the "\n" in the strings were suspicious already, we know that they cannot be sent this way. did removing them/splitting lines solve the problem? i tend to think that those lines are (were) still too long. so you decided to either send more lines or put them into a dialog...
but yes, to me the code looked good. as i posted it, i didnt change anything, despite the indentation lol
if you would have posted the code indented properly, i would have found the bug. maybe ^^
btw, you took my job!
[ame]http://www.youtube.com/watch?v=f38Y0i0-mHA[/ame]
oh, iam busy for 10 hours now...
Re: Switch issue -
[TC]XxJuggaloxX - 08.03.2013
Yes I did notice the "\n" in which after I saw those, I gotta say. I feel like a huge tardmuffin xD
I was converting it over from a Dialog to a SendClientMessage and didn't realize some of the stupidity in what I did when I asked for help xD
The string do work now as I have shortened them. I even updated them a bit.
So not instead of "Police" "Medics" etc. It will say a 4 letter Tag for the Group
pawn Код:
case 1: {
switch(playerVariables[playerid][pGroupRank]) {
case 4: {
format(string, sizeof(string), "[%s] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup", groupVariables[playerVariables[playerid][pGroup]][gGroupTag]); SendClientMessage(playerid, COLOR_GRAD5,string);
format(string, sizeof(string), "[%s] {FFFFFF}- /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike /listmygroup /swatinv /spikes", groupVariables[playerVariables[playerid][pGroup]][gGroupTag]); SendClientMessage(playerid, COLOR_GRAD5,string);
}
case 5: {
format(string, sizeof(string), "[%s] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup", groupVariables[playerVariables[playerid][pGroup]][gGroupTag]); SendClientMessage(playerid, COLOR_GRAD5,string);
format(string, sizeof(string), "[%s] {FFFFFF}- /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike /gwithdraw /listmygroup", groupVariables[playerVariables[playerid][pGroup]][gGroupTag]); SendClientMessage(playerid, COLOR_GRAD5,string);
format(string, sizeof(string), "[%s] {FFFFFF}- /swatinv /spikes /invite /uninvite /changerank /gwithdraw /gmotd /lockhq /gov", groupVariables[playerVariables[playerid][pGroup]][gGroupTag]); SendClientMessage(playerid, COLOR_GRAD5,string);
}
case 6: {
format(string, sizeof(string), "[%s] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /gname", groupVariables[playerVariables[playerid][pGroup]][gGroupTag]); SendClientMessage(playerid, COLOR_GRAD5,string);
format(string, sizeof(string), "[%s] {FFFFFF}- /backup /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike /gwithdraw /gsafepos", groupVariables[playerVariables[playerid][pGroup]][gGroupTag]); SendClientMessage(playerid, COLOR_GRAD5,string);
format(string, sizeof(string), "[%s] {FFFFFF}- /listmygroup /swatinv /spikes /invite /uninvite /changerank /gwithdraw /gmotd /lockhq /gov /granknames", groupVariables[playerVariables[playerid][pGroup]][gGroupTag]); SendClientMessage(playerid, COLOR_GRAD5,string);
}
default: {
format(string, sizeof(string), "[%s] {FFFFFF}- /r /d /m /su /wanted /fingerprint /ticket /cuff /uncuff /tazer /lspd /showmotd /gdeposit /backup", groupVariables[playerVariables[playerid][pGroup]][gGroupTag]); SendClientMessage(playerid, COLOR_GRAD5,string);
format(string, sizeof(string), "[%s] {FFFFFF}- /cancelbackup /acceptbackup /confiscate /deployspike /destroyspike", groupVariables[playerVariables[playerid][pGroup]][gGroupTag]); SendClientMessage(playerid, COLOR_GRAD5,string);
}
}
}
Re: Switch issue -
Babul - 08.03.2013
you will feel better when you convert the next dialog to a clientmessage... good to know that the code works, but i have to say it looks horrible again now. i rarely align blocks the way you did - i simply fold the code so its invisible. the trick with the brace at the end of each case line makes a folded codeblock take 1 line only.