This code is from Jon, I tried to edit it for my needs but I just don't know enough (trying to learn) to get it to do what I want it to do. I tried sending the server cmds in a few parts in the code, it works, but the timing is wrong, and I don't know if this is best option.
- After 3 rounds I need it to change team and I want a cvar to be set "ajc_team <1|2>" and also "pb_bot_join_team <T|CT>" (i.e. CT(humans) changes to T, ajc_team = 1 pb_bot_join_team = CT) I want this to happen each time the code changes team every 3 rounds, so the next cmds would be (i.e. T(humans) changes to CT, ajc_teams = 2 pb_bot_join_team = T) I hope this makes since.
You don't have to right full code if you don't want, I can try to learn myself, only maybe some hints/tips so I can finally figure this out, thank you.
PHP Code:
#include <amxmodx>
#include <cstrike>
#define PLUGIN "Switch Teams"
#define VERSION "1.0"
#define AUTHOR "Jon"
#define ROUNDS 3
new g_iRounds;
new g_iMaxPlayers;
public plugin_init( )
{
register_plugin( PLUGIN, VERSION, AUTHOR );
g_iMaxPlayers = get_maxplayers( );
register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" );
register_logevent( "EventRoundEnd", 2, "1=Round_End" );
}
public EventNewRound( )
{
if( GetPlayers( ) )
{
g_iRounds++;
}
}
public EventRoundEnd( )
{
if( g_iRounds == ROUNDS )
{
for( new i = 1; i <= g_iMaxPlayers; i++ )
{
if( !is_user_connected( i ) )
{
continue;
}
switch( cs_get_user_team( i ) )
{
case CS_TEAM_T:
{
cs_set_user_team( i, CS_TEAM_CT );
}
case CS_TEAM_CT:
{
cs_set_user_team( i, CS_TEAM_T );
}
}
}
g_iRounds = 0;
}
}
bool:GetPlayers( )
{
new iTerrorists, iCTs;
for( new i = 1; i <= g_iMaxPlayers; i++ )
{
if( !is_user_connected( i ) )
{
continue;
}
switch( cs_get_user_team( i ) )
{
case CS_TEAM_T:
{
iTerrorists++;
}
case CS_TEAM_CT:
{
iCTs++;
}
}
if( iTerrorists && iCTs )
{
return true;
}
}
return false;
}