/flush command -
OnY - 02.12.2013
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..
Re: /flush command -
Kyosaur - 02.12.2013
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
Re: /flush command -
OnY - 02.12.2013
I tryed to make one,but when i type /flush chat is clearead at all players...
AW: /flush command -
BigETI - 02.12.2013
Then show us, how much effort you just gave to solve this problem, and we might be able to help you in return.
Re: /flush command -
Kyosaur - 02.12.2013
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.
Re: /flush command -
OnY - 02.12.2013
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;
}
Re: /flush command -
OnY - 02.12.2013
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
}
Re: /flush command -
iZN - 02.12.2013
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;
}
Re: /flush command -
OnY - 02.12.2013
Thank`s very much..But,SendClientMessage is not good ?
Anyway,thank`s to all !
T/C
Re: /flush command -
Kyosaur - 02.12.2013
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.