SA-MP Forums Archive
Administrative chat - 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: Administrative chat (/showthread.php?tid=435391)



Administrative chat - Fell - 06.05.2013

Hello everyone. I have a question regarding the admin chat.

Using this:
pawn Код:
dcmd_a(playerid, params[])
{
    new message[128], sendername[MAX_PLAYER_NAME], string[128];
    if(!sscanf(params, "s[128]", message))return SendClientMessage(playerid, -1, "Type: /a (your message)");
    {
        if(PlayerInfo[playerid][pAdmin] >= 1)
        {
            new d, m, y, h, mi, s;
            gettime(h, mi, s);
            getdate(y, m, d);
            GetPlayerName(playerid,sendername,sizeof(sendername));

            new arank[24];
            switch(PlayerInfo[playerid][pAdmin])
            {
                case 1:arank = "Trial Administrator";
                case 2:arank = "Normal Administrator";
                case 3:arank = "Senior Administrator";
                case 4:arank = "Lead Administrator";
                case 5:arank = "Head Administrator";
                case 6:arank = "Head of Admins";
                case 1337:arank = "Scripter";
                case 1338:arank = "Server Owner";
                default:arank = "Unknown / Player";
            }
            format(string, sizeof(string), "[%s] %s (%d): %s", arank, sendername, playerid, message);
            SendAdminMessage(COLOR_LIGHTRED, string);

            printf("%s %s: %s",arank, sendername, message);

            format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s %s: %s", arank, d, m, y, h, mi, s, sendername, message);
            AdminChatLog(string);
        }
    }
    return true;
}
Whenever I write /a Hello my name is bla bla bla

The only thing that comes up are /a Hello

I cannot add sentences somehow. Any ideas on how to fix that? Cheers!


Re: Administrative chat - Face9000 - 06.05.2013

s[128] - increase cell string size.


Re: Administrative chat - MattyG - 06.05.2013

Also, try changing the sscanf line to;

pawn Код:
if(sscanf(params, "s", message))return SendClientMessage(playerid, -1, "Type: /a (your message)");



Re: Administrative chat - Fell - 06.05.2013

.123


Re: Administrative chat - Fell - 06.05.2013

Quote:
Originally Posted by MattyG
Посмотреть сообщение
Also, try changing the sscanf line to;

pawn Код:
if(sscanf(params, "s", message))return SendClientMessage(playerid, -1, "Type: /a (your message)");
When editing that line it says Type: /a (your message) only


Re: Administrative chat - Fell - 06.05.2013

I increased the string size but yet the problem exists. Any other solutions please?


Re: Administrative chat - Jf - 06.05.2013

In this line:

pawn Код:
printf("%s %s: %s",arank, sendername, message);
Print's all the message?


Re: Administrative chat - Fell - 06.05.2013

Quote:
Originally Posted by Jf
Посмотреть сообщение
In this line:

pawn Код:
printf("%s %s: %s",arank, sendername, message);
Print's all the message?
Yeah but it is not necessary?


Re: Administrative chat - Jf - 06.05.2013

Try this.

pawn Код:
dcmd_a(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] == 0) return 1;
   
    new Message[128], Sendername[MAX_PLAYER_NAME];
    if(sscanf(params, "s[128]", Message)) return SendClientMessage(playerid, -1, "Type: /a (your message)");
    else
    {
        new arank[24];
        switch(PlayerInfo[playerid][pAdmin])
        {
            case 1:arank = "Trial Administrator";
            case 2:arank = "Normal Administrator";
            case 3:arank = "Senior Administrator";
            case 4:arank = "Lead Administrator";
            case 5:arank = "Head Administrator";
            case 6:arank = "Head of Admins";
            case 1337:arank = "Scripter";
            case 1338:arank = "Server Owner";
            default:arank = "Unknown / Player";
        }
       
        GetPlayerName(playerid, Sendername, MAX_PLAYER_NAME);
       
        new S[128];
        format(S, 128, "[%s] %s (%d): %s", arank, Sendername, playerid, Message);
        SendAdminMessage(COLOR_LIGHTRED, S);
       
        //Debug
        printf("String Lenght: %d", strlen(S)); // If is more than 128, will not send all the message!
       
        new d, m, y, h, mi, s; gettime(h, mi, s); getdate(y, m, d);
        format(S, 128, "(%d/%d/%d)[%d:%d:%d] %s %s: %s", arank, d, m, y, h, mi, s, Sendername, Message);
        AdminChatLog(S);
    }
    return 1;
}
If not works, try to chaging your "SendAdminMessage" function to this one:
pawn Код:
SendAdminMessage(color = -1, const message[], minadminlvl = 1)
{
    #if defined foreach
    foreach(Player, i) if(PlayerInfo[i][pAdmin] >= minadminlvl) SendClientMessage(i, color, message);
    #else
    for(new i; i < MAX_PLAYERS; i++)
        if(IsPlayerConnected(i))
            if(PlayerInfo[i][pAdmin] >= minadminlvl) SendClientMessage(i, color, message);
    #endif
    return 1;
}



Re: Administrative chat - Fell - 07.05.2013

With that one it only says Type: /a (your message)

Hmm...