How to put number of player currently playing ?
#1

How to put number of player currently playing ?

Exemple : %s joined the server. currently playing (Number Of Player)

Reply
#2

pawn Код:
public OnPlayerConnect(playerid)
{
  new name[MAX_PLAYER_NAME], str[128];
  GetPlayerName(playerid, name, sizeof(name));
  format(str, sizeof(str), "%s (%d) Has joined the server", name, playerid);
  SendClientMessageToAll(0x808080FF, str);
  return 1;
}
hope it helps u

ahah, now i understand what u want.
thy this:
pawn Код:
new PlayersCount;

public OnPlayerConnect(playerid)
{
  PlayersCount++;
  new name[MAX_PLAYER_NAME], str[128];
  GetPlayerName(playerid, name, sizeof(name));
  format(str, sizeof(str), "%s (%d) Has joined the server. [Current Players: %d]", name, playerid, PlayersCount);
  SendClientMessageToAll(0x808080FF, str);
  return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  PlayersCount--;
  return 1;
}
Reply
#3

look at my filterscript (check signature)
Reply
#4

Doesn't work

I have error with PlayerCounts++
Reply
#5

Quote:
Originally Posted by Noredine
Doesn't work

I have error with PlayerCounts++
Can you give me good code please.
Reply
#6

Quote:
Originally Posted by the_chaoz
thy this:
pawn Код:
new PlayersCount;

public OnPlayerConnect(playerid)
{
  PlayersCount++;
  new name[MAX_PLAYER_NAME], str[128];
  GetPlayerName(playerid, name, sizeof(name));
  format(str, sizeof(str), "%s (%d) Has joined the server. [Current Players: %d]", name, playerid, PlayersCount);
  SendClientMessageToAll(0x808080FF, str);
  return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  PlayersCount--;
  return 1;
}
Your question was answered and the code was given to you, what's wrong?
Reply
#7

pawn Код:
new count;
for(new i;i<MAX_PLAYERS;i++)
{
    if(IsPlayerConnected(i))
      count++;
}
count will store the currently connected players.
Reply
#8

Quote:
Originally Posted by GTAIV2008
pawn Код:
new count;
for(new i;i<MAX_PLAYERS;i++)
{
    if(IsPlayerConnected(i))
      count++;
}
count will store the currently connected players.
Ok i add this where ? End of script or Top of script
Reply
#9

Add it where you want to use it
In cmds or something like that, the code above is NOT an actual function working on its own.
Reply
#10

Quote:
Originally Posted by GTAIV2008
Add it where you want to use it
In cmds or something like that, the code above is NOT an actual function working on its own.
Ok and you can give me the code current players if he leave

exemple : Guys has joined the server . [Current Players : 12]
after : Guys has leaved the server . [Current Players : 11]

U know what i need ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)