Question
#1

Hello,
Can someone help me with one thing? Is there way to send different messages? I mean one message to playerid and other to other players. E.g: For playerid - "You are jailed for 5 minutes. Reason: Unknown.", and for the other players - "[playername] is jailed for 5 minutes. Reason: Unknown."

If anyone have script or something like this, share it please. I need one.

Thanks,
BGEdition
Reply
#2

Hello!

Do you mean this?
PHP код:
SendClientMessage(playerid,-1,"You are jailed for 5 minutes. Reason: Unknown.");//for one player
//for all players
new string[145],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof name);
format(string,sizeof string,"%s is jailed for 5 minutes. Reason: Unknown.",name);
SendClientMessageToAll(-1,string); 
Reply
#3

the second code is sending message to all players right? I want to send it to all players exept playerid.
Reply
#4

Ok, then write it so:
PHP код:
new string[145],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof name);
format(string,sizeof string,"%s is jailed for 5 minutes. Reason: Unknown.",name);
for(new 
i;i<MAX_PLAYERS;i++)
{
    if(
== playerid)continue;
    
SendClientMessage(i,-1,string);

Reply
#5

PHP код:
new playerIDplayerName[MAX_PLAYER_NAME], reason[64], string[128];
GetPlayerName(playerIDplayerNamesizeof(playerName));
format(stringsizeof(string), "%s is jailed for 5 minutes. Reason : %s"playerNamereason);
SendClientMessageToAll(yourcolorherestring);
//Do the same for  "You are jailed for 5 minutes", only except SendClientMessageToAll use 
//SendClientMessage(playerID, yourcolorhere, string); 
Reply
#6

Quote:
Originally Posted by bgedition
Посмотреть сообщение
the second code is sending message to all players right? I want to send it to all players exept playerid.
Oh alright then, a bit too late, do what Mencent wrote then
Reply
#7

pawn Код:
CMD:jail(playerid, params[]) {
    new name[MAX_PLAYER_NAME], string[143];
    format(string,sizeof string,"%s is jailed for 5 minutes. Reason: Unknown.",name);
    for(new i;i<MAX_PLAYERS;i++) {
        if(i == playerid)return SendClientMessage(playerid, -1, "You are jailed for 5 minutes. Reason: Unknown.");
        SendClientMessage(i,-1,string);
    }
    return 1;
}
I think now is ok, or is not? What are you say?
thanks
Reply
#8

Don't use return in a loop because it will stop and the rest of the players won't see any message.
Reply
#9

Ok I understand. How is now?

pawn Код:
CMD:jail(playerid, params[]) {
    new name[MAX_PLAYER_NAME], string[143];
    format(string,sizeof string,"%s is jailed for 5 minutes. Reason: Unknown.",name);
    for(new i;i<MAX_PLAYERS;i++) {
        if(i == playerid)continue;
        SendClientMessage(i,-1,string);
    }
        SendClientMessage(playerid, -1, "You are jailed for 5 minutes. Reason: Unknown.");
    return 1;
}
Reply
#10

You need to get the player's name, also returning in a loop is not so much recommended because itll stop it.

Код:
CMD:jail(playerid, params[]) 
{
	new 
		name[MAX_PLAYER_NAME], 
		string[45 + MAX_PLAYER_NAME]
	;

	GetPlayerName(playerid, name, MAX_PLAYER_NAME);

	SendClientMessage(playerid, -1, "You are jailed for 5 minutes. Reason: Unknown."); 

	format(string, sizeof (string), "%s is jailed for 5 minutes. Reason: Unknown.", name); 

	for(new i; i != MAX_PLAYERS; i++) 
	{ 
		if (!IsPlayerConnected(playerid))
			continue;

		if (i == playerid)
			continue;
			
		SendClientMessage(i, -1, string); 
	} 

	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)