16.04.2016, 10:09
I actually didn't bother to check the code, I just fixed the indentation. Using "else" statement will solve it:
EDIT: Updated because setting the value before the switch.
PHP код:
CMD:badge(playerid, params[])
{
if(pInfo[playerid][Faction] == 0 || pInfo[playerid][Faction] >= 3) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not authorized to use this command!");
pDuty[playerid] = !pDuty[playerid];
switch(pInfo[playerid][Faction])
{
case 1:
{
if(pDuty[playerid])
{
SendClientMessage(playerid, COLOR_WHITE, "You are now on Duty");
SetPlayerColor(playerid, COLOR_PDRAD);
}
else
{
// off duty
}
}
case 2:
{
if(pDuty[playerid])
{
SendClientMessage(playerid, COLOR_WHITE, "You are now on Duty");
SetPlayerColor(playerid, COLOR_RED);
}
else
{
// off duty
}
}
case 3:
{
if(!pDuty[playerid])
{
SendClientMessage(playerid, COLOR_WHITE, "You are now off Duty");
SetPlayerColor(playerid, COLOR_WHITE);
}
else
{
// on duty
}
}
}
return 1;
}