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

Team timeout


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hpkA
Junior Member
Join Date: Dec 2016
Old 05-22-2017 , 10:13   Team timeout
Reply With Quote #1

Helo guys,

I need a simple plugin that when the terrorists say !tactical the server uses the command timeout_terrorist_start and when the ct's timeout_ct_start

Can someone help me?
Sorry for the poor english


Regards,
hpkA is offline
g00gl3
Member
Join Date: Feb 2016
Location: bulgaria
Old 05-22-2017 , 13:03   Re: Team timeout
Reply With Quote #2

not tested =] ty.

Code:
#pragma semicolon 1

#include <sourcemod>
#include <cstrike>

public Plugin:myinfo =
{
	name = "Team Timeout",
	author = "g00gl3",
	description = "Set a team timeout",
	version = "1.0.0"
};

public OnPluginStart()
{
	RegConsoleCmd("sm_tactical", Command_TimeOut, "Start a Team timeout"); 
}

public Action:Command_TimeOut(client, args)
{
	if(GetClientTeam(client) == CS_TEAM_T)
	{
		ServerCommand("timeout_terrorist_start");
		PrintToChatAll(" \x02[TimeOut] \x04%N \x03start the timeout for (T) Team", client);
		
		return Plugin_Handled;
	}
	
	else if(GetClientTeam(client) == CS_TEAM_CT)
	{
		ServerCommand("timeout_ct_start");
		PrintToChatAll(" \x02[TimeOut] \x04%N \x03start the timeout for (CT) Team", client);
		
		return Plugin_Handled;
	}

	return Plugin_Continue;
}
Attached Files
File Type: sp Get Plugin or Get Source (tactical.sp - 319 views - 776 Bytes)

Last edited by g00gl3; 05-22-2017 at 13:04.
g00gl3 is offline
Bobakanoosh
Senior Member
Join Date: Sep 2015
Location: United States
Old 05-22-2017 , 13:18   Re: Team timeout
Reply With Quote #3

Quote:
Originally Posted by g00gl3 View Post
not tested =] ty.
beat me to it ;(

Might add that players could easily spam the command and result in the game never starting but not sure if OP wanted to prevent that.

Last edited by Bobakanoosh; 05-22-2017 at 13:19.
Bobakanoosh is offline
hpkA
Junior Member
Join Date: Dec 2016
Old 05-22-2017 , 22:57   Re: Team timeout
Reply With Quote #4

Quote:
Originally Posted by Bobakanoosh View Post
beat me to it ;(

Might add that players could easily spam the command and result in the game never starting but not sure if OP wanted to prevent that.

Spam is not possible because each team has a limit of 4 requests per round, and each request has 30 seconds.
When the 4 requests are finished, they can no longer use the command

I tested the plugin and what happens is this: The only spam I get is that you use the command once behind the other it will be showing the message (PrintToChatAll ("\ x02 [TimeOut] \ x04% N \ x03start the Timeout for (T) Team ", client);
Other than this, it worked the way I wanted it to.
Is it possible to block this message to appear once per round?
Thanks guys
hpkA is offline
Bobakanoosh
Senior Member
Join Date: Sep 2015
Location: United States
Old 05-22-2017 , 23:12   Re: Team timeout
Reply With Quote #5

This should work, the cooldown length is defined at the top there.

Code:
#pragma semicolon 1

#include <sourcemod>
#include <cstrike>

#define COMMAND_COOLDOWN 5

int g_iCommandCooldown[MAXPLAYERS+1];

public Plugin:myinfo =
{
	name = "Team Timeout",
	author = "g00gl3",
	description = "Set a team timeout",
	version = "1.0.0"
};

public OnPluginStart()
{

	RegConsoleCmd("sm_tactical", Command_TimeOut, "Start a Team timeout"); 
	
	HookEvent("player_spawn", Event_PlayerSpawn);
	
}

public Action Event_PlayerSpawn(Handle event, const char[] name, bool dontBroadcast) {

	int client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	if(client < 2)
		return Plugin_Continue;
		
	g_iCommandCooldown[client] = 0;
	
	return Plugin_Continue;

}


public Action:Command_TimeOut(client, args)
{
	if(GetTime() - g_iCommandCooldown[client] < COMMAND_COOLDOWN) {
	
		PrintToChat(client, " \x02[TimeOut] That command is on cooldown");
		return Plugin_Handled;
	
	} 


	if(GetClientTeam(client) == CS_TEAM_T)
	{
		ServerCommand("timeout_terrorist_start");
		PrintToChatAll(" \x02[TimeOut] \x04%N \x03start the timeout for (T) Team", client);
		
		g_iCommandCooldown[client] = GetTime();
		
		return Plugin_Handled;
	}
	
	else if(GetClientTeam(client) == CS_TEAM_CT)
	{
		ServerCommand("timeout_ct_start");
		PrintToChatAll(" \x02[TimeOut] \x04%N \x03start the timeout for (CT) Team", client);
		
		g_iCommandCooldown[client] = GetTime();
		
		return Plugin_Handled;
	}

	return Plugin_Continue;
}
Bobakanoosh is offline
hpkA
Junior Member
Join Date: Dec 2016
Old 05-23-2017 , 08:17   Re: Team timeout
Reply With Quote #6

This only blocks on the first command. In the next commands it sends this "PrintToChatAll (" \ x02 [TimeOut] \ x04 \ n \ x03start timeout to (CT) Team "

But no problem, I just removed that sentence and it works perfectly.

Thanks to all, guys.
hpkA is offline
Bobakanoosh
Senior Member
Join Date: Sep 2015
Location: United States
Old 05-23-2017 , 14:24   Re: Team timeout
Reply With Quote #7

It just puts a cooldown on that person to use the command.. if you set the cooldown to say 9999 then that person could only use it once per round (unless it was a very long round)
Bobakanoosh 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 23:27.


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