I would like if someone could modify my plugin as follows:
1. I want to move players only at the beginning of the round not during the game with ii now
2. I want him to check the teams every 3 rounds and balance good players according to kills, now he does it, but I hardly know how many minutes he asked them to check
1. I want to move players only at the beginning of the round not during the game with ii now
2. I want him to check the teams every 3 rounds and balance good players according to kills, now he does it, but I hardly know how many minutes he asked them to check
Код:
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <hamsandwich>
new bool:g_bShouldSwap, g_pSwapDelay, g_pRespawn
public plugin_init()
{
register_plugin("Swap Best Players", "1.1", "OciXCrom")
register_logevent("OnRoundEnd", 2, "1=Round_End")
g_pSwapDelay = register_cvar("sbp_swap_delay", "600")
g_pRespawn = register_cvar("sbp_respawn", "1")
CC_SetPrefix("&x04[SBP]")
}
public plugin_cfg()
{
set_task(get_pcvar_float(g_pSwapDelay), "time_to_swap", .flags = "b")
}
public time_to_swap()
{
if(get_pcvar_num(g_pRespawn) == 1)
{
swap_best_players(true)
}
else
{
CC_SendMessage(0, "The game will attempt to swap the best players when the &x03round ends&x01.")
g_bShouldSwap = true
}
}
public OnRoundEnd()
{
if(g_bShouldSwap)
{
swap_best_players(false)
g_bShouldSwap = false
}
}
public swap_best_players(bool:bRespawn)
{
new iPlayers[32], id[2], iPnum
get_players(iPlayers, iPnum, "e", "CT")
if(!iPnum)
{
return
}
SortCustom1D(iPlayers, iPnum, "sort_players")
id[0] = iPlayers[0]
get_players(iPlayers, iPnum, "e", "TERRORIST")
if(!iPnum)
{
return
}
SortCustom1D(iPlayers, iPnum, "sort_players")
id[1] = iPlayers[0]
cs_set_user_team(id[0], CS_TEAM_T)
cs_set_user_team(id[1], CS_TEAM_CT)
if(bRespawn)
{
ExecuteHam(Ham_CS_RoundRespawn, id[0])
ExecuteHam(Ham_CS_RoundRespawn, id[1])
}
new szName[2][32]
get_user_name(id[0], szName[0], charsmax(szName[]))
get_user_name(id[1], szName[1], charsmax(szName[]))
CC_SendMessage(0, "&x03%s &x01and &x03%s &x01have swapped teams!", szName[0], szName[1])
}
public sort_players(id1, id2)
{
if(get_user_frags(id1) > get_user_frags(id2))
{
return -1
}
else if(get_user_frags(id1) < get_user_frags(id2))
{
return 1
}
else
{
if(cs_get_user_deaths(id1) < cs_get_user_deaths(id2))
{
return -1
}
else if(cs_get_user_deaths(id1) > cs_get_user_deaths(id2))
{
return 1
}
}
CC_SendMessage(0, "Unable to swap players because &x032 or more &x01of them have the exact same score.")
return 0
}