Clear 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: Clear Chat (
/showthread.php?tid=596468)
Clear Chat -
whatreally - 18.12.2015
hi i want clear only players chat not admins
Help = +Rep
Код:
COMMAND:clearchat(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][playerLevel] >= 3)
{
for(new i = 0; i < 50; i++)
{
SendClientMessageToAll(COLOR_WHITE," ");
}
SendClientMessageToAll(COLOR_WHITE, "{A9C4E4}An administrator has cleared the chat.");
new log[250];
format(log, sizeof(log), "%s(%i) cleared the chat", playerData[playerid][tempAdminName], playerid);
SendAdminText(playerid, log);
}
else
{
return 0;
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be logged in to use commands.");
}
return 1;
}
Re: Clear Chat -
FreAkeD - 18.12.2015
You're using a loop, therefore it will loop through
ALL players and send the message to every single player.
More on Loops:
https://sampwiki.blast.hk/wiki/Loops
Re: Clear Chat -
JaKe Elite - 18.12.2015
I have re-coded the way you clear the chat, The chat is only cleared out for players [not Admins].
Note; I am not sure if you are using foreach, So i have used a standard player looping on this code, This is a bad method. Use foreach.
PHP код:
COMMAND:clearchat(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][playerLevel] >= 3)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(playerData[i][playerLevel] == 0)
{
for(new x = 0; x < 50; x++)
{
SendClientMessage(i, COLOR_WHITE," ");
}
}
}
}
SendClientMessageToAll(COLOR_WHITE, "{A9C4E4}An administrator has cleared the chat.");
new log[250];
format(log, sizeof(log), "%s(%i) cleared the chat", playerData[playerid][tempAdminName], playerid);
SendAdminText(playerid, log);
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be logged in to use commands.");
}
return 1;
}
Re: Clear Chat -
whatreally - 18.12.2015
Thanks +rep