SA-MP Forums Archive
What is the problem there ? - 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: What is the problem there ? (/showthread.php?tid=461467)



What is the problem there ? - SilentSoul - 02.09.2013

It's about my admin chat command , any one type /ac he get my name and rank for example my friend if he type /ac text he it show me this [Owner]SilentSoul:text....
Codes
pawn Код:
CMD:ac(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] == 0)return SendClientMessage(playerid,-1,"{FF0000}[ERROR]:{FAF5F5}You are not{FF0000} Administrator {FAF5F5}to use admin chat");
    new name[1024],i , text[126];
    if(sscanf(params, "s[126]", text))return SendClientMessage(playerid,-1,"{FF0000}[System Usage]:{FAF5F5}/ac [text]");
    GetPlayerName(i, name, sizeof(name));
    format(text, sizeof(text), "{FFD700}[%s] %s: %s", GetPlayerAdminRank(i),name ,text);
    SendMessageToAdmins(text);
    return 1;
}
About GetPlayerAdminRank

pawn Код:
stock GetPlayerAdminRank(playerid)
{
    new rankname[32];

    switch(PlayerInfo[playerid][pAdminLevel])
    {
        case 1: { rankname = "Moderator"; }
        case 2: { rankname = "Admin"; }
        case 3: { rankname = "Head Admin"; }
        case 4: { rankname = "Owner"; }
    }

    return rankname;
}
And SendMessage To Admins stock
pawn Код:
stock SendMessageToAdmins(text[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)

    {
        if(PlayerInfo[i][pAdminLevel] > 0)
        {
            SendClientMessage(i, -1, text);
        }
    }
}
Sorry for my bad english :/


Re: What is the problem there ? - Borg - 02.09.2013

You should use playerid id in CMD:ac and not i.

Код:
CMD:ac(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] == 0)return SendClientMessage(playerid,-1,"{FF0000}[ERROR]:{FAF5F5}You are not{FF0000} Administrator {FAF5F5}to use admin chat");
    new name[1024], text[126];
    if(sscanf(params, "s[126]", text))return SendClientMessage(playerid,-1,"{FF0000}[System Usage]:{FAF5F5}/ac [text]");
    GetPlayerName(playerid, name, sizeof(name));
    format(text, sizeof(text), "{FFD700}[%s] %s: %s", GetPlayerAdminRank(playerid),name ,text);
    SendMessageToAdmins(text);
    return 1;
}



Re: What is the problem there ? - SilentSoul - 02.09.2013

-Thank you , i will test later thanks for reply