SA-MP Forums Archive
Rank of player isn't showing in /fchat? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Rank of player isn't showing in /fchat? (/showthread.php?tid=350524)



Rank of player isn't showing in /fchat? - cloudysky - 12.06.2012

Yeah the command works but it isn't showing my rank when I use it.

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;
}



Re: Rank of player isn't showing in /fchat? - Kindred - 12.06.2012

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", CheckPlayerRank(playerid), playername, message);
            SendFactionMessage(playerid, COLOUR_LRED, string);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOUR_WHITE, "HINT: You are not in a faction." );
    }
    return 1;
}

stock CheckPlayerRank(playerid)
{
    new RankName[24];
    switch(PlayerInfo[playerid][Faction])
    {
        case 0:
        {
            RankName = "Civilian";
        }
        case 1: //This is just an example, LSPD faction.
        {
            switch(PlayerInfo[playerid][FactionRank])
            {
                case 0: { RankName = "Cadet" }
                case 1: { RankName = "Officer" }
                //etc
            }
        }
        //More factions made like above
    }
    return RankName;
}
Just an example, untested. If it is not a string, it should check what number the faction your in is, and then change the rank according to there own rank. It then returns the string.