AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CS:GO] Kill Command (https://forums.alliedmods.net/showthread.php?t=229563)

helloape12 11-09-2013 22:36

[CS:GO] Kill Command
 
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
                 
    }


MasterOfTheXP 11-10-2013 00:28

Re: [CS:GO] Kill Command
 
PHP Code:

public OnPluginStart()
{
    
RegConsoleCmd("sm_kill"kill);
}

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



xf117 11-10-2013 04:33

Re: [CS:GO] Kill Command
 
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.

hamilton5 11-10-2013 06:49

Re: [CS:GO] Kill Command
 
did some one say proper?
https://wiki.alliedmods.net/Commands...#Chat_Triggers

Bacardi 11-10-2013 07:49

Re: [CS:GO] Kill Command
 
Quote:

Originally Posted by xf117 (Post 2059070)
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

xf117 11-10-2013 07:49

Re: [CS:GO] Kill Command
 
@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.


All times are GMT -4. The time now is 04:15.

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