Changing rank number to name.
#1

Hey basically on my faction chat i want it to display the rank name of the player but FactionRank is defined as a number not a rank name, I know i need to define it as the rank name instead of the number but i'm not entirely sure how to do it, any help would be appreciated.

Here is the code

pawn Код:
command(fchat, playerid, params[])
{
    if(PlayerInfo[playerid][FactionApartof] >= 1)
    {
        new message[128], playername[50], string[128];
        if(sscanf(params, "s[128]", message)) return SendClientMessage(playerid, COLOUR_WHITE, "HINT: /(f)chat [Message]" );
        {
            GetPlayerName(playerid, playername, 50);
            format(string, sizeof(string),"[FACTION CHAT]%s %s: %s", PlayerInfo[playerid][FactionRank], playername, message);
            SendFactionMessage(playerid, COLOUR_LRED, string);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOUR_WHITE, "HINT: You are not in a faction." );
    }
    return 1;
}
Reply
#2

You can make a function with a switch, that returns the rank name to each of the rank numbers. Something like:
pawn Код:
GetRank(rankNumber, rankName[])
{
    switch(PlayerInfo[playerid][FactionRank])
    {
        case 1: rankName = 'RankName1';
        case 2: rankName = 'RankName2';
        ...
    }
    return 1;
}
After just, just call it to store the rank name into the array passed in the function header.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)