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

[CS:GO] force team join


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
theprodigy1
Junior Member
Join Date: Jan 2017
Old 01-01-2017 , 17:56   [CS:GO] force team join
Reply With Quote #1

This is plugin by @thetwistedpanda its working just fine but what i need is few cvars to manage it.
I need a cvar to control wich team should everybody join CT or T.
And simple on/off cvar.
I am banging my head with my MG server as some maps are T only but CTs still can join somehow and ruin the whole game.

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

public OnPluginStart()
{
    
HookEvent("player_connect_full"Event_OnFullConnectEventHookMode_Pre);
    
HookEvent("cs_match_end_restart"Event_OnMatchRestartEventHookMode_Pre);
    
HookEvent("player_team"Event_OnPlayerTeamEventHookMode_Pre);
    
HookEvent("player_death"Event_OnPlayerDeathEventHookMode_Pre);
    
AddCommandListener(Command_Join"jointeam");
}

public 
Action:Event_OnFullConnect(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
client || !IsClientInGame(client))
        return 
Plugin_Continue;

    new 
iRediBlue;
    for(new 
1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i))
            continue;

        new 
iTeam GetClientTeam(i);
        if(
iTeam == CS_TEAM_T)
            
iRed++;
        else if(
iTeam == CS_TEAM_CT)
            
iBlue++;
    }

    if(
iRed iBlue)
        
SetEntProp(clientProp_Send"m_iTeamNum"CS_TEAM_T);
    else
        
SetEntProp(clientProp_Send"m_iTeamNum"CS_TEAM_CT);

    
ForcePlayerSuicide(client);
    
CS_RespawnPlayer(client);
    return 
Plugin_Continue;
}

public 
Action:Event_OnMatchRestart(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
iRediBlueiJoin;
    for(new 
1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i))
            continue;

        switch(
GetClientTeam(i))
        {
            case 
CS_TEAM_T:
                
iRed++;
            case 
CS_TEAM_CT:
                
iBlue++;
        }
    }

    for(new 
1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i))
            continue;

        if(
iRed iBlue)
            
iJoin CS_TEAM_T;
        else if(
iBlue iRed)
            
iJoin CS_TEAM_CT;
        else
            
iJoin GetRandomInt(CS_TEAM_TCS_TEAM_CT);

        switch(
iJoin)
        {
            case 
CS_TEAM_T:
                
iRed++;
            case 
CS_TEAM_CT:
                
iBlue++;
        }

        
ChangeClientTeam(iiJoin);
    }
}

public 
Action:Event_OnPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
client || !IsClientInGame(client))
        return 
Plugin_Continue;

    if(!
IsPlayerAlive(client))
        
CreateTimer(0.1Timer_RespawnGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    return 
Plugin_Continue;
}

public 
Action:Timer_Respawn(Handle:timerany:userid)
{
    new 
client GetClientOfUserId(userid);
    if(!
client)
        return 
Plugin_Continue;

    new 
iTeam GetClientTeam(client);
    if(
iTeam <= CS_TEAM_SPECTATOR)
        return 
Plugin_Continue;

    if(
IsPlayerAlive(client))
        return 
Plugin_Continue;

    
CS_RespawnPlayer(client);

    return 
Plugin_Continue;
}

public 
Action:Command_Join(client, const String:command[], argc)
{
    
decl String:sJoining[8];
    
GetCmdArg(1sJoiningsizeof(sJoining));
    new 
iJoining StringToInt(sJoining);
    if(
iJoining == CS_TEAM_SPECTATOR)
        return 
Plugin_Continue;

    new 
iTeam GetClientTeam(client);
    if(
iJoining == iTeam)
        return 
Plugin_Handled;
    else
    {
        
SetEntProp(clientProp_Send"m_iTeamNum"iJoining);
        
ForcePlayerSuicide(client);
        
CS_RespawnPlayer(client);
    }

    return 
Plugin_Continue;
}


public 
Action:Event_OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
client || !IsClientInGame(client))
        return 
Plugin_Continue;

    
CreateTimer(0.1Timer_RespawnGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);

    return 
Plugin_Continue;

theprodigy1 is offline
Mr.Freeman
Senior Member
Join Date: Nov 2013
Location: Canada
Old 01-01-2017 , 21:49   Re: [CS:GO] force team join
Reply With Quote #2

I haven't modded in quite some time but would it no be still possible to hook 'jointeam' and when the players are in the team menu it auto sorts them to Terrorist even if they select CT team?

I could try and write this for you if you can't figure it out, just trying to relearn after the major syntax changes
__________________
Feel Free to PM me about any questions, I'll do my best to help
Mr.Freeman is offline
iGANGNAM
AlliedModders Donor
Join Date: Sep 2012
Location: Lithuania
Old 01-03-2017 , 11:24   Re: [CS:GO] force team join
Reply With Quote #3

Try my plugins, might resolve your problem.
Attached Files
File Type: sp Get Plugin or Get Source (a_round_ender.sp - 261 views - 6.1 KB)
File Type: sp Get Plugin or Get Source (csgo_spawntools.sp - 285 views - 17.0 KB)
File Type: inc spawntools.inc (315 Bytes, 250 views)
__________________
iGANGNAM is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 01-04-2017 , 02:44   Re: [CS:GO] force team join
Reply With Quote #4

I updated it to the new syntax and added the CVAR functionality you wanted. Untested.

"forceteam_setting" is the new cvar and it's ONLY acceptable values are 0, 2, or 3.

0 - Plugin treats joining as it did before
2 - Forces players to the Terrorist team
3 - Forces players to the Counter-Terrorist Team
Attached Files
File Type: sp Get Plugin or Get Source (somePlugin123.sp - 866 views - 4.3 KB)

Last edited by headline; 01-05-2017 at 00:51.
headline is offline
theprodigy1
Junior Member
Join Date: Jan 2017
Old 01-04-2017 , 19:18   Re: [CS:GO] force team join
Reply With Quote #5

Quote:
Originally Posted by Headline View Post
I updated it to the new syntax and added the CVAR functionality you wanted. Untested.

"forceteam_setting" is the new cvar and it's ONLY acceptable values are 0, 2, or 3.

0 - Plugin treats joining as it did before
2 - Forces players to the Terrorist team
3 - Forces players to the Counter-Terrorist Team
When 0 it kills all players doesn't matter t or ct if you can fix this it would be nice.
2 and 3 work great.

Last edited by theprodigy1; 01-04-2017 at 19:28.
theprodigy1 is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 01-04-2017 , 19:28   Re: [CS:GO] force team join
Reply With Quote #6

Quote:
Originally Posted by theprodigy1 View Post
When 0 it kills all players doesn't matter t or ct
2 or 3 works fine forces you to a team, but if you press M and choose CT if its set on 2 the player goes to ct immediately and goes back to t immediately aswell and thats enough to ruin the game so it doesn't make a difference for me thanks for the try...
Okay so 0 kills all players? What do you mean. Ill fix 2and 3 soon
headline is offline
theprodigy1
Junior Member
Join Date: Jan 2017
Old 01-04-2017 , 19:41   Re: [CS:GO] force team join
Reply With Quote #7

I mean litteraly what i said it kills everybody i just put the plugin in the server and everybody started dying until i put forceteam_setting 3 or 2

Quote:
Originally Posted by iGANGNAM View Post
Try my plugins, might resolve your problem.
I don't have problems with the spawnpoints the map i'm trying is with 64 sp

Last edited by theprodigy1; 01-04-2017 at 19:49.
theprodigy1 is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 01-05-2017 , 00:52   Re: [CS:GO] force team join
Reply With Quote #8

Quote:
Originally Posted by theprodigy1 View Post
I mean litteraly what i said it kills everybody i just put the plugin in the server and everybody started dying until i put forceteam_setting 3 or 2



I don't have problems with the spawnpoints the map i'm trying is with 64 sp
I updated the plugin post I made. Try that
headline is offline
theprodigy1
Junior Member
Join Date: Jan 2017
Old 01-05-2017 , 16:30   Re: [CS:GO] force team join
Reply With Quote #9

Quote:
Originally Posted by Headline View Post
I updated the plugin post I made. Try that
Wokrs even worse than before, when set on 3 makes people join both teams and instantly kills them, when set on 2 everybody joins ct but still they die, on 0 nothing happens people still die.

Last edited by theprodigy1; 01-05-2017 at 16:30.
theprodigy1 is offline
exc4libur
Member
Join Date: Oct 2015
Old 02-15-2017 , 13:01   Re: [CS:GO] force team join
Reply With Quote #10

Why isn't it possible to force player to spectator?
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 18:40.


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