Raised This Month: $51 Target: $400
 12% 

Switching teams


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
maxi2014
Junior Member
Join Date: Jun 2022
Old 06-06-2022 , 15:46   Switching teams
Reply With Quote #1

Hi! I need a little help with my script, i want to make everyone switch teams.
Thanks if you take your time to help me.
OUTPUT: Debug1

CS:Source btw

PHP Code:
decl team;
int maxclients MaxClients;
for (
int i<= maxclientsi++) {
    
PrintToChatAll("Debug1"); //RUNS OK
    
if (IsClientConnected(i)) {
        
PrintToChatAll("Debug2");
        
team GetClientTeam(i);
        if (
team == CS_TEAM_CT) {
            
ChangeClientTeam(iCS_TEAM_T);
        } else if (
team == CS_TEAM_T) {
            
PrintToChatAll("Debug3");
            
ChangeClientTeam(iCS_TEAM_CT);
        }
    }


Last edited by maxi2014; 06-06-2022 at 16:00.
maxi2014 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 06-28-2022 , 04:44   Re: Switching teams
Reply With Quote #2

Here is a working ct (change teams) command from a plugin I wrote.
From the chat type !ct to change every player humans and bots team.

un-comment this line if you also want the round to immediately end and a new round start.
//ServerCommand("mp_restartgame 1");

Nice effort. You almost had it!

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#pragma semicolon 1

public void OnPluginStart()
{
    
RegConsoleCmd("sm_ct",        Command_SwitchTeams);
}

public 
Action Command_SwitchTeams(int clientint args)
{
    if (
GetClientTeam(client) == CS_TEAM_NONE)
        return 
Plugin_Continue;

    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            if (
GetClientTeam(i) == CS_TEAM_T)
                
ChangeClientTeam(i,CS_TEAM_CT);
            else if (
GetClientTeam(i) == CS_TEAM_CT)
                
ChangeClientTeam(i,CS_TEAM_T);
        }
    }
    
//ServerCommand("mp_restartgame 1");
    
return Plugin_Continue;


Last edited by Austin; 06-29-2022 at 16:13.
Austin is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 06-28-2022 , 08:30   Re: Switching teams
Reply With Quote #3

Quote:
Originally Posted by Austin View Post
Here is a working ct (change teams) command from a plugin I wrote.
From the chat type !cm to change every player humans and bots team.

un-comment this line if you also want the round to immediately end and a new round start.
//ServerCommand("mp_restartgame 1");

Nice effort. You almost had it!

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#pragma semicolon 1

public void OnPluginStart()
{
    
RegConsoleCmd("sm_ct",        Command_SwitchTeams);
}

public 
Action Command_SwitchTeams(int clientint args)
{
    if (
GetClientTeam(client) == CS_TEAM_NONE)
        return 
Plugin_Continue;

    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            if (
GetClientTeam(i) == CS_TEAM_T)
                
ChangeClientTeam(i,CS_TEAM_CT);
            else if (
GetClientTeam(i) == CS_TEAM_CT)
                
ChangeClientTeam(i,CS_TEAM_T);
        }
    }
    
//ServerCommand("mp_restartgame 1");
    
return Plugin_Continue;

Not a type of command I would register for every player to be allowed to use.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 06-28-2022 , 14:34   Re: Switching teams
Reply With Quote #4

Quote:
Originally Posted by eyal282 View Post
Not a type of command I would register for every player to be allowed to use.
On my servers only well behaved friends are allowed in and everyone has admin,
so I keep forgetting about this.

Would this be the correct way to limit this to SM admins only?

PHP Code:
RegConsoleCmd("sm_ct"Command_SwitchTeamsADMFLAG_RESERVATION); 
tx
Austin is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 06-28-2022 , 14:57   Re: Switching teams
Reply With Quote #5

Quote:
Originally Posted by Austin View Post
On my servers only well behaved friends are allowed in and everyone has admin,
so I keep forgetting about this.

Would this be the correct way to limit this to SM admins only?

PHP Code:
RegConsoleCmd("sm_ct"Command_SwitchTeamsADMFLAG_RESERVATION); 
tx
No. Use an admin command -
PHP Code:
RegAdminCmd("sm_ct"Command_SwitchTeamsADMFLAG_RESERVATION"Switches players to opposite team."); 
Maxximou5 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode