Raised This Month: $ Target: $400
 0% 

[HELP] if server is empty


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xlenonz
Member
Join Date: Jun 2007
Old 01-19-2009 , 10:44   [HELP] if server is empty
Reply With Quote #1

hi,

i write small plugin but im not good that

if server is empty , change server mp_timelimit to 0.
if any user is connect or on game mp_timelimit to 40.
after if there no player on game change mp_timelimit to 0.

i write thats but , if player connect then , disconnect dont change mp_timelimit to 0

PHP Code:
#include <amxmodx>

public plugin_init()
{
   
set_task(1.0,"MyFunction"
}

public 
MyFunction()
{
server_cmd("mp_timelimit 0")
}

public 
client_putinserver(id)
{
  
server_cmd("mp_timelimit 40")
}  

public 
oyuncuvarmi()
{
new 
playernum get_playersnum()
if (
playernum 0)
{
server_cmd("mp_timelimit 40")
}
else
{
server_cmd("mp_timelimit 0")
}
set_task(30.0,"oyuncuvarmi")
return 
PLUGIN_CONTINUE

xlenonz is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-19-2009 , 11:46   Re: [HELP] if server is empty
Reply With Quote #2

PHP Code:
#include <amxmodx>

public plugin_init() {
    
set_task(1.0"CheckPlayers"_,_,_"b");
}

public 
CheckPlayers() {
    new 
g_iPlayers get_playersnum();
    
    if( 
g_iPlayers == )
        
server_cmd("mp_timelimit 0");
    else
        
server_cmd("mp_timelimit 40");
    
    return 
PLUGIN_CONTINUE;

but i dont reccomend to use this.
__________________
xPaw is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-19-2009 , 12:27   Re: [HELP] if server is empty
Reply With Quote #3

Code:
#include <amxmodx> #include <amxmisc> new g_player_count; new mp_timelimit; public plugin_init() {     register_plugin("Plugin Name", "0.1", "Exolent");         register_event("TeamInfo", "EventPlayerLeave", "a", "2=UNASSIGNED");         mp_timelimit = get_cvar_pointer("mp_timelimit"); } public client_putinserver(client) {     if( ++g_player_count == 1 )     {         set_pcvar_num(mp_timelimit, 40);     } } public EventPlayerLeave() {     if( --g_player_count == 0 )     {         set_pcvar_num(mp_timelimit, 0);     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 01-19-2009 at 12:34.
Exolent[jNr] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-19-2009 , 12:32   Re: [HELP] if server is empty
Reply With Quote #4

client_disconnect can be triggered before the player has enter the server, you should use get_playersnum (<- seems to return 1 when last player has left, just check it twice ;) )
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-19-2009 , 12:34   Re: [HELP] if server is empty
Reply With Quote #5

When I wrote "Team Join Management", I found out a few things about TeamInfo event.
Such as, when the "team" parameter is "UNASSIGNED", the player has left.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-19-2009 , 16:22   Re: [HELP] if server is empty
Reply With Quote #6

Quote:
Originally Posted by Exolent[jNr] View Post
When I wrote "Team Join Management", I found out a few things about TeamInfo event.
Such as, when the "team" parameter is "UNASSIGNED", the player has left.
But the message is not fired everytime, i'm sure you know the bug when a player is connecting and he already appears in scores as a T or a CT.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
xlenonz
Member
Join Date: Jun 2007
Old 01-19-2009 , 15:23   Re: [HELP] if server is empty
Reply With Quote #7

Quote:
Originally Posted by xPaw View Post
PHP Code:
#include <amxmodx>

public plugin_init() {
    
set_task(1.0"CheckPlayers"_,_,_"b");
}

public 
CheckPlayers() {
    new 
g_iPlayers get_playersnum();
    
    if( 
g_iPlayers == )
        
server_cmd("mp_timelimit 0");
    else
        
server_cmd("mp_timelimit 40");
    
    return 
PLUGIN_CONTINUE;

but i dont reccomend to use this.
thats work thanks, and Exolent[jNr]
xlenonz is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 01-19-2009 , 15:56   Re: [HELP] if server is empty
Reply With Quote #8

Just some little notes:

@xPaw: LoL, I like the fact that you used g_iPlayers when it's not even a global variable...

@xlenonz: I think you should use Exolent's way(no offense to xPaw), as xPaw's way is very CPU demanding.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 01-19-2009 at 18:28.
Dores is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-20-2009 , 07:04   Re: [HELP] if server is empty
Reply With Quote #9

Quote:
Originally Posted by Dores View Post
as xPaw's way is very CPU demanding.
i told him to dont use, i just fixed his way
__________________
xPaw is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 01-20-2009 , 10:26   Re: [HELP] if server is empty
Reply With Quote #10

Quote:
Originally Posted by xPaw View Post
i told him to dont use, i just fixed his way
You told him not to use, I told him why.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Reply



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 01:41.


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