/flush command
#1

Hello !
How can i make a command like /clearchat but /flush...When the player type /flush chat cleared but only at him not at all....
I have a roleplay server and i need /flush..
Reply
#2

This is the second post I have seen of you just asking for code. That is sad because I have not even been back for 48 hours yet! Here is everything you need for this flush command (outside of OnPlayerCommandText / command processing--I assume you have THAT much down):

https://sampwiki.blast.hk/wiki/Control_S...res#for_.28.29
https://sampwiki.blast.hk/wiki/SendClientMessage

It would be a whole lot easier, and faster for you if you just read all the documentation / resources available to you, so you can learn at least the basics.

https://sampwiki.blast.hk/wiki/Scripting_Basics
Reply
#3

I tryed to make one,but when i type /flush chat is clearead at all players...
Reply
#4

Then show us, how much effort you just gave to solve this problem, and we might be able to help you in return.
Reply
#5

Quote:
Originally Posted by OnY
Посмотреть сообщение
I tryed to make one,but when i type /flush chat is clearead at all players...
Make sure you are using SendClientMessage and not the SendClientMessageToAll function. If you are using SendClientMessage, then you must be iterating through all players and sending the message to them all anyways (looping)?

Post your code.
Reply
#6

Eh...I don`t know if this is so good but :

Код:
        if(strcmp(cmd, "/flush", true) == 0)
        {
               if(IsPlayerConnected(playerid))
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            ClearChatbox(i, 100);
	}
	return 1;
   }
Reply
#7

Quote:
Originally Posted by Kyosaur
Посмотреть сообщение
Make sure you are using SendClientMessage and not the SendClientMessageToAll function. If you are using SendClientMessage, then you must be iterating through all players and sending the message to them all anyways (looping)?

Post your code.
Ohh..like that ?
Код:
  	if (strcmp("/flush", cmdtext, true, 5) == 0)
	{
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		SendClientMessage(playerid, COLOR_WHITE, " ");
		return 1
	}
Reply
#8

pawn Код:
// Putting this at top
#define Clear(%0)   for(new xz = 0; xz < 100; xz++) SendClientMessage(%0, -1, " ")

if (strcmp("/flush", cmdtext, true, 5) == 0)
{
    Clear(playerid);
    return true;
}

// ZCMD is recommended - strcmp is slow.
CMD:flush(playerid)
{
      Clear(playerid);
      return true;
}
Reply
#9

Thank`s very much..But,SendClientMessage is not good ?
Anyway,thank`s to all !
T/C
Reply
#10

Quote:
Originally Posted by OnY
Посмотреть сообщение
Eh...I don`t know if this is so good but :

Код:
        if(strcmp(cmd, "/flush", true) == 0)
        {
               if(IsPlayerConnected(playerid))
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            ClearChatbox(i, 100);
	}
	return 1;
   }
You do not need the connection check, because the player typed the command :P. You also do not need the player loop (you only want it for the single player that typed the command, afterall). If ClearChatbox works (not sure what the second parameter is, but I'll give you the benefit of the doubt and assume its the number of messages) then it would just be ClearChatbox(player, 100);

Quote:
Originally Posted by iZN
Посмотреть сообщение
pawn Код:
// Putting this at top
#define Clear(%0)   for(new xz = 0; xz < 100; xz++) SendClientMessage(%0, -1, " ")

if (strcmp("/flush", cmdtext, true, 5) == 0)
{
    Clear(playerid);
    return true;
}

// ZCMD is recommended - strcmp is slow.
CMD:flush(playerid)
{
      Clear(playerid);
      return true;
}
Did you really need a macro for that lol xD? If it works, it works I guess aha.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)