Auto Map Changer

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
15
Реакции
-1
Hello everyone, i made this plugin, wich change the map when there is a certain amount of players on the server
Код:
#include <amxmodx>
#include <amxmisc>

#pragma compress 1

new PluginOn;
new MaxPlayers;
new MinPlayers;
new CheckTime;

static const
PLUGIN_NAME[] = "AutoMapChanger",
PLUGIN_AUTHOR[] = "scz",
PLUGIN_VERSION[] = "1.0";

public plugin_init()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
    PluginOn = register_cvar("amc_on","1");
    MinPlayers = register_cvar("amc_minpl","0");
    MaxPlayers = register_cvar("amc_maxpl","1");
    CheckTime = register_cvar("amc_check","15");
    set_task(get_pcvar_float(CheckTime),"check_online_count",8757,_,_,"b",0);
}

public check_online_count()
{
    if(!get_pcvar_num(PluginOn))
    {
        return;
    }
    
    new iPlayers[32], iNum, player,count;
    get_players(iPlayers,iNum);
    for(new i=0;i<iNum;i++)
    {
        player = iPlayers[i];
        if(is_user_connected(player) && !is_user_hltv(player))
        {
            count++;
        }
    }
    new mapname[32];
    get_mapname(mapname,31);
    if(count==get_pcvar_num(MinPlayers) && equal(mapname, "de_dust2x2"))
    {
        return;
        
    }
    else if(count==get_pcvar_num(MinPlayers))
    {
        server_cmd("amx_map de_dust2x2");
        server_cmd("amx_cvar mp_timeleft 0");
        server_cmd("amx_cvar mp_timelimit 0");
        
    }
    else if(count==get_pcvar_num(MaxPlayers) && equal(mapname, "de_dust2x2"))
    {
        server_cmd("amx_map de_dust2");
        server_cmd("amx_cvar mp_timeleft 20");
        server_cmd("amx_cvar mp_timelimit 21");
    }
}
And i tried to modify it to add a cvar for the maps ( Empty server map, player map) like this:
Код:
#include <amxmodx>
#include <amxmisc>

#pragma compress 1

new PluginOn;
new MaxPlayers;
new MinPlayers;
new CheckTime;
new CvarMinMap;
new MinMap[32];
new CvarMaxMap;
new MaxMap[32];

static const
PLUGIN_NAME[] = "AutoMapChanger",
PLUGIN_AUTHOR[] = "scz",
PLUGIN_VERSION[] = "1.0";

public plugin_init()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
    PluginOn = register_cvar("amc_on","1");
    MinPlayers = register_cvar("amc_minpl","0");
    MaxPlayers = register_cvar("amc_maxpl","1");
    CheckTime = register_cvar("amc_check","15");
    set_task(get_pcvar_float(CheckTime),"check_online_count",8757,_,_,"b",0);
    CvarMinMap         = register_cvar("amx_minmap", "de_dust2x2");
    get_pcvar_string(CvarMinMap, MinMap, charsmax(MinMap));
    CvarMaxMap         = register_cvar("amc_maxmap", "de_dust2");
    get_pcvar_string(CvarMaxMap, MaxMap, charsmax(MaxMap));
}

public check_online_count()
{
    if(!get_pcvar_num(PluginOn))
    {
        return;
    }
    
    new iPlayers[32], iNum, player,count;
    get_players(iPlayers,iNum);
    for(new i=0;i<iNum;i++)
    {
        player = iPlayers[i];
        if(is_user_connected(player) && !is_user_hltv(player))
        {
            count++;
        }
    }
    new mapname[32];
    get_mapname(mapname,31);
    if(count==get_pcvar_num(MinPlayers) && equal("mapname, &s",MinMap))
    {
        return;
        
    }
    else if(count==get_pcvar_num(MinPlayers))
    {
        server_cmd("amx_map %s",MinMap);
        server_cmd("amx_cvar mp_timeleft 0");
        server_cmd("amx_cvar mp_timelimit 0");
        
    }
    else if(count==get_pcvar_num(MaxPlayers) && equal("mapname, %s",MinMap))
    {
        server_cmd("amx_map %s",MaxMap);
        server_cmd("amx_cvar mp_timeleft 20");
        server_cmd("amx_cvar mp_timelimit 21");
    }
}
Basically my problem is:
If there is dust2x2 and 0 player on the server (Minplayers 0 MinMap de_dust2x2) the plugin will keep change the map to dust2x2 every CheckTime, but he should do nothing until the MaxPlayer number will be reach, then change the map to dust2 (MaxMap)
Can somebody help me?
 
Сообщения
673
Реакции
242
Помог
11 раз(а)
equal("mapname, &s",MinMap)

====>
equal(mapname, MinMap,0))

Код:
/* Checks if two strings equal. If len var is set
* then there are only c chars comapred. */
native equal(const a[],const b[],c=0);]
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу