CMD:invite(playerid, params[]) {
new string[128], id;
if(PlayerInfo[playerid][pFaction] == 0) return SendErrorMessage(playerid, "You're not part of any faction.");
if(FactionRank[PlayerInfo[playerid][pFaction]][PlayerInfo[playerid][pFactionrank]][fInviteKick] < 1) return SendErrorMessage(playerid, "You do not have the permission required to invite new faction members.");
if(sscanf(params, "u", id)) return SendSyntaxMessage(playerid, "/invite <playerid/partofname>");
if(!IsPlayerConnected(id)) return SendErrorMessage(playerid, "Player is not connected.");
PlayerInfo[id][pFaction] = PlayerInfo[playerid][pFaction];
PlayerInfo[id][pFactionrank] = 1;
format(string, sizeof(string), "You've invited %s to the faction.", PlayerName(id, false));
SendInfoMessage(playerid, string);
format(string, sizeof(string), "You've been invited to %s by %s.", FactionInfo[PlayerInfo[playerid][pFaction]][fName], PlayerName(playerid, false));
SendInfoMessage(id, string);
return 1;
}
if(FactionRank[PlayerInfo[playerid][pFaction]][PlayerInfo[playerid][pFactionrank]][fInviteKick] < 1) return SendErrorMessage(playerid, "You do not have the permission required to invite new faction members.");
enum fRanks {
fID,
fFaction,
fRank,
fName[40],
fInviteKick,
fPromoteDemote,
fMoneyManage,
fBuildingManage,
fFactionManage
}; new FactionRank[MAX_FACTIONS][MAX_FACTIONRANKS][fRanks];
if ((0 <= PlayerInfo[playerid][pFaction] < sizeof FactionRank) && (0 <= PlayerInfo[playerid][pFactionrank] < sizeof FactionRank[]))
{
if (FactionRank[PlayerInfo[playerid][pFaction]][PlayerInfo[playerid][pFactionrank]][fInviteKick] < 1) return SendErrorMessage(playerid, "You do not have the permission required to invite new faction members.");
}
else return SendErrorMessage(playerid, "Not in faction or not correct rank..");// modify this line
Run time errors in commands return the unknown command message. Crashdetect would tell you exactly what is wrong but it's obvious in your case: Run time error 4.
To prevent it, you need to check both pFaction and pFactionrank of the player because if the value of it is not valid (0 to sizeof FactionRank - 1) will give you the run time error. pawn Код:
|