/clearchat?
#1

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

Send several /n.
Reply
#3

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;
            }
Reply
#4

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

Thank you, Alex.
Reply
#5

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

Btw, you should use a for statement.
Reply
#7

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;
}
Reply
#8

Using a loop instead of static code is less efficient.
Reply
#9

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.
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)