has joined server
#1

Код:
	new name[MAX_PLAYER_NAME]; new j_msg[20 + MAX_PLAYER_NAME];
	GetPlayerName(playerid, name,sizeof (name));
	format(j_msg,sizeof (j_msg),"%s has joined server",name);
	SCMA(0x808080AA, j_msg);
hello i make this code and its work fine but i want when someone join just the other players see this message "blabla has joined server" not him
Reply
#2

Pass a loop through all players, and check whether the player is himself or not.

pawn Код:
for(new a; a < MAX_PLAYERS; ++a)
{
    if(IsPlayerConnected(a) && a != playerid) // if 'a' is connected and not playerid
        SendClientMessage(a,0x808080AA,j_msg);
}
Reply
#3

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
      if(IsPlayerConnected(i))
      {
            new str[40], strname[1+MAX_PLAYER_NAME+1];
            GetPlayerName(playerid, strname, sizeof(strname));
            format(str,sizeof(str),"[Connect]: %s Has connected to the server", strname);
            SendClientMessage(i, -1, str);
      }
}
Reply
#4

Quote:
Originally Posted by zT KiNgKoNg
Посмотреть сообщение
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
      if(IsPlayerConnected(i))
      {
            new str[40], strname[1+MAX_PLAYER_NAME+1];
            GetPlayerName(playerid, strname, sizeof(strname));
            format(str,sizeof(str),"[Connect]: %s Has connected to the server", strname);
            SendClientMessage(i, -1, str);
      }
}
that basicly is same as Send message to all
u should do a statement above it to check if index i is not equal to playerid

thats what arukta did , so his answer is appropriate
Reply
#5

Or use this function:

https://sampforum.blast.hk/showthread.php?pid=94980#pid94980
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)