Raised This Month: $ Target: $400
 0% 

0 players on server


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Loupu.
Member
Join Date: Jul 2013
Old 06-08-2014 , 03:10   0 players on server
Reply With Quote #1

Hi , i want a code , when all players from server disconnect and on server are 0 players to change the map, can someone help me with this?
Loupu. is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-08-2014 , 03:53   Re: 0 players on server
Reply With Quote #2

Check if get_playersnum( ) equals 1 on client_disconnect, then change the map?
Backstabnoob is offline
Loupu.
Member
Join Date: Jul 2013
Old 06-08-2014 , 04:59   Re: 0 players on server
Reply With Quote #3

hmm.... it'l be smth like this yeap?

PHP Code:
public client_disconnect() {

    new 
PlayerCount
    
new iPlayers[32], iNum
    get_players
(iPlayers,iNum)
    for(new 
iiNumi++)
    {
        new 
tempid iPlayers[i]
        if(!
is_user_bot(tempid) && is_user_connected(tempid))
            
PlayerCount++
    }
    if(
PlayerCount == 0)
    {
        
server_cmd("amx_changelevel de_dust2");
    } 

can you check if its right?
Loupu. is offline
Old 06-08-2014, 05:03
aron9forever
This message has been deleted by aron9forever. Reason: brainfuck
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-08-2014 , 06:49   Re: 0 players on server
Reply With Quote #4

No, why are you looping through the players? get_players already gives you the amount of players which is "iNum". You can specify whether it ignore bots in the flags, look up how to use the function on Google.

Also, I said the player count should be 1. Check against if( iNum == 1 ). client_disconnect is called before get_players and get_playersnum results are updated, so it will give you 1 if the last player disconnected.
Backstabnoob 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 09:45.


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