Portal SAMP
[Ajuda] quantidade de membros online - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] quantidade de membros online (/showthread.php?tid=3460)



quantidade de membros online - gabrielbgxx - 22/03/2023

como posso fazer para aparecer a quantidade de membros online e o limite ex:0/100
em textdraw em algum canto


RE: quantidade de membros online - Carlos Victor - 23/03/2023

Código PHP:
CMD:online(playerid)
{
    static
        
string[128];

    
format(stringsizeof(string), "Jogadores conectados %d/%d"ReturnPlayerOnServer(), MAX_PLAYERS);
    
SendClientMessage(playerid, -1string);
    return 
1;
}

ReturnPlayerOnServer()
{
    static
        
i,
        
j,
        
players;

    for(
0GetPlayerPoolSize(); <= ji++)
    {
        if(
IsPlayerConnected(i))
            
players++;
    }
    return 
players;


Isso que você quer?


RE: quantidade de membros online - White_Blue - 24/03/2023

Basta fazer uma textdraw e usar a função PlayerTextDrawSetString.

Exemplo usando foreach:
Código PHP:
new string[128];

stock GetPlayersOnline() {
   
Iter_Count(Player);
   return 
1;
}


public 
OnPlayerConnect(playerid) {
     foreach(
Playeri) {
     
format(stringsizeof(string), "%d"GetPlayersOnline());
     
PlayerTextDrawSetString(istringsua_textdraw); // Troque sua_textdraw pela a variável que armazena sua textdraw.
     
}
     return 
1;




RE: quantidade de membros online - pushline - 24/03/2023

(23/03/2023 19:10)Carlos Victor Escreveu:
Código PHP:
CMD:online(playerid)
{
    static
        
string[128];

    
format(stringsizeof(string), "Jogadores conectados %d/%d"ReturnPlayerOnServer(), MAX_PLAYERS);
    
SendClientMessage(playerid, -1string);
    return 
1;
}

ReturnPlayerOnServer()
{
    static
        
i,
        
j,
        
players;

    for(
0GetPlayerPoolSize(); <= ji++)
    {
        if(
IsPlayerConnected(i))
            
players++;
    }
    return 
players;


Isso que você quer?

no SA:MP esta função (GetPlayerPoolSize) está quebrada e retornará 0 mesmo quando não houver jogadores. fixes.inc e open.mp corrigem isso para retornar -1.

Use o Iter_Count ou um foreach(new i : Player) do y_iterate/y_foreach.