SA-MP Forums Archive
Clearing 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: Clearing Chat (/showthread.php?tid=395099)



Clearing Chat - RevolutionLite - 25.11.2012

Hello,

I wan't a command what is RCON admin only which can clear the chat. 0.3e only please as i'm trying some and getting errors.


~Kyle_Magix


Re: Clearing Chat - Laure - 25.11.2012

Its not rcon but the command is something like this
Код:
CMD:clearchat(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
   	if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    
	for(new i=0; i<100; i++)
	{
	    SendClientMessageToAll(COLOR_WHITE, "");
	}
	format(string, sizeof(string), "Info: %s has cleared the chat window.", GetPlayerName(playerid));
	SendClientMessageToAll(COLOR_DARKRED, string);
	return 1;
}



Re: Clearing Chat - leetboi - 25.11.2012

Download admin system, its better.Why u dont make command like /cc to clean chat, noone will know for that comand ofc if you dont put it in /cmds or wherever.


Re: Clearing Chat - RenSoprano - 25.11.2012

pawn Код:
CMD:cc(playerid, params[])
{
    new string[128]; // This is the string what is lenght 128 letters
    if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "You are not authorized to use this command."); // This will check if you are rcon logged in

    for(new i=0; i<100; i++) // This will send a empty message 100 times to all players and it will clear the chat
    {
        SendClientMessageToAll(0xFFFFFFAA, "");
    }
    format(string, sizeof(string), "AdmWarning: %s has cleared the chat window.", GetPlayerName(playerid)); // This will show who cleared the chat
    SendClientMessageToAll(0xFFFF00AA, string); // This will send the message to all players
    return 1;
}
Hope I help you


Re: Clearing Chat - RevolutionLite - 25.11.2012

Quote:
Originally Posted by RenSoprano
Посмотреть сообщение
pawn Код:
CMD:cc(playerid, params[])
{
    new string[128]; // This is the string what is lenght 128 letters
    if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "You are not authorized to use this command."); // This will check if you are rcon logged in

    for(new i=0; i<100; i++) // This will send a empty message 100 times to all players and it will clear the chat
    {
        SendClientMessageToAll(0xFFFFFFAA, "");
    }
    format(string, sizeof(string), "AdmWarning: %s has cleared the chat window.", GetPlayerName(playerid)); // This will show who cleared the chat
    SendClientMessageToAll(0xFFFF00AA, string); // This will send the message to all players
    return 1;
}

Hope I help you
I put this in, And got some errors
pawn Код:
C:\Users\kyle\Desktop\Gates\Codes\Announcing.pwn(17) : error 029: invalid expression, assumed zero
C:\Users\kyle\Desktop\Gates\Codes\Announcing.pwn(17) : error 017: undefined symbol "cmd_cc"
C:\Users\kyle\Desktop\Gates\Codes\Announcing.pwn(17) : error 029: invalid expression, assumed zero
C:\Users\kyle\Desktop\Gates\Codes\Announcing.pwn(17) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.



Re: Clearing Chat - RenSoprano - 25.11.2012

Do you use ZCMD? or Strcmp, dcmd, ycmd what command processor do you use


Re: Clearing Chat - RevolutionLite - 25.11.2012

Quote:
Originally Posted by RenSoprano
Посмотреть сообщение
Do you use ZCMD? or Strcmp, dcmd, ycmd what command processor do you use
it has #include <zcmd> at the top and sscanf2 so proberly zcmd? I know how some of it works.


Re: Clearing Chat - McCarthy - 25.11.2012

Quote:
Originally Posted by RenSoprano
Посмотреть сообщение
pawn Код:
CMD:cc(playerid, params[])
{
    new string[128]; // This is the string what is lenght 128 letters
    if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "You are not authorized to use this command."); // This will check if you are rcon logged in

    for(new i=0; i<100; i++) // This will send a empty message 100 times to all players and it will clear the chat
    {
        SendClientMessageToAll(0xFFFFFFAA, "");
    }
    format(string, sizeof(string), "AdmWarning: %s has cleared the chat window.", GetPlayerName(playerid)); // This will show who cleared the chat
    SendClientMessageToAll(0xFFFF00AA, string); // This will send the message to all players
    return 1;
}
That would not work for Rcon admin but normal players. Also I'm pretty sure 100 lines arent needed, 50 will do just fine. The GetPlayerName will also not work in the format. Correct code would be:
pawn Код:
CMD:cc(playerid, params[])
{
    new string[128], Name[25]; // This is the string what is lenght 128 letters, and a variable to store the name in
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "You are not authorized to use this command."); // This will check if you are rcon logged in
    GetPlayerName(playerid, Name, sizeof(Name)); //Storing the name into the Name variable we created
    for(new i=0; i<50; i++) // This will send a empty message 50 times to all players and it will clear the chat
    {
        SendClientMessageToAll(-1, "");
    }
    format(string, sizeof(string), "AdmWarning: %s has cleared the chat window.",Name); // This will show who cleared the chat (using the name variable to show the name we got earlier)
    SendClientMessageToAll(0xFFFF00AA, string); // This will send the message to all players
    return 1;
}
Also. Are you placing the commands outside callbacks?


Re: Clearing Chat - RenSoprano - 25.11.2012

Код:
GetPlayerName(playerid, Name, sizeof(Name));
This is same like that what I made GetPlayerName(playerid) and you are right for IsPlayerAdmin


Re: Clearing Chat - RevolutionLite - 25.11.2012

Quote:
Originally Posted by McCarthy
Посмотреть сообщение
That would not work for Rcon admin but normal players. Also I'm pretty sure 100 lines arent needed, 50 will do just fine. The GetPlayerName will also not work in the format. Correct code would be:
pawn Код:
CMD:cc(playerid, params[])
{
    new string[128], Name[25]; // This is the string what is lenght 128 letters, and a variable to store the name in
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "You are not authorized to use this command."); // This will check if you are rcon logged in
    GetPlayerName(playerid, Name, sizeof(Name)); //Storing the name into the Name variable we created
    for(new i=0; i<50; i++) // This will send a empty message 50 times to all players and it will clear the chat
    {
        SendClientMessageToAll(-1, "");
    }
    format(string, sizeof(string), "AdmWarning: %s has cleared the chat window.",Name); // This will show who cleared the chat (using the name variable to show the name we got earlier)
    SendClientMessageToAll(0xFFFF00AA, string); // This will send the message to all players
    return 1;
}
Also. Are you placing the commands outside callbacks?
Thanks a lot!. REP+ added.