SA-MP Forums Archive
/clearchat? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /clearchat? (/showthread.php?tid=253338)



/clearchat? - Type-R - 06.05.2011

Hi is there anyway of making a command /clearchat that would clear out the chat, like move the messages up?


Re: /clearchat? - o_O - 06.05.2011

Send several /n.


Respuesta: /clearchat? - Alex_Obando - 06.05.2011

pawn Код:
// === [Clearchat] ===
    if(strcmp(cmdtext, "/clearchat", true) == 0)
    {
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                SendClientMessageToAll(COLOR_SYSTEM, " ");
                GameTextForAll("Chat cleared!", 1000,1);
                                return 1;
            }



Re: /clearchat? - o_O - 06.05.2011

Mega fail. I meant to say white spaces, not /n.

Thank you, Alex.


Re: /clearchat? - Type-R - 06.05.2011

OMG i couldn't think that for my self... Than you!!!


Re: /clearchat? - o_O - 06.05.2011

Btw, you should use a for statement.


Re: /clearchat? - Seven_of_Nine - 06.05.2011

I use a loop, instead of much SendClientMessage-s.
pawn Код:
COMMAND:clearchat(playerid) {
    new
        name1[30],
        text[128];
    if(PlayerInfo[playerid][pAdminLevel] >= 3) {
        for(new i = 0; i < 100; i++) {
            SendClientMessageToAll(COLOR_WHITE," ");
        }
        GetPlayerName(playerid,name1,sizeof(name1));
        format(text,sizeof(text),"Administrator \"%s\" has cleared the chat.",name1);
        SendClientMessageToAll(medblue,text);
        SaveIn("clearchat",text);
    } else {
        return SendClientMessage(playerid,red,"Only lvl3 or higher admins can use this command.");
    }
    return 1;
}



Re: /clearchat? - Calgon - 06.05.2011

Using a loop instead of static code is less efficient.


Re: /clearchat? - Mean - 06.05.2011

Quote:
Originally Posted by Seven_of_Nine
Посмотреть сообщение
I use a loop, instead of much SendClientMessage-s.
pawn Код:
COMMAND:clearchat(playerid) {
    new
        name1[30],
        text[128];
    if(PlayerInfo[playerid][pAdminLevel] >= 3) {
        for(new i = 0; i < 100; i++) {
            SendClientMessageToAll(COLOR_WHITE," ");
        }
        GetPlayerName(playerid,name1,sizeof(name1));
        format(text,sizeof(text),"Administrator \"%s\" has cleared the chat.",name1);
        SendClientMessageToAll(medblue,text);
        SaveIn("clearchat",text);
    } else {
        return SendClientMessage(playerid,red,"Only lvl3 or higher admins can use this command.");
    }
    return 1;
}
That's copied, he doesn't have thoose AdminLevel vars. So
pawn Код:
CMD:clearchat( playerid, params[ ] )  {
    for( new i = 0; i < 50; i++ ) SendClientMessageToAll( -1, " " );
    return 1;
}

@Calgon: Could be, but this is shorter.


Re: /clearchat? - Seven_of_Nine - 06.05.2011

Lol that'd return a warning, because you didn't use the params[].
pawn Код:
COMMAND:clearchat(playerid)  {
    if(IsPlayerAdmin(playerid) {
        for(new i = 0; i < 100; i++) SendClientMessageToAll(-1, " " );
    } else {
        return SendClientMessage(playerid,red,"ERROR: This command is only avaible for admins.");
    }
    return 1;
}