Message to all when typed command
#1

Hello , i need a little function when a player types a cmd like /hello , i want that in chat it shows that PLayer xxx has used /hello . I now it works with sendclientmessage to all but how i can make it with the player ? Thanks
Reply
#2

use SendClientMessageToAll(-1, "message here");

this will send to all players Much better than SendClientMessage if you want it to go to ALL players.

If you want it to go to more than one person but not all players, use SendClientMessage in a loop, where the loop will go through all players and use an if statement to determine if it should send the message to them

Код:
hello(string[]) {
SendClientMessageToAll(-1,string);
}
Reply
#3

Quote:
Originally Posted by wooolly
Посмотреть сообщение
use SendClientMessageToAll(-1, "message here");

this will send to all players Much better than SendClientMessage if you want it to go to ALL players.

If you want it to go to more than one person but not all players, use SendClientMessage in a loop, where the loop will go through all players and use an if statement to determine if it should send the message to them

Код:
hello(string[]) {
SendClientMessageToAll(-1,string);
}
Thanks , but i need when a player types the Command example /hello that it show in chat for all that Player xxx has used /Hello.

thanks
Reply
#4

With player you have first to format your message:
pawn Код:
new
    message[23 + MAX_PLAYER_NAME], // We only need space for "Player " +player name " has used /hello" + end of string indicator
    playername[MAX_PLAYER_NAME + 1]
;
GetPlayerName(playerid, playername, sizeof(playername)); //You have to pass playerid to function, in most command processors it's by default passed (ZCMD/YCMD)
format(message, sizeof(message), "Player %s has used /hello", playername);
SendClientMessageToAll(0xBADA55FF, message);
Also check out format wiki documentation
Reply
#5

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
   new pName[MAX_PLAYER_NAME], string[128];
   GetPlayerName(playerid, pName, sizeof(pName));
   format(string, sizeof(string), "Player %s has used %s", pName, cmdtext);
   SendClientMessageToAll(-1, string);
   return 1;
}
Reply
#6

No one here understand what he mean
If you don't know what he want then stop shitposting.
First of all use zcmd include.
Here is code,
Код:
CMD:hello(playerid, params[])
{
SendClientMessageToAll(-1, "Player %s has used /hello",pname);
return 1;
}
Reply
#7

Quote:
Originally Posted by MohanedZzZ
Посмотреть сообщение
No one here understand what he mean
If you don't know what he want then stop shitposting.
First of all use zcmd include.
Here is code,
Код:
CMD:hello(playerid, params[])
{
SendClientMessageToAll(-1, "Player %s has used /hello",pname);
return 1;
}
mad?, he's just showing an example of "/hello" -_-
Reply
#8

here is what i try . I Put the Sendlicnetmessage to all but i get error at pname
Quote:

181) : error 017: undefined symbol "playername"
Quote:

CMD:radio(playerid)
{
HideRadioTextdraws(playerid);
TextDrawShowForPlayer(playerid,Radio[0]);
TextDrawShowForPlayer(playerid,Radio[1]);
TextDrawShowForPlayer(playerid,Radio[2]);
TextDrawShowForPlayer(playerid,Radio[3]);
Radio_viewing[playerid] =1;
SendClientMessageToAll(-1, "Player %s used /Radio",playername);
return 1;
}

Reply
#9

Check my post, you're missing a few lines
Reply
#10

Quote:
Originally Posted by ReD_HunTeR
Посмотреть сообщение
mad?, he's just showing an example of "/hello" -_-
hey yo
Some servers made this command
When player connect he type /hello
Its appear in the chat Player blah blah said hello.
Got it ?
He asked for an example and i posted it.
Eh stay with your CVT leaked script :']
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)