View Single Post
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 10-07-2018 , 04:28   Re: [L4D2] Play on Team 4
Reply With Quote #9

PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.0"

public Plugin myinfo =
{
    
name "[L4D2] Play as Team 4",
    
author "Xanaguy/MasterMe",
    
description "Play on the hidden Team 4!",
    
version PLUGIN_VERSION,
    
url "https://forums.alliedmods.net/showthread.php?t=311185"
};

public 
void OnPluginStart()
{
    
CreateConVar("team4version"PLUGIN_VERSION"\"Play as Team 4\" plugin version"FCVAR_NOTIFY|FCVAR_DONTRECORD);

    
RegAdminCmd("sm_team4"ClientToTeam4ADMFLAG_ROOT"Switch to Team 4.");
    
RegAdminCmd("sm_team3"ClientToTeam3ADMFLAG_ROOT"Switch to Team 3.");
    
RegAdminCmd("sm_team2"ClientToTeam2ADMFLAG_ROOT"Switch to Team 2.");
}

public 
Action ClientToTeam4(int clientint args)
{
    if (!
bIsValidClient(client))
    {
        
ReplyToCommand(client"[PT4] You must be in-game to use this command.");
        return 
Plugin_Handled;
    }

    
ChangeClientTeam(client4);

    return 
Plugin_Handled;
}

public 
Action ClientToTeam2(int clientint args)
{
    if (!
bIsValidClient(client))
    {
        
ReplyToCommand(client"[PT4] You must be in-game to use this command.");
        return 
Plugin_Handled;
    }

    
FindConVar("vs_max_team_switches").SetInt(9999);
    
ClientCommand(client"jointeam 2");
    
FindConVar("vs_max_team_switches").SetInt(1);

    return 
Plugin_Handled;
}

public 
Action ClientToTeam3(int clientint args)
{
    if (!
bIsValidClient(client))
    {
        
ReplyToCommand(client"[PT4] You must be in-game to use this command.");
        return 
Plugin_Handled;
    }

    
FindConVar("vs_max_team_switches").SetInt(9999);
    
ClientCommand(client"jointeam 3");
    
FindConVar("vs_max_team_switches").SetInt(1);

    return 
Plugin_Handled;
}

stock bool bIsValidClient(int client)
{
    if (
client <= || client MaxClients || !IsClientInGame(client) || IsFakeClient(client))
    {
        return 
false;
    }

    return 
true;

Maybe you could add support for letting admins target other players with the commands.
Attached Files
File Type: sp Get Plugin or Get Source (l4d2_team4.sp - 795 views - 1.9 KB)
__________________
Psyk0tik is offline