Team Switch – Modification

Статус
Закрыто для дальнейших ответов.

CSLover

Участник
Сообщения
60
Реакции
5
Помог
2 раз(а)
Баллы
8
Ошибка
doesn’t swap the team scores
AMX Mod X
AMX Mod X 1.9.0.5294 (http://www.amxmodx.org)
Authors:
David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Dec 3 2021 15:54:56
Built from: https://github.com/alliedmodders/amxmodx/commit/363871a
Build ID: 5294:363871a
Core mode: JIT+ASM32
Билд сервера
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.14.0.857-dev
Build date: 19:52:21 Mar 27 2025 (4002)
ReGameDLL
ReGameDLL version: 5.28.0.756-dev
Build date: 19:19:31 Mar 27 2025
Metamod версия
Metamod-r v1.3.0.149, API (5:13)

Metamod-r build: 11
Metamod плагины
[ 1] Reunion             RUN   -    reunion_new_mm_i386.so         v0.2.0.34        ini  Start Never
[ 2] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5294 ini Start ANY
[ 3] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC5 ini ANY ANY
[ 4] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 5] ReSRDetector RUN - resrdetector_mm_i386.so v0.1.0 ini Chlvl ANY
[ 6] WHBlocker RUN - whblocker_mm_i386.so v1.5.697 ini Chlvl ANY
[ 7] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 8] SafeNameAndChat RUN - SafeNameAndChat.so v1.2 Beta 3 ini ANY ANY
[ 9] HitBox Fix RUN - hitbox_fix_mm_i386.so v2.0.3 ini Start ANY
[10] Backtrack Detector RUN - backtrack_detector_mm_i386.so v1.0.1 ini Start Never
[11] Accuracy Fix RUN - accuracyfix_mm.so v1.1.17 ini ANY ANY
[12] Rechecker RUN - rechecker_mm_i386.so v2.7 ini Chlvl ANY
[13] MySQL RUN - mysql_amxx_i386.so v1.9.0.5294 pl2 ANY ANY
[14] ReAPI RUN - reapi_amxx_i386.so v5.26.0.338-dev pl2 ANY Never
[15] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5294 pl2 ANY ANY
[16] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5294 pl2 ANY ANY
[17] CSX RUN - csx_amxx_i386.so v1.9.0.5294 pl2 ANY ANY
[18] Engine RUN - engine_amxx_i386.so v1.9.0.5294 pl2 ANY ANY
[19] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5294 pl2 ANY ANY
[20] hackdetector RUN - hackdetector_amxx_i386.so v0.15.328.lite pl2 ANY ANY
[21] Amxx Easy Http RUN - easy_http_amxx_i386.so v1.4.0 pl2 ANY ANY
[22] Fun RUN - fun_amxx_i386.so v1.9.0.5294 pl2 ANY ANY
Список плагинов
[ 1] Admin Base 1.9.0.5294 AMXX Dev Team admin.amxx running

[ 2] Admin Commands 1.9.0.5294 AMXX Dev Team admincmd.amxx running

[ 3] Slots Reservation 1.9.0.5294 AMXX Dev Team adminslots.amxx running

[ 4] Menus Front-End 1.9.0.5294 AMXX Dev Team menufront.amxx running

[ 5] Maps Menu 1.9.0.5294 AMXX Dev Team mapsmenu.amxx running

[ 6] Plugin Menu 1.9.0.5294 AMXX Dev Team pluginmenu.amxx running

[ 7] Chat Logger 2.1a Jim chat_logger.amx running

[ 8] Anti Flood 1.9.0.5294 AMXX Dev Team antiflood.amxx running

[ 9] Admin Votes 1.9.0.5294 AMXX Dev Team adminvote.amxx running

[ 10] Pause Plugins 1.9.0.5294 AMXX Dev Team pausecfg.amxx running

[ 11] StatsX 1.9.0.5294 AMXX Dev Team statsx.amxx running

[ 12] Hide / cmds 1.2 Dev-CS.ru hide_slash.amxx running

[ 13] Lite Admin ESP 1.0 neygomon admin_esp.amxx running

[ 14] HackDetector 0.15.lite Lev @ AGHL.RU De hackdetector.am running

[ 15] Unreal Aim Blocker 2.21 karaulov aim_blocker.amx running

[ 16] Unreal Cheater Cry 1.7 Karaulov unreal_cheater_ running

[ 17] HPP_BLOCK 1.2 Karaulov hpp_blocker.amx running

[ 18] AirSpeedLimit 1.0 Kova seb_korlat_350_ running

[ 19] [ReAPI] Anti overflow 3.1 mazdan & Inline, antir.amxx running

[ 20] Anti steamid changer 1.0.5 ufame anti_steamidcha running

[ 21] Easy KBChecker 2.1.1 bristol easy_kbchecker. running

[ 22] SF Warn Menu 0.1.4g serfreeman1337 sf_admin_warns. running

[ 23] ProxySnort 1.8.7 SPiNX proxysnort_Siko running

[ 24] Telegram Reports Sende 3.0.1 @pywave & Albert telegram_report running

[ 25] Safe Userinfo 1.0.4 the_hunter safe_userinfo.a running

[ 26] Turul Weapon Menu 1.4 mforce turul_weapon_me running

[ 27] Instant AutoTeamBalanc 1.2.0 ConnorMcLeod instant_autotea running

[ 28] Galileo v5.9.1-926 Brad Jones/Addon galileo.amxx running

[ 29] AFK Bomb Transfer (Sil 0.4-silent VEN / Modified b c4_transfer_tur running

[ 30] Crosshair Menu 1.2.6 KriTo & PurposeL crosshair_menu. running

[ 31] Turull 1.0.0 ConnorMcLeod reload_speed.am running

[ 32] CS AFK Manager 1.0.6 (amx Freeman afk_manager.amx running

[ 33] Icon Color 1.0 AcE icon_color.amxx running

[ 34] Anti Flashbang Bug 1.1.1 Numb / ConnorMcL no_team_flash.a running

[ 35] Spectator Bot 1.2.2(bata b0t. SpectatorBot.am running

[ 36] Save score & money 1.3.7 Minni Mouse Save_Score_and_ running

[ 37] Resetscore System 1.1 OciXCrom crx_resetscore. running

[ 38] Colored Flashbangs 1.0 v3x colored_flashba running

[ 39] Awp Crohssair 1.1b Hip_hop_x awp_crosshair.a running

[ 40] Custom skies 0.0.1 Nordic Warrior CustomSkies.amx running

[ 41] Advanced Bullet Damage 1.1 Sn!ff3r + MOD sebzes_kijelzes running

[ 42] Advanced Kill Assists 1.6 Xelson next21_kill_ass running

[ 43] Admin Commands Log 1.1 w0w admin_commands_ running

[ 44] MultiJump 1.1 twistedeuphoria multijump.amxx running

[ 45] BombSite Lock 0.3 bugsy bombsite_lock.a running

[ 46] [ReAPI] Info Killer 1.1.0 Jumper Info_Killer.amx running

[ 47] BackWeapon 3 0.0.6 ConnorMcLeod backweapons3.am running

[ 48] C4 Crosshair Delete 1.0 Subb98 c4_crosshair_de running

[ 49] Game Messages & Sounds 3.0.2 OciXCrom crx_gamemessage running

[ 50] Custom Flashlight 0.5.4 ConnorMcLeod CustomFlashLigh running

[ 51] Show Weapon in scenari 0.1 b0t. ShowWeaponInSce running

[ 52] Grenade Animation 3rd 1.0 Prefers to be An grenade_animati running

[ 53] cfg_hse 1.0 mut2nt headshot_effect running

[ 54] [ReAPI] Pop Grenades 2.5 EFFx & HamletEag csgo_pop_grenad running

[ 55] Connect Announce 0.3b v3x connect_announc running

[ 56] Free Defuser KIT 2.0.0 tuty FreeDefuserkit. running

[ 57] GoSpec 1.2 OciXCrom crx_gospec.amxx running

[ 58] Simple Menu 2.1.2 OciXCrom crx_simplemenu. running

[ 59] unknown unknown unknown bombplant_siten running

[ 60] Free BPammo Weapons 0.0.1 Vaqtincha FreeBPammoWeapo running

[ 61] ReloadSoundFix 1.1 Karaulov reloadsound_fix running

[ 62] BOMB REAL TIMER 6.0 Vaqtincha | Flym bomb_real_timer running

[ 63] Bomb Effect Defuse 1.0 MayroN bomb_effect_def running

[ 64] Different C4 sound per 1.0.1-25w0 szGabu c4_sound_site4. running

[ 65] No Name Change 2.1 OciXCrom crx_nonamechang running

[ 66] Ultimate Fire in the H 2.1 OciXCrom crx_fireintheho running

[ 67] Block Radio Text 1.0 Inline block_radio_tex running

[ 68] [Resources Manager] Pr 2.0 Shadows Adi precache_list.a running
Исходный код плагина
#include amxmodx
#include amxmisc
#include cstrike
#include hamsandwich

#define MAX_PLAYERS 32
#define MAX_USER_INFO_LENGTH 256
#define TASKID 5007

#define PLUGIN "Auto-Team swap"
#define VERSION "1.1 (Safe)"
#define AUTHOR ".sρiηX҉."

#define VOTE_ACCESS ADMIN_CFG

new vote_count[2]
new counter, pfTime, pMrounds, pRestart
new bool:TERR[MAX_PLAYERS + 1], bool:AFK[MAX_PLAYERS + 1]

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_logevent("@OnRoundStart", 2, "1=Round_Start")
register_logevent("@OnRoundEnd", 2, "1=Round_End")
register_concmd("swap_vote", "cmdVote", VOTE_ACCESS, ": Vote for autoswapping teams")

pfTime = register_cvar("amx_hud_time", "5.0")
pMrounds = register_cvar("amx_max_rounds", "15")
pRestart = get_cvar_pointer("sv_restartround")

register_menucmd(register_menuid("Autoswap teams?"), (1 << 0) | (1 << 1), "voteTeamSwitch")
}

@OnRoundStart()
{
if (!get_pcvar_num(pRestart) && get_gametime() > get_pcvar_float(pfTime) * 2.0)
counter++
}

@OnRoundEnd()
{
if (get_pcvar_num(pfTime))
@hud_task()
}

@hud_task()
{
if (!get_pcvar_num(pRestart) && get_gametime() > get_pcvar_float(pfTime) * 2.0)
if (!task_exists(TASKID))
set_task(get_pcvar_float(pfTime) / 4, "@New_Hud", TASKID)
}

@New_Hud()
{
new switch_sound[64]
// HUD üzenet módosítva: középre vízszintesen, legfelül függőlegesen
set_dhudmessage(100, 255, 0, -1.0, 0.0, 1, get_pcvar_float(pfTime) / 4, get_pcvar_float(pfTime))

if (counter >= get_pcvar_num(pMrounds))
{
show_dhudmessage(0, "Swap teams")
counter = 0

for (new player = 1; player <= MAX_PLAYERS; player++)
{
// --- SAFE FILTER ---
if (!is_user_connected(player))
continue
if (is_user_hltv(player))
continue
if (is_user_bot(player) && get_user_team(player) == 3)
continue
// -------------------

AFK[player] = false

if (get_user_team(player) == 1)
TERR[player] = true
else if (get_user_team(player) == 2)
TERR[player] = false
else
{
AFK[player] = true
continue
}

// Remove VIP status if any
if (cs_get_user_vip(player))
cs_set_user_vip(player, 0, 0, 0)

// Only active players get swapped
if (!AFK[player])
{
cs_set_user_team(player, TERR[player] ? CS_TEAM_CT : CS_TEAM_T, CS_DONTCHANGE, false)

// Respawn fix for VIPs
if (cs_get_user_vip(player))
{
cs_set_user_vip(player, 0, 0, 0)
ExecuteHamB(Ham_CS_RoundRespawn, player)
set_pcvar_num(pRestart, 1)
}

new iNum = random_num(1, 5)
formatex(switch_sound, charsmax(switch_sound), "spk sound/hostage/hos%i.wav", iNum)

switch (random_num(0, 1))
{
case 0: client_cmd(player, "%s", switch_sound)
case 1: client_cmd(player, "spk ^"team switch^"")
}
}
}
}
else
{
new switch_time[16]
new bottom_line = get_pcvar_num(pMrounds) - counter
num_to_word(bottom_line, switch_time, charsmax(switch_time))
//client_cmd(0, "spk ^"%s round until switch^"", switch_time)
show_dhudmessage(0, " %i ", bottom_line)
}
}

public cmdVote(id, level, cid)
{
if (!cmd_access(id, level, cid, 1) || task_exists(3517))
return PLUGIN_HANDLED

new keys = (1 << 0 | 1 << 1)
for (new i = 0; i < 2; i++)
vote_count[i] = 0

new menu[MAX_USER_INFO_LENGTH]
new len = format(menu, charsmax(menu), "[AMX] %s Autoswap teams?^n", get_pcvar_float(pfTime) ? "Disable" : "Enable")
len += format(menu[len], charsmax(menu), "^n1. Yes")
len += format(menu[len], charsmax(menu), "^n2. No")

show_menu(0, keys, menu, 10)
set_task(10.0, "vote_results", 3517)
return PLUGIN_HANDLED
}

public voteTeamSwitch(id, key)
{
vote_count[key]++
}

public vote_results()
{
if (vote_count[0] > vote_count[1])
{
client_print(0, print_chat, "[%s %s] Voting success (yes ^"%d^") (no ^"%d^") %s is now %s",
PLUGIN, VERSION, vote_count[0], vote_count[1], PLUGIN, get_pcvar_float(pfTime) ? "disabled" : "enabled")

set_pcvar_float(pfTime, get_pcvar_float(pfTime) ? 0.0 : 5.0)
}
else
{
client_print(0, print_chat, "[%s %s] Voting failed (yes ^"%d^") (no ^"%d^")",
PLUGIN, VERSION, vote_count[0], vote_count[1])
}
}
Hi!

If possible, I’d like to ask for some help with the following plugin.

The plugin’s purpose is to automatically swap the teams after a predefined number of rounds.

However, the problem is that it doesn’t swap the team scores along with the teams.

Could someone help me fix this please?
 
Решение
@CSLover,
Код:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <reapi>

#define PLUGIN "Auto-Team swap"
#define VERSION "1.1 (Safe)"
#define AUTHOR ".sρiηX҉."

#define MAX_USER_INFO_LENGTH 256
#define TASKID 5007

#define VOTE_ACCESS ADMIN_CFG

#define rg_get_current_round() (get_member_game(m_iTotalRoundsPlayed) + 1)

new vote_count[2]
new pfTime, pMrounds, pRestart, g_TScore, g_CTScore;
new bool:TERR[MAX_PLAYERS + 1], bool:AFK[MAX_PLAYERS + 1]

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_logevent("@OnRoundStart", 2, "1=Round_Start")
    register_logevent("@OnRoundEnd", 2, "1=Round_End")
    register_concmd("swap_vote", "cmdVote", VOTE_ACCESS, ": Vote...
В конце раунда:
Код:
g_TScore = get_member_game(m_iNumTerroristWins);
g_CTScore = get_member_game(m_iNumCTWins);

При swap:
Код:
set_member_game(m_iNumTerroristWins, g_CTScore);
set_member_game(m_iNumCTWins, g_TScore);
 
@CSLover,
Код:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <reapi>

#define PLUGIN "Auto-Team swap"
#define VERSION "1.1 (Safe)"
#define AUTHOR ".sρiηX҉."

#define MAX_USER_INFO_LENGTH 256
#define TASKID 5007

#define VOTE_ACCESS ADMIN_CFG

#define rg_get_current_round() (get_member_game(m_iTotalRoundsPlayed) + 1)

new vote_count[2]
new pfTime, pMrounds, pRestart, g_TScore, g_CTScore;
new bool:TERR[MAX_PLAYERS + 1], bool:AFK[MAX_PLAYERS + 1]

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_logevent("@OnRoundStart", 2, "1=Round_Start")
    register_logevent("@OnRoundEnd", 2, "1=Round_End")
    register_concmd("swap_vote", "cmdVote", VOTE_ACCESS, ": Vote for autoswapping teams")

    pfTime = register_cvar("amx_hud_time", "5.0")
    pMrounds = register_cvar("amx_max_rounds", "15")
    pRestart = get_cvar_pointer("sv_restartround")

    register_menucmd(register_menuid("Autoswap teams?"), (1 << 0) | (1 << 1), "voteTeamSwitch")
}

@OnRoundStart()
{
    if (rg_get_current_round() >= get_pcvar_num(pMrounds))
    {
        g_TScore = get_member_game(m_iNumTerroristWins);
        g_CTScore = get_member_game(m_iNumCTWins);
    }
}

@OnRoundEnd()
{
    if (get_pcvar_num(pfTime))
        @hud_task()
}

@hud_task()
{
    if (!get_pcvar_num(pRestart) && get_gametime() > get_pcvar_float(pfTime) * 2.0)
        if (!task_exists(TASKID))
            set_task(get_pcvar_float(pfTime) / 4, "@New_Hud", TASKID)
}

@New_Hud()
{
    new switch_sound[64]
    // HUD üzenet módosítva: középre vízszintesen, legfelül függőlegesen
    set_dhudmessage(100, 255, 0, -1.0, 0.0, 1, get_pcvar_float(pfTime) / 4, get_pcvar_float(pfTime))

    if (rg_get_current_round() >= get_pcvar_num(pMrounds))
    {
        show_dhudmessage(0, "Swap teams")

        for (new player = 1; player <= MAX_PLAYERS; player++)
        {
            // --- SAFE FILTER ---
            if (!is_user_connected(player))
                continue
            if (is_user_hltv(player))
                continue
            if (is_user_bot(player) && get_user_team(player) == 3)
                continue
            // -------------------

            AFK[player] = false

            if (get_user_team(player) == 1)
                TERR[player] = true
            else if (get_user_team(player) == 2)
                TERR[player] = false
            else
            {
                AFK[player] = true
                continue
            }

            // Remove VIP status if any
            if (cs_get_user_vip(player))
                cs_set_user_vip(player, 0, 0, 0)

            // Only active players get swapped
            if (!AFK[player])
            {
                cs_set_user_team(player, TERR[player] ? CS_TEAM_CT : CS_TEAM_T, CS_DONTCHANGE, false)

                // Respawn fix for VIPs
                if (cs_get_user_vip(player))
                {
                    cs_set_user_vip(player, 0, 0, 0)
                    ExecuteHamB(Ham_CS_RoundRespawn, player)
                    set_pcvar_num(pRestart, 1)
                }

                new iNum = random_num(1, 5)
                formatex(switch_sound, charsmax(switch_sound), "spk sound/hostage/hos%i.wav", iNum)

                switch (random_num(0, 1))
                {
                    case 0: client_cmd(player, "%s", switch_sound)
                    case 1: client_cmd(player, "spk ^"team switch^"")
                }
            }
        }

        set_member_game(m_iNumTerroristWins, g_CTScore);
        set_member_game(m_iNumCTWins, g_TScore);
    }
    else
    {
        new switch_time[16]
        new bottom_line = get_pcvar_num(pMrounds) - rg_get_current_round()
        num_to_word(bottom_line, switch_time, charsmax(switch_time))
        //client_cmd(0, "spk ^"%s round until switch^"", switch_time)
        show_dhudmessage(0, " %i ", bottom_line)
    }
}

public cmdVote(id, level, cid)
{
    if (!cmd_access(id, level, cid, 1) || task_exists(3517))
        return PLUGIN_HANDLED

    new keys = (1 << 0 | 1 << 1)
    for (new i = 0; i < 2; i++)
        vote_count[i] = 0

    new menu[MAX_USER_INFO_LENGTH]
    new len = format(menu, charsmax(menu), "[AMX] %s Autoswap teams?^n", get_pcvar_float(pfTime) ? "Disable" : "Enable")
    len += format(menu[len], charsmax(menu), "^n1. Yes")
    len += format(menu[len], charsmax(menu), "^n2. No")

    show_menu(0, keys, menu, 10)
    set_task(10.0, "vote_results", 3517)
    return PLUGIN_HANDLED
}

public voteTeamSwitch(id, key)
{
    vote_count[key]++
}

public vote_results()
{
    if (vote_count[0] > vote_count[1])
    {
        client_print(0, print_chat, "[%s %s] Voting success (yes ^"%d^") (no ^"%d^") %s is now %s",
            PLUGIN, VERSION, vote_count[0], vote_count[1], PLUGIN, get_pcvar_float(pfTime) ? "disabled" : "enabled")

        set_pcvar_float(pfTime, get_pcvar_float(pfTime) ? 0.0 : 5.0)
    }
    else
    {
        client_print(0, print_chat, "[%s %s] Voting failed (yes ^"%d^") (no ^"%d^")",
            PLUGIN, VERSION, vote_count[0], vote_count[1])
    }
}
Сообщение автоматически объединено:

Test it
 
Решение
Статус
Закрыто для дальнейших ответов.

Кто просматривает тему

Назад
Верх