AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   0 players on server (https://forums.alliedmods.net/showthread.php?t=241712)

Loupu. 06-08-2014 03:10

0 players on server
 
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?

Backstabnoob 06-08-2014 03:53

Re: 0 players on server
 
Check if get_playersnum( ) equals 1 on client_disconnect, then change the map?

Loupu. 06-08-2014 04:59

Re: 0 players on server
 
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?

Backstabnoob 06-08-2014 06:49

Re: 0 players on server
 
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.


All times are GMT -4. The time now is 09:45.

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