Problem with automatic map changer

Сообщения
15
Реакции
-1
Hello everyone, i made this plugin by bothering pieces from other plugins.
baiscally what i want the plugin to do is to check the player count and the map that are on the server and change the map if there is less/more than a certain amount of players based on the map
example: if is de_dust2x2 and more than 15 players online change map to de_dust2, if is de_dust2 and less than 15 players online change to de_dust2x2.
my problem is, the plugin change the map but enter in a loop and change it continously
Код:
#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    set_task(5.0,"check_online_count",8757,_,_,"b",0);
}

public check_online_count()
{
    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==0 && !equal(mapname, "de_dust2"))
    {
        server_cmd("amx_map de_dust2x2");
    }
    else if(count<14 && !equal(mapname, "de_mirage"))
    {
        server_cmd("amx_map de_dust2x2");
    }
    else if(count<14 && !equal(mapname, "de_train"))
    {
        server_cmd("amx_map de_dust2x2");
    }
    else if(count<14 && !equal(mapname, "de_nuke"))
    {
        server_cmd("amx_map de_dust2x2");
    }
    else if(count==1 && !equal(mapname, "de_dust2x2"))
    {
        server_cmd("amx_map de_dust2");
    }
}
 
Сообщения
15
Реакции
-1
Nordic Warrior I saw that and thank for the suggestion, but it's not kinda like i want.. i want to be like:
If less than 15 players connected change map to de_dust2x2 and timeleft 20 (optional timeleft)
If more than 15 players connected change map to de_dust2 and timeleft 20 (optional timeleft)
 
Сообщения
663
Реакции
232
Помог
11 раз(а)
try so

Код:
new mapname[32];
    get_mapname(mapname,31);
    if(count==0 && !equal(mapname, "de_dust2"))
    {
        server_cmd("amx_map de_dust2x2");
    }
    else if(count<14 && !equal(mapname, "de_mirage"))
    {
        server_cmd("amx_map de_dust2x2");
    }
    else if(count<14 && !equal(mapname, "de_train"))
    {
        server_cmd("amx_map de_dust2x2");
    }
    else if(count<14 && !equal(mapname, "de_nuke"))
    {
        server_cmd("amx_map de_dust2x2");
    }
    else if(count==1 && !equal(mapname, "de_dust2x2"))
    {
        server_cmd("amx_map de_dust2");
    }
===>
Код:
new mapname[32];
get_mapname(mapname,31);
if(count > 15 && equal(mapname, "de_dust2x2"))
{
    server_cmd("amx_map de_dust2");
}
else if(equal(mapname, "de_dust2"))
{
    server_cmd("amx_map de_dust2x2");
}


Код:
set_task delay would do more ex: 10s
 
Сообщения
15
Реакции
-1
Limbooc, thank you so much, and yes, the task will be set for like 60-120 seconds, that player count and task timer was only for testing :D
 
Сообщения
15
Реакции
-1
Limbooc, it will be even possibile to add a const to type all the maps name for the count maps to change to dust2x2 (server with less x amount of players)
And 2 cvars to set the minimum amount of players(change to dust2x2) and max amount of players(to change to large map)
 

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

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