Raised This Month: $32 Target: $400
 8% 

[CS:GO] Help with force client join a team on connect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 01-28-2016 , 23:02   [CS:GO] Help with force client join a team on connect
Reply With Quote #1

I'm trying to force the player to join to CT or T automatically...

PHP Code:
HookEvent("player_connect_full"Event_OnFullConnectEventHookMode_Pre);

..........

public 
Action Event_OnFullConnect(Handle event, const char[]namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
char steamauth[32];
    
GetClientAuthId(clientAuthId_Steam2steamauthsizeof(steamauth));
    if (
StrEqual(steamauthsteamid_ct))
    {
        
CreateTimer(0.1ForceTeamCTGetClientUserId(client));
    }
    else if (
StrEqual(steamauthsteamid_tfalse))
    {
        
CreateTimer(0.1ForceTeamTGetClientUserId(client));
    }
//These "steamid_ct" and "steamid_t" are ok, they work fine... They are settled down on another situation

..........

public 
Action ForceTeamCT(Handle timerany userid)
{
    
int client GetClientOfUserId(userid);
    
    
SetEntProp(clientProp_Send"m_iTeamNum"CS_TEAM_CT);
    
ChangeClientTeam(client3);
    
CS_RespawnPlayer(client);
}

public 
Action ForceTeamT(Handle timerany userid)
{
    
int client GetClientOfUserId(userid);
    
    
SetEntProp(clientProp_Send"m_iTeamNum"CS_TEAM_T);
    
ChangeClientTeam(client2);
    
CS_RespawnPlayer(client);

But when the match starts, when all the players from a team are dead, the match won't end...

mp_ignore_round_win_conditions is always 0

This only happens when I force the players that way, before they choose a team by themselves. When they choose a team and then I just change their teams, the round will get a winner...

I guess that:
PHP Code:
SetEntProp(clientProp_Send"m_iTeamNum"CS_TEAM_T);
ChangeClientTeam(client2); 
isn't enough to the game know which team you are, because planting and defusing the bomb make a winner.

If there is a way to literally make the players to select/click the CT or T team when they connect this will be good.

Last edited by joao7yt; 01-28-2016 at 23:34.
joao7yt is offline
Disowned
Member
Join Date: Oct 2015
Old 01-29-2016 , 00:34   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #2

CS_SwitchTeam(int client, int team)
Disowned is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 01-29-2016 , 00:41   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #3

Quote:
Originally Posted by Disowned View Post
CS_SwitchTeam(int client, int team)
I will try it in a few hours, but searching in my phone I think it will work, thanks mate
joao7yt is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 01-29-2016 , 07:59   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #4

This worked fine, I don't know why they don't mention this in another posts... I didn't even need to create a timer.

Tip: If you want to move the client to spectator use:
PHP Code:
ChangeClientTeam(clientCS_TEAM_SPECTATOR); 
And if you want to move the client to coach CT or T:
PHP Code:
ChangeClientTeam(clientCS_TEAM_SPECTATOR);
SetEntProp(clientProp_Send"m_iCoachingTeam"3//Or "2" to coach as T; 
And to remove the client from coach:
PHP Code:
SetEntProp(clientProp_Send"m_iCoachingTeam"0); 

Last edited by joao7yt; 01-29-2016 at 08:01.
joao7yt is offline
apocalyptic
Senior Member
Join Date: Feb 2013
Location: China
Old 02-02-2016 , 03:06   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #5

Quote:
Originally Posted by joao7yt View Post
This worked fine, I don't know why they don't mention this in another posts... I didn't even need to create a timer.
This may not be prefect. Some players cannot buy any weapons by using mouse, but (console) buy commands work fine.
apocalyptic is offline
apocalyptic
Senior Member
Join Date: Feb 2013
Location: China
Old 02-02-2016 , 03:15   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #6

This is NOT automatically, but at least it has no bugs.
PHP Code:
public OnPluginStart()
{
    
AddCommandListener(Command_JoinTeam"jointeam")
}

public 
Action:Command_JoinTeam(client, const String:command[], argc)
{
    if (
IsFakeClient(client))
        return 
Plugin_Continue //You must allow bots to join, or there will be no bots in game.
    
decl String:arg[4]
    
GetCmdArg(1argsizeof(arg))
    new 
ToTeam=StringToInt(arg)//0=random  1=spectator  2=terrorist  3=counter-terrorist
    //You can detect any player's choice here.
    //If you allow them to join, return Plugin_Continue to let them play.
    //Otherwise, return Plugin_Stop to force them to select again.


Last edited by apocalyptic; 02-02-2016 at 03:18.
apocalyptic is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 02-02-2016 , 04:18   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #7

Quote:
Originally Posted by apocalyptic View Post
This is NOT automatically, but at least it has no bugs.
Oh, I noticed this bug, but I didn't think it's related with that... Good to know, later I will try your code, ty bro
joao7yt is offline
apocalyptic
Senior Member
Join Date: Feb 2013
Location: China
Old 02-02-2016 , 07:55   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #8

Quote:
Originally Posted by joao7yt View Post
Oh, I noticed this bug, but I didn't think it's related with that... Good to know, later I will try your code, ty bro
Here comes my newest test: (automatic, and players can buy weapons by clicking mouses)
PHP Code:
#include <clients>
public OnClientPutInServer(client)
{
    
//you must make a timer here, or ClientCommand will not work.
    
CreateTimer(1.0,AutoJoin,client)
}
public 
Action:AutoJoin(Handle:timerany:client)
{
    
//force a player to join, for example:
    
ClientCommand(client,"jointeam CS_TEAM_CT")

apocalyptic is offline
CaptainNervous
Senior Member
Join Date: Mar 2015
Location: World
Old 02-02-2016 , 08:10   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #9

This works fine but if players choose auto select they can join other team.
Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

public OnPluginStart()
{
	RegConsoleCmd("jointeam", Command_JoinTeam); 
}

public Action:Command_JoinTeam(client, argc)
{
	if(!argc || !client || !IsClientInGame(client))
		return Plugin_Continue;

	decl String:m_szTeam[8];
	GetCmdArg(1, m_szTeam, sizeof(m_szTeam));
	new m_iTeam = StringToInt(m_szTeam);
	
	if(m_iTeam == CS_TEAM_CT)
	{
		CS_SwitchTeam(client, 2)
		return Plugin_Handled;
	}

	return Plugin_Continue;
}
__________________
CaptainNervous is offline
hamilton5
Veteran Member
Join Date: Oct 2012
Location: USA
Old 02-02-2016 , 22:38   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #10

why was mp_humanteam ruled out for this scenario?
hamilton5 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 22:37.


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