Thread: auto team swap
View Single Post
shayan123
BANNED
Join Date: Oct 2020
Location: GB
Old 01-13-2023 , 11:47   Re: auto team swap
Reply With Quote #3

Quote:
#include <amxmodx>
#include <cstrike>

new g_iSwapTime;

public plugin_init() {
register_plugin("Auto Team Swap", "1.0", "Author");

g_iSwapTime = register_cvar("amx_team_swap_time", "600");
set_task(get_pcvar_float(g_iSwapTime), "Task_SwapTeams", .flags = "b");
}

public Task_SwapTeams() {
swap_teams(); //function to swap teams
cs_reset_round_stats(); // function to reset frags
set_task(get_pcvar_float(g_iSwapTime), "Task_SwapTeams", .flags = "b");
}
This plugin uses the register_cvar() function to register a console variable, amx_team_swap_time, which allows you to set the time in seconds between team swaps. The plugin uses the set_task() function to create a task that swaps teams and resets frags every amx_team_swap_time seconds. This task calls the Task_SwapTeams() function which uses swap_teams() and cs_reset_round_stats() functions to swap teams and reset frags respectively.
Also, the task is set to repeat itself every amx_team_swap_time seconds so the teams will keep swapping and resetting frags every 10 minutes.

Please note that this is an example and you may need to modify the code to suit your needs, also, this plugin will only work on a fixed map.

Also, please note that this plugin is not tested and it may not work as expected, you may need to test it and make any necessary adjustments.
shayan123 is offline
Send a message via ICQ to shayan123 Send a message via AIM to shayan123 Send a message via Yahoo to shayan123 Send a message via Skype™ to shayan123