View Single Post
arcticx2
Senior Member
Join Date: Nov 2011
Old 10-15-2016 , 09:07   Re: [Request] Lock Team for CS:GO
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
Use AddCommandListener to jointeam, don't create new sm command.
thanks for respond

i found new useful plugin in here

https://forums.alliedmods.net/showth...20#post2279220

and the problem of this plugin is it locks team BUT YOU CANT UNDO IT ! i change the value of sm_lock_teams but it doesn't effect the game

anyway i dont know how to program in sm but i create one so can you check what is wrong in the source code or mine ?

note: my code is just like source but i tried to create another admin command to change the status of
sm_lock_teams variable , when i enter sm_lockteams nothing will happen


PHP Code:
#pragma semicolon 1
#include <sourcemod>
#define PLUGIN_VERSION    "1.0"

new Handle:g_hLocked INVALID_HANDLE;

public 
OnPluginStart()
{
    
AddCommandListener(Command_JoinTeam"jointeam");
    
g_hLocked CreateConVar("sm_lock_teams""1""Enable or disable locking teams during match"FCVAR_NOTIFY);
    
    
RegAdminCmd("sm_lockteams",            CMD_LOCK,            ADMFLAG_ROOT,        "Lock join teams");
}

public 
Action:Command_JoinTeam(client, const String:command[], args)
{    
    if (
client != 0)
    {
        if(
IsClientInGame(client) && !IsFakeClient(client))
        {
            if (
GetClientTeam(client) > && GetConVarBool(g_hLocked))
            {
                
PrintToChat(client"\x01 \x07[SM] Change team is locked by admin!");
                return 
Plugin_Stop;
            }
        }
    }

    return 
Plugin_Continue;
}  

public 
ActionCMD_LOCK(clientargs)
{
    if(!
IsClientValid(client) || !IsClientInGame(client))
    {
        return 
Plugin_Handled;
    }
    
    if(
args != 1)
    {
        
ReplyToCommand(client"%t""CMD_Extend_Usage");
        return 
Plugin_Handled;
    }
        
    if (
GetConVarBool(g_hLocked)){
        
SetConVarInt(g_hLocked0);
        
PrintToChat(client"\x01 \x07[SM] Change team is opened by admin");

    }else{
        
SetConVarInt(g_hLocked1);
        
PrintToChat(client"\x01 \x07[SM] Change team is closed by admin");

    }
        
    return 
Plugin_Handled;
}


boolIsClientValid(client)
{
    return ((
client 0) && (client <= MaxClients));


Last edited by arcticx2; 10-15-2016 at 09:09. Reason: add note
arcticx2 is offline