SA-MP Forums Archive
players online - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: players online (/showthread.php?tid=126392)



players online - Sampiscool123 - 08.02.2010

hi

how do i make it so when a player connects it says they have joined then it says how many players are online

for example "Sampiscool123 has joined the server. (10 players online)"

Thanks


Re: players online - smeti - 08.02.2010

pawn Code:
public OnPlayerConnect(playerid)
{
    new
        string[144];
    format(string, sizeof string,"%s has joined the server. (%d players online)", pName(playerid), ConnectedPlayers());
    SendClientMessageToAll(0xFFFF00AA, string);
    return true;
}

stock ConnectedPlayers()
{
    new
        Connected,
        ReDefinedMaxPlayers = GetMaxPlayers();
    for(new i; i < ReDefinedMaxPlayers; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        Connected++;
    }
    return Connected;
}

stock pName(playerid)
{
    new
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof name);
    return name;
}



Re: players online - Sampiscool123 - 08.02.2010

thanks