/clearchat command
#1

How do I make the /clearchat command to delete the chat. Thank you.
Reply
#2

pawn Код:
CMD:clearchat(playerid, params[])
{
 for(new i=0; i<100; i++)
        {
        SendClientMessage(playerid,COLOR_RED, "");
        }
}
Reply
#3

pawn Код:
CMD:clearchat(playerid, params[])
{
    //if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][Admin] < 1) return SendClientMessage(playerid, 0xFF0000FF, "Only admins can use this command."); //Optional, replace PlayerInfo[playerid][Admin] with your own variable if you intend to use.
    for(new i = 0; i < 100; i++)
    {
        SendClientMessageToAll(playerid,0xFF0000FF, " ");
    }
    return 1;
}
1: You want the chat to be cleared for everyone, not just the player who types /clearchat, therefore use SendClientMessageToAll instead.
2: You may want to check for admin status, optional, but just in case.
3: COLOR_RED may come up as undefined if you are 'assuming' they have the same definitions.
Reply
#4

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
pawn Код:
CMD:clearchat(playerid, params[])
{
 for(new i=0; i<100; i++)
        {
        SendClientMessage(playerid,COLOR_RED, "");
        }
}
It gives me errors, can you do it with the regular /command
Reply
#5

Do you mean using STRCMP? OnPlayerCommandText? If yes, here ya go.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/clearchat", cmdtext, true, 10) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                SendClientMessageToAll(-1, "");
            }
        }
        else SendClientMessage(playerid, -1, "You are not authorized to use this command !");
        return 1;
    }
    return 0;
}
Reply
#6

Quote:
Originally Posted by JustinAn
Посмотреть сообщение
Do you mean using STRCMP? OnPlayerCommandText? If yes, here ya go.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/clearchat", cmdtext, true, 10) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                SendClientMessageToAll(-1, "");
            }
        }
        else SendClientMessage(playerid, -1, "You are not authorized to use this command !");
        return 1;
    }
    return 0;
}
THANK YOUUUU!!

+REP
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)