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

Allowing console command for specific team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
h0pe
Junior Member
Join Date: Sep 2015
Location: The Moon
Old 11-20-2015 , 06:06   Allowing console command for specific team
Reply With Quote #1

Hello guys,
I need to know how can I create a console command for a specific team.
For example terrorists in csgo...
__________________

"You never fail until you stop trying."
Albert Einstein

----------------

Wanna see how to trick fools? Click here!


h0pe is offline
Send a message via Skype™ to h0pe
xerox8521
Senior Member
Join Date: Sep 2011
Old 11-20-2015 , 06:38   Re: Allowing console command for specific team
Reply With Quote #2

You cannot really create commands depending on the team however you can check their team using https://sm.alliedmods.net/new-api/clients/GetClientTeam

if you include <cstrike> you can then use CS_TEAM_T CS_TEAM_CT for checking


PHP Code:

if(GetClientTeam(client) == CS_TEAM_T// Check if client is T
{



Last edited by xerox8521; 11-20-2015 at 06:39.
xerox8521 is offline
tommie113
AlliedModders Donor
Join Date: Oct 2013
Old 11-20-2015 , 09:45   Re: Allowing console command for specific team
Reply With Quote #3

No need for include cstrike.
Use GetClientTeam(client) and check it's integer value.
1 = spectator
2 = terrorist
3 = counter-terrorist
__________________
No longer taking requests due to lack of time and interrest.
Only helping out with minor things through forum.
tommie113 is offline
nhnkl159
Senior Member
Join Date: Jul 2012
Location: Israel 3>
Old 11-20-2015 , 13:29   Re: Allowing console command for specific team
Reply With Quote #4

Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "nhnkl159"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <sdktools>


public void OnPluginStart()
{
	RegConsoleCmd("sm_test", Cmd_Test, "Test Command");
}


public Action:Cmd_Test(client, args)
{
	if(GetClientTeam(client) == 1)
	{
		//Spectors
	}
	if(GetClientTeam(client) == 2)
	{
		//Terrorists
	}
	if(GetClientTeam(client) == 3)
	{
		//CounterTerrorists
	}
}
__________________
nhnkl159 is offline
Send a message via Skype™ to nhnkl159
xerox8521
Senior Member
Join Date: Sep 2011
Old 11-20-2015 , 15:00   Re: Allowing console command for specific team
Reply With Quote #5

why making life more complicated than it has to be ? I mean those defines dont exist just for the lulz.
xerox8521 is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 11-20-2015 , 17:55   Re: Allowing console command for specific team
Reply With Quote #6

Quote:
Originally Posted by nhnkl159 View Post
Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "nhnkl159"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <sdktools>


public void OnPluginStart()
{
    RegConsoleCmd("sm_test", Cmd_Test, "Test Command");
}


public Action:Cmd_Test(client, args)
{
    if(GetClientTeam(client) == 1)
    {
        //Spectors
    }
    if(GetClientTeam(client) == 2)
    {
        //Terrorists
    }
    if(GetClientTeam(client) == 3)
    {
        //CounterTerrorists
    }
}

You should always use a switch over if/else statements whenever possible.
__________________
Spirit_12 is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 11-21-2015 , 14:46   Re: Allowing console command for specific team
Reply With Quote #7

And you also don't need to call GetClientTeam() every single time either. Call it once, save its result, and then use a switch statement.
Potato Uno 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 08:25.


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