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

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


Post New Thread Reply   
 
Thread Tools Display Modes
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 02-04-2016 , 21:52   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #11

Quote:
Originally Posted by hamilton5 View Post
why was mp_humanteam ruled out for this scenario?
because i want to put clients on both teams, but the plugin will choose it...
joao7yt is offline
exc4libur
Member
Join Date: Oct 2015
Old 03-07-2016 , 17:34   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #12

Is it possible to deactivate the whole team-choose-menu inclusive motd?
exc4libur is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 03-07-2016 , 17:53   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #13

Quote:
Originally Posted by exc4libur View Post
Is it possible to deactivate the whole team-choose-menu inclusive motd?
I think if you hook the "jointeam" command and do a "return Plugin_Stop;" it wont open. And for motd, look at my posts, I have a plugin to block it.
joao7yt is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 03-07-2016 , 20:10   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #14

Quote:
Originally Posted by exc4libur View Post
Is it possible to deactivate the whole team-choose-menu inclusive motd?
There's the cvar "sv_disable_show_team_select_menu", don't think it affects the motd though
__________________
splewis is offline
exc4libur
Member
Join Date: Oct 2015
Old 03-08-2016 , 02:14   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #15

Yeah, this is working but there is another problem with the auto-join now. In case there is now "jointeam" command the addcommandlistener isn't working and teamjoin is randomly. I have tried to use player_death_pre hook, but this doesn't work either. After a following death it works.

Is there perhaps another command when a client "autojoins"?

Where can i get a list of commands that are executed while starting? Have read a lot of post, but found nothing.

Best regards

P.S.: I have added mp_force_pick_time 0 to prevent delay

Last edited by exc4libur; 03-08-2016 at 02:35.
exc4libur is offline
Wilczek
AlliedModders Donor
Join Date: Oct 2012
Location: Poland
Old 03-08-2016 , 03:04   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #16

I'm sorry if I don't understand, but... Do you want to just make an autojoin (no team select possible) and lock changing the teams? If so, I really don't get all this discussion. Just use a mp_force_assign_teams 1 and a plugin to lock teams.
__________________
Wilczek is offline
exc4libur
Member
Join Date: Oct 2015
Old 03-08-2016 , 03:09   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #17

No that is not what i wanted to do. The workflow should be like:

1. Player starts to connect to server
2. No Team-Choice-Menu will be displayed
3. I check steamid with a db entry and decide which team to join
4. Force player to this decided team without the option for himself to choice

Problem is that when i use mp_force_assign_teams or use the auto-join from the team-choice-menu, the plugin doesn't work on the first go. After a player_death everythings fine.
exc4libur is offline
Wilczek
AlliedModders Donor
Join Date: Oct 2012
Location: Poland
Old 03-08-2016 , 03:20   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #18

I haven't tested it, but:

1. Don't hook it.
2. mp_force_assing_teams 1 - it will skip the team select menu after clicking OK in the MOTD window
3. Hook player_team event and do the math here
4. CS_SwitchTeam(client, team).

Probably you could hook the broadcast after 2. step to block it and don't spam the chat with double "Player xxx joined XXX" message as the proper team will be displayed after 4th step.
__________________

Last edited by Wilczek; 03-08-2016 at 03:22.
Wilczek is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 03-08-2016 , 05:37   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #19

Quote:
Originally Posted by Wilczek View Post
I haven't tested it, but:

1. Don't hook it.
2. mp_force_assing_teams 1 - it will skip the team select menu after clicking OK in the MOTD window
3. Hook player_team event and do the math here
4. CS_SwitchTeam(client, team).

Probably you could hook the broadcast after 2. step to block it and don't spam the chat with double "Player xxx joined XXX" message as the proper team will be displayed after 4th step.
There's no mp_force_assing_teams command...

If we use sv_disable_show_team_select_menu 1 and when the player gets in a team randomly we hook player_team?

Last edited by joao7yt; 03-08-2016 at 05:45.
joao7yt is offline
exc4libur
Member
Join Date: Oct 2015
Old 03-08-2016 , 06:37   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #20

Have tested it. The same situation as before. PLayer spawns in a random team and stays. Only with player_death hook a team switch is made.

The problem seems to be to get the teamswitch before spawning the first time. It works with pre_player_death hook but only with admincommandlistener "jointeam", so the menu must be active. When auto-join is used, this does not work.

This one works after spawn on first "real" death:

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma semicolon 1

bool g_bTeamSelect[32];

#define CLANTAG_LENGTH 16
char g_ClanTag[MAXPLAYERS+1][CLANTAG_LENGTH];

public Plugin myinfo = {
    name = "CS:GO Restrict",
    author = "eXc",
    description = "Plugin to restrict team join",
    version = "0.1b",
    url = "www.myrisk-gaming.de"
};

public void OnPluginStart()
{
    for(int i; i<=MaxClients; i++)
    {
        g_bTeamSelect[i] = false;
    }

  HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
  //HookEvent("player_team", Event_PlayerTeam);
}

public Action Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast)
{
    // Getting infos of involved players
    int userid = event.GetInt("userid");
    int client = GetClientOfUserId(userid);
    PrintToChatAll("Userid: %i Client: %i -> Death Pre", userid, client);
    
    if(!client)
        return Plugin_Handled;
    
    if(g_bTeamSelect[client] == false)
    {
        // 2 = T, 3 = CT
        new m_iTeam = GetClientTeam(client);
        
        if(m_iTeam == CS_TEAM_CT)
        {
            PrintToChatAll("Ab zu den Terroristen.");
            CS_SwitchTeam(client, CS_TEAM_T);
            if (!IsPlayerAlive(client)) {
                RequestFrame(RF_RespawnClient, client);
            }
            return Plugin_Handled;
        }
        else if(m_iTeam == CS_TEAM_T)
        {
            CS_SwitchTeam(client, CS_TEAM_T);
            if (!IsPlayerAlive(client)) {
                RequestFrame(RF_RespawnClient, client);
            }
            return Plugin_Handled;
        }
        else if(m_iTeam == CS_TEAM_SPECTATOR)
        {
            CS_SwitchTeam(client, CS_TEAM_T);
            if (!IsPlayerAlive(client)) {
                RequestFrame(RF_RespawnClient, client);
            }
            return Plugin_Handled;
        }
    }
    return Plugin_Handled;
}

public void RF_RespawnClient(int client) {
  CS_RespawnPlayer(client);
}
This one works directly on the first spawn but only with Team-Choice-Menu enabled.

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

public Plugin myinfo = {
    name = "CS:GO Restrict",
    author = "eXc",
    description = "Plugin to restrict team join",
    version = "0.1b",
    url = "www.myrisk-gaming.de"
};

public void OnPluginStart()
{
    AddCommandListener(Event_OnPlayerTeamJoin, "jointeam");
}

public Action Event_OnPlayerTeamJoin(int client, const char[] command,int args)
{
    if(!args || !client || !IsClientInGame(client))
    if(!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, CS_TEAM_T)
        PrintToChatAll("You are not allowed to join CT.")
            if (!IsPlayerAlive(client)) {
                RequestFrame(RF_RespawnClient, client);
            }
            return Plugin_Handled;
    }
    else if(m_iTeam == CS_TEAM_T)
    {
        CS_SwitchTeam(client,CS_TEAM_T)
            if (!IsPlayerAlive(client)) {
                RequestFrame(RF_RespawnClient, client);
            }
            return Plugin_Handled;
    }
    else if(m_iTeam == CS_TEAM_SPECTATOR)
    {
        CS_SwitchTeam(client,CS_TEAM_SPECTATOR)
            if (!IsPlayerAlive(client)) {
                RequestFrame(RF_RespawnClient, client);
            }
            return Plugin_Handled;
    }
    return Plugin_Handled;
}

public void RF_RespawnClient(int client) {
  CS_RespawnPlayer(client);
}
exc4libur 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:05.


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