Raised This Month: $32 Target: $400
 8% 

Online Players >=


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LifeStone
Member
Join Date: Oct 2015
Old 03-24-2017 , 06:08   Online Players >=
Reply With Quote #1

Hello i want to make my plugin to work when is 5 or more players online and not only the alives what i cant write ?

Last edited by LifeStone; 03-25-2017 at 13:18.
LifeStone is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-24-2017 , 06:54   Re: Online Players >=
Reply With Quote #2

You can use get_playersnum()
klippy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 03-24-2017 , 07:30   Re: Online Players >=
Reply With Quote #3

Or.. try that:

PHP Code:
if (get_alive_players() >= 5) {
   
// your code...l
}

get_alive_players()
{
   static 
aliveid;
   
alive 0;

   for (
id 1id <= get_maxplayers(); id++) {
        if (
is_user_alive(id))
            
alive++;
}

return 
alive;

__________________








CrazY. is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-24-2017 , 07:35   Re: Online Players >=
Reply With Quote #4

CrazY, they never asked for the number of alive players. Please read thoroughly before posting.

Also, as a side note, there's no reason to use static modifier as you assign values to these variables before using them anyway.
klippy is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-24-2017 , 09:06   Re: Online Players >=
Reply With Quote #5

And there's definitely no need to loop through all players.

PHP Code:
new iPlayers[32], iPnum
get_players
(iPlayersiPnum"a")

// iPnum is the number of alive players. 
__________________

Last edited by OciXCrom; 03-24-2017 at 14:48.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-24-2017 , 09:33   Re: Online Players >=
Reply With Quote #6

Quote:
Originally Posted by OciXCrom View Post
And there's definitely no need to loop through all players.

PHP Code:
new iPlayers[32], iPnum
get_players
(iPlayersiPnum)

// iPnum is the number of alive players. 
iPnum is the number of connected players
PHP Code:
new iPlayers[32], iPnum
get_players
(iPlayersiPnum"a"// now iPnum is equal to all the alive players.. 
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 03-24-2017 , 10:30   Re: Online Players >=
Reply With Quote #7

O.o

Yes sir.

And to get a random player ?
__________________









Last edited by CrazY.; 03-24-2017 at 10:32.
CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-24-2017 , 11:00   Re: Online Players >=
Reply With Quote #8

PHP Code:
new players[32], pnum;
get_players(playerspnum"a");

if(!
pnum) return;

new 
random_chosen_id players[random(pnum-1)]

// random_chosen_id  var is the player id whom chosen randomly.. 
already been made just search..
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-24-2017 at 16:32.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 03-24-2017 , 13:22   Re: Online Players >=
Reply With Quote #9

Do not need the -1 Natsheh.

@LifeStone,

Use the native that KliPPy said.

PHP Code:
if(get_playersnum() >= 5)
{
     
// bla bla

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-24-2017 , 14:02   Re: Online Players >=
Reply With Quote #10

Quote:
Originally Posted by EFFx View Post
Do not need the -1 Natsheh.

@LifeStone,

Use the native that KliPPy said.

PHP Code:
if(get_playersnum() >= 5)
{
     
// bla bla

Again that post was an answer for @CrazY. Question!
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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

Forum Jump


All times are GMT -4. The time now is 05:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode