if(sscanf(params, "ui", id, rank)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setrank [playerid] [rank] (1-5)");
{
if(PlayerInfo[playerid][pFacLeader] == 1 || PlayerInfo[playerid][pAdmin] == 4)
{
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "That player is not connected!");
if(rank > 5) return SendClientMessage(playerid, COLOR_RED, "You can't set a rank higher than 5!");
if(rank > PlayerInfo[playerid][pFacRank]) return SendClientMessage(playerid, COLOR_GREEN, "PROMOTION!");
switch(rank)
{
case 1:
{
switch(PlayerInfo[playerid][pFac])
{
case 1:
{
format(string, sizeof(string), "%s set your rank to Cadet!", pName);
}
case 2:
{
format(string, sizeof(string), "%s set your rank to Associate!", pName);
}
case 3:
{
format(string, sizeof(string), "%s set your rank to Associate!", pName);
}
case 4:
{
format(string, sizeof(string), "%s set your rank to Raw Recruit!", pName);
}
case 5:
{
format(string, sizeof(string), "%s set your rank to Raw Recruit!", pName);
}
}
}
case 2:
{
switch(PlayerInfo[playerid][pFac])
{
case 1:
{
format(string, sizeof(string), "%s set your rank to Trooper!", pName);
}
case 2:
{
format(string, sizeof(string), "%s set your rank to Soldier!", pName);
}
case 3:
{
format(string, sizeof(string), "%s set your rank to Soldier!", pName);
}
case 4:
{
format(string, sizeof(string), "%s set your rank to Street Soldier!", pName);
}
case 5:
{
format(string, sizeof(string), "%s set your rank to Street Soldier!", pName);
}
}
}
case 3:
{
switch(PlayerInfo[playerid][pFac])
{
case 1:
{
format(string, sizeof(string), "%s set your rank to Lieutenant!", pName);
}
case 2:
{
format(string, sizeof(string), "%s set your rank to Capo!", pName);
}
case 3:
{
format(string, sizeof(string), "%s set your rank to Capo!", pName);
}
case 4:
{
format(string, sizeof(string), "%s set your rank to Gang Fighter!", pName);
}
case 5:
{
format(string, sizeof(string), "%s set your rank to Gang Fighter!", pName);
}
}
}
case 4:
{
switch(PlayerInfo[playerid][pFac])
{
case 1:
{
format(string, sizeof(string), "%s set your rank to Deputy Chief of Police!", pName);
}
case 2:
{
format(string, sizeof(string), "%s set your rank to Underboss!", pName);
}
case 3:
{
format(string, sizeof(string), "%s set your rank to Underboss!", pName);
}
case 4:
{
format(string, sizeof(string), "%s set your rank to Henchman!", pName);
}
case 5:
{
format(string, sizeof(string), "%s set your rank to Henchman!", pName);
}
}
}
case 5:
{
switch(PlayerInfo[playerid][pFac])
{
case 1:
{
format(string, sizeof(string), "%s set your rank to Chief of Police!", pName);
}
case 2:
{
format(string, sizeof(string), "%s set your rank to Boss!", pName);
}
case 3:
{
format(string, sizeof(string), "%s set your rank to Boss!", pName);
}
case 4:
{
format(string, sizeof(string), "%s set your rank to Gang Leader!", pName);
}
case 5:
{
format(string, sizeof(string), "%s set your rank to Gang Leader!", pName);
}
}
if(rank > PlayerInfo[playerid][pFacRank]) return SendClientMessage(playerid, COLOR_GREEN, "PROMOTION!");
if(rank > PlayerInfo[playerid][pFacRank]) SendClientMessage(playerid, COLOR_GREEN, "PROMOTION!");
static const ranks[][][] = {
/* 0 */ { "Cadet", "Trooper", "Lieutenant", "Deputy Chief of Police", "Chief of Police" },
/* 1 */ { "Associate", "Soldier", "Capo", "Underboss", "Boss" },
/* 2 */ { "Associate", "Soldier", "Capo", "Underboss", "Boss" },
/* 3 */ { "Raw Recruit", "Street Soldier", "Gang Fighter", "Henchman", "Gang Leader" },
/* 4 */ { "Raw Recruit", "Street Soldier", "Gang Fighter", "Henchman", "Gang Leader" }
};
format(string, sizeof(string), "%s set your rank to %s!", pName, ranks[PlayerInfo[playerid][pFac] - 1][rank - 1]);
Because you have a return right there. Return stops the function immediately.
Also use constant arrays to store the rank instead of repeating "set your rank to" a hundred times. If you ever wanted to change that message you'd have to change it in hundred different places which is far from ideal. Your current setup is also quite weird. Why not switch through factions first, then through ranks so you at least have them more or less together? Something like this might work. It gets rid of the switch structure entirely. Not tested. PHP код:
|