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_Times, nCvar_Map, nMaps
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_Map, nMap, charsmax(nMap))
if(nPlayers == 0)
{
nMaps++
if(nMaps == get_pcvar_num(nCvar_Times))
{
server_cmd("changelevel %s", nMap)
}
}
}