/clearchat command - 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: /clearchat command (
/showthread.php?tid=406344)
/clearchat command -
RiChArD_A - 10.01.2013
How do I make the /clearchat command to delete the chat. Thank you.
Re: /clearchat command -
Glad2BeHere - 10.01.2013
pawn Код:
CMD:clearchat(playerid, params[])
{
for(new i=0; i<100; i++)
{
SendClientMessage(playerid,COLOR_RED, "");
}
}
Re: /clearchat command -
Threshold - 10.01.2013
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.
Respuesta: Re: /clearchat command -
RiChArD_A - 10.01.2013
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
Re: /clearchat command -
JustinAn - 10.01.2013
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;
}
Respuesta: Re: /clearchat command -
RiChArD_A - 10.01.2013
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!!
![Wink](images/smilies/wink.png)
+REP