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

[CS:GO] Kill Command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
helloape12
Junior Member
Join Date: Oct 2013
Old 11-09-2013 , 22:36   [CS:GO] Kill Command
Reply With Quote #1

Hi,

How would I make a command so that the user types '!kill' in chat instead of having to open console and type 'kill'?

I've been trying to research it but I'm not sure how you would link it to the kill command, or what the actual command/event is.

I've seen cmd_kill and the event player_Death but I'm not too sure if those are it.

Here is my silly attempt at making one:

Code:
public OnPluginStart()
{
    RegConsoleCmd("sm_kill", kill);
}

public Action:kill(client, args)
{	
	if(IsClientValid(client))
	{
		  cmd_kill
		  
    }
helloape12 is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 11-10-2013 , 00:28   Re: [CS:GO] Kill Command
Reply With Quote #2

PHP Code:
public OnPluginStart()
{
    
RegConsoleCmd("sm_kill"kill);
}

public 
Action:kill(clientargs)
{
    if (
clientForcePlayerSuicide(client);

__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 11-10-2013 , 04:33   Re: [CS:GO] Kill Command
Reply With Quote #3

I would go for a proper way.
PHP Code:
public OnPluginStart() {

  
AddCommandListener(Command_Say"say");
  
AddCommandListener(Command_Say"say_team");
}


public 
Action:Command_Say(client, const String:command[], argc) {

  
decl String:text[128];
  
GetCmdArgString(textsizeof(text));
  new 
bool:bPublic true;
 
  new 
startidx 0;
  if (
text[0] == '"') {
    
startidx++;
    new 
len strlen(text);
    if (
text[len-1] == '"') {
      
text[len-1] = '\0';
    }
  }
 
  
// Here you can specify any signs you want. # for example
  
if (text[startidx] == '!') {
    
startidx++;
  } else if (
text[startidx] == '/') {
    
startidx++;
    
bPublic false;
  } else {
    return 
Plugin_Continue;
  }

  
// Here you can add any text triggers you want to
  
if (StrEqual(text[startidx], "kill"false)) {
    
// This is the actual action function
    
PerformKill(client);
    if (
bPublic) {
      return 
Plugin_Continue;
    } else {
      return 
Plugin_Handled;
    }
  }

  return 
Plugin_Continue;
}

stock PerformKill(client) {

  if (
IsClientInGame(client) && IsPlayerAlive(client)) {
    
ForcePlayerSuicide(client);
  }

Don't make another console command if you just want a chat trigger.

Last edited by xf117; 11-10-2013 at 04:34.
xf117 is offline
Send a message via ICQ to xf117
hamilton5
Veteran Member
Join Date: Oct 2012
Location: USA
Old 11-10-2013 , 06:49   Re: [CS:GO] Kill Command
Reply With Quote #4

did some one say proper?
https://wiki.alliedmods.net/Commands...#Chat_Triggers
hamilton5 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-10-2013 , 07:49   Re: [CS:GO] Kill Command
Reply With Quote #5

Quote:
Originally Posted by xf117 View Post
I would go for a proper way.
PHP Code:
public OnPluginStart() {

  
AddCommandListener(Command_Say"say");
  
AddCommandListener(Command_Say"say_team");
}


public 
Action:Command_Say(client, const String:command[], argc) {
...

Then why not go to straigth (or do I have misunderstood this forward ?)
OnClientSayCommand_Post

Last edited by Bacardi; 11-10-2013 at 07:50.
Bacardi is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 11-10-2013 , 07:49   Re: [CS:GO] Kill Command
Reply With Quote #6

@hamilton5 That section explains how sourcemod auto creates chat triggers for your own console commands you create. It is considered a bad practice to register a console command just to have a chat trigger.

P.S.
@Bacardi i don't think you can block the message in the Post hook.

Last edited by xf117; 11-10-2013 at 07:51.
xf117 is offline
Send a message via ICQ to xf117
Reply


Thread Tools
Display Modes

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 04:19.


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