SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 06/06/2017, 03:09 AM   #1
TYDS
Huge Clucker
 
Join Date: Sep 2016
Posts: 270
Reputation: 5
Default help

how can i get how many player on server ?
TYDS is offline   Reply With Quote
Old 06/06/2017, 03:16 AM   #2
Toroi
Gangsta
 
Toroi's Avatar
 
Join Date: Feb 2017
Location: Venezuela
Posts: 697
Reputation: 146
Default Re: help

Kinda related

http://forum.sa-mp.com/showthread.php?t=635325
__________________
Scripting Help in a nutshell

Quote:
Originally Posted by Thanks View Post
So.. hey everyone im trying to searching at ****** how to make leaderboard with Textdraws so i find many but Not in my brain...
Toroi is offline   Reply With Quote
Old 06/06/2017, 03:18 AM   #3
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 822
Reputation: 130
Default Re: help

PHP Code:
new onlinePlayers;


public 
OnPlayerConnect(playerid)
{
    
onlinePlayers++;
    return 
1;
}

public 
OnPlayerDisconnect(playerid)
{
     
onlinePlayers--;
     return 
1;
}

CMD:players(playeridparams[])
{
    new 
string[128];
    
format(stringsizeof(string), "Online players: %d"onlinePlayers);
    
SendClientMessage(playerid, -1string);
    return 
1;

You looking for something like this?
Kane is offline   Reply With Quote
Old 06/06/2017, 03:20 AM   #4
TYDS
Huge Clucker
 
Join Date: Sep 2016
Posts: 270
Reputation: 5
Default Re: help

Quote:
Originally Posted by Arthur Kane View Post
PHP Code:
new onlinePlayers;


public 
OnPlayerConnect(playerid)
{
    
onlinePlayers++;
    return 
1;
}

public 
OnPlayerDisconnect(playerid)
{
     
onlinePlayers--;
     return 
1;
}

CMD:players(playeridparams[])
{
    new 
string[128];
    
format(stringsizeof(string), "Online players: %d"onlinePlayers);
    
SendClientMessage(playerid, -1string);
    return 
1;

You looking for something like this?
yes but it's better if it a function to getplayeronserver
TYDS is offline   Reply With Quote
Old 06/06/2017, 03:27 AM   #5
Beckett
High-roller
 
Beckett's Avatar
 
Join Date: Feb 2012
Location: www.finalnights-rp.com
Posts: 1,794
Reputation: 104
Default Re: help

Code:
GetOnlinePlayers()
{
	new player;
	for(new i = 0; i <= GetPlayerPoolSize(); i++)
	{
	    if(IsPlayerConnected(i)) player++;
	}
	return player;
}

CMD:playersonline(playerid, params[])
{
    new string[22];
    format(string, sizeof(string), "Online players: %d", GetOnlinePlayers());
    SendClientMessage(playerid, -1, string);
    return 1;
}
Beckett is offline   Reply With Quote
Old 06/06/2017, 03:30 AM   #6
TYDS
Huge Clucker
 
Join Date: Sep 2016
Posts: 270
Reputation: 5
Default Re: help

Quote:
Originally Posted by DaniceMcHarley View Post
Code:
GetOnlinePlayers()
{
	new player;
	for(new i = 0; i <= GetPlayerPoolSize(); i++)
	{
	    if(IsPlayerConnected(i)) player++;
	}
	return player;
}

CMD:playersonline(playerid, params[])
{
    new string[30];
    format(string, sizeof(string), "Online players: %d", GetOnlinePlayers());
    SendClientMessage(playerid, -1, string);
    return 1;
}
thank you
TYDS is offline   Reply With Quote
Old 06/06/2017, 03:36 AM   #7
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 822
Reputation: 130
Default Re: help

Why not just press tab?!
Kane is offline   Reply With Quote
Old 06/06/2017, 03:38 AM   #8
TYDS
Huge Clucker
 
Join Date: Sep 2016
Posts: 270
Reputation: 5
Default Re: help

Quote:
Originally Posted by Arthur Kane View Post
Why not just press tab?!
just use for my system =]]z
TYDS is offline   Reply With Quote
Old 06/06/2017, 03:42 AM   #9
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,945
Reputation: 504
Default Re: help

if you using foreach then you can use Iter_Count(Player) to get total number of players connected
SyS is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 09:46 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.