AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Do something depends of player count (https://forums.alliedmods.net/showthread.php?t=135201)

Alucard^ 08-13-2010 17:56

Do something depends of player count
 
Well, i have a simple question. I can't test right now, for that reason i am posting here.

Code:
new g_iPlayers; public client_connect(id) {     g_iPlayers++;         DoSomething(); } public client_disconnect(id) {     g_iPlayers--;         DoSomething(); } public DoSomething() {     if(g_iPlayers > 5)     {         // some code here     }     else     {         // some code here     } }

I want to know if this method is correct or i have to add something to fix bugs, or something like that.

tm. 08-13-2010 18:19

Re: Do something depends of player count
 
I think (not sure) that client_disconnect it's not called if player disconnects before putinserver.

Alucard^ 08-13-2010 18:25

Re: Do something depends of player count
 
Ye for that reason i ask that, becouse i am not really sure and i think will have some bugs.

The only thing that i think i can use appart of that or with that, is SVC_DISCONNECT message.

fysiks 08-13-2010 18:41

Re: Do something depends of player count
 
get_players()

Alucard^ 08-13-2010 19:57

Re: Do something depends of player count
 
OHHHH, i am really stupid, i used that for an old plugin and now didn't think about it... thanks. Also i think that get_playersnum() is best in this case.

fysiks 08-13-2010 22:47

Re: Do something depends of player count
 
Quote:

Originally Posted by Alucard^ (Post 1270150)
OHHHH, i am really stupid, i used that for an old plugin and now didn't think about it... thanks. Also i think that get_playersnum() is best in this case.

Oh yeah :|. I don't use that one much. Forgot about it.

Alucard^ 08-14-2010 19:10

Re: Do something depends of player count
 
Sry didn't understand at all what you said (cuz my english is not really good).. you said to me, to forgot about get_playersnum() or get_players()?

ConnorMcLeod 08-14-2010 19:13

Re: Do something depends of player count
 
Both are fine, if you don't need the list of players, use get_playersnum(), it also provide an extra argument so you can count connecting players.

fysiks 08-14-2010 23:29

Re: Do something depends of player count
 
Quote:

Originally Posted by Alucard^ (Post 1270981)
Sry didn't understand at all what you said (cuz my english is not really good).. you said to me, to forgot about get_playersnum() or get_players()?

I said I forgot about get_playersnum() because I don't use it much if at all.

Alucard^ 08-15-2010 12:09

Re: Do something depends of player count
 
Ah ok, Thanks =p


All times are GMT -4. The time now is 21:56.

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