I found a others method for it but i would its automatic. I made on this when they are dead admin need to type bb_swap deadct on the console and it will switch. But if someone can do it automatic at last round instead of typing. (For the last round map) 6 of 6
PHP Code:
public cmdSwap(id)
{
if (access(id, SWAP))
{
new arg[32];
read_argv(1, arg, 31);
if (equal(arg, "deadct", true))
{
new hasDeadCT = false;
new player;
for (player = 1; player <= get_maxplayers(); player++)
{
if (is_user_connected(player) && cs_get_user_team(player) == CS_TEAM_CT && !is_user_alive(player))
{
// Switch the dead CT player to the terrorist team
cs_set_user_team(player, CS_TEAM_T);
// Respawn the player as a Zombie
Respawn_Zombie(player);
hasDeadCT = true;
client_print(player, print_chat, "[BaseBuilder] You have been moved to the Terrorist team for the last round.");
}
}
if (!hasDeadCT)
{
// Print msg
client_print(id, print_console, "[Swap] There are no dead players on CT!");
return PLUGIN_HANDLED;
}
// Log and print a message indicating the action
new adminname[35];
get_user_name(id, adminname, 34);
Log("[TEAM-SWAP-DEADCT] Admin: %s switched dead CT players to Terrorist team and respawned them as Zombies", adminname);
client_print(id, print_console, "[Swap] You switched all dead Builder players to Zombies.");
}
else
{
new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY);
if (!is_user_connected(player)) return PLUGIN_HANDLED;
cs_set_user_team(player, cs_get_user_team(player) == CS_TEAM_T ? CS_TEAM_CT : CS_TEAM_T);
if (cs_get_user_team(player) == CS_TEAM_T)
{
g_iszombie[player] = true;
g_ishuman[player] = false;
}
if (cs_get_user_team(player) == CS_TEAM_CT)
{
g_ishuman[player] = true;
g_iszombie[player] = false;
}
if (is_user_alive(player))
ExecuteHamB(Ham_CS_RoundRespawn, player);
// Print a message to the switched player
client_print(player, print_chat, "[BaseBuilder] You've been changed to the other team by an admin!");
new adminname[35], playername[35];
get_user_name(id, adminname, 34);
get_user_name(player, playername, 34);
Log("[TEAM-SWAP] Admin: %s swapped Player: %s", adminname, playername);
client_print(id, print_console, "[Swap] Player %s has been switched to the opposite team.", playername);
}
}
return PLUGIN_HANDLED;
}
__________________