AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   map check (https://forums.alliedmods.net/showthread.php?t=213801)

GhostMan 04-19-2013 03:53

map check
 
I have a small plugin which changes to 'default' map if there no players found in server.

I would like to hear some improvements for this plugin. I'm thinking of changing mp_timelimit to 0 when map is default and no players found and change it back to 35 when somebody connects. But the problem is that if nobody connects to server for more than 35mins after connection server will instantly change the map. What alternatives could i do becouse of that?

PHP Code:

#include <amxmodx>
     
new nCvar_TimesnCvar_MapnMaps
     
public plugin_init()
{
    
register_plugin("Map check""1.1""None")
       
    
nCvar_Times register_cvar("nmap_check_time""3")
    
nCvar_Map register_cvar("nmap_check_map""de_dust2_2x2")

    new 
mapname[32
    
get_mapname(mapname,31)

    if(
equali(mapname"de_dust2_2x2"))
    {
        return 
PLUGIN_HANDLED
    
}
    else
    {
        
set_task(60.0"nice_map_check"___"b")
    }
    return 
PLUGIN_CONTINUE
}
     
public 
nice_map_check()
{
    new 
nMap[40], nPlayers get_playersnum()
       
    
get_pcvar_string(nCvar_MapnMapcharsmax(nMap))
       
    if(
nPlayers == 0)
    {
        
nMaps++
           
        if(
nMaps == get_pcvar_num(nCvar_Times))
        {
            
server_cmd("changelevel %s"nMap)
        }
    }



^SmileY 04-19-2013 09:55

Re: map check
 
Check in client_disconnect(id) only.

Try this: (Not tested)

PHP Code:

#include <amxmodx>

new p_Map;

public 
plugin_init()
{
    
register_plugin("Changelevel",AMXX_VERSION_STR,"SmileY");
    
    
p_Map register_cvar("amx_default_map","de_dust2");
}

public 
client_disconnect(id)
{
    new 
iPlayers get_playersnum(1); // Check if any player its connecting to server

    
new szMap[32];
    
get_pcvar_string(p_Map,szMap,charsmax(szMap));
    
    if(
is_map_valid(szMap) && !iPlayers)
    {
        new 
szThisMap[32];
        
get_mapname(szThisMap,charsmax(szThisMap));
        
        if(!
equali(szMap,szName)) server_cmd("changelevel %s",szMap);
    }




All times are GMT -4. The time now is 10:52.

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