Thread: Block Kill
View Single Post
freakzoid
Junior Member
Join Date: Jun 2010
Old 07-29-2010 , 17:08   Re: Block Kill
Reply With Quote #5

Hey all, I just read Yak's FAQs on Scripting and found:

Quote:
EDIT: As of version 1.3, there is a better way to hook and block commands that are already registered. Unlike RegConsoleCmd, the new AddCommandListener(CommandListener:callback, const String:command[]="") creates only a lightweight hook for when the command is run, instead of creating a whole new command and slowing down the command dispatch. Thus, you should always use AddCommandListener when possible.
So here is edited version of Block Kill with AddCommandListener:

PHP Code:
#include <sourcemod>

#define BLOCKKILL_VERSION "1.2"
new Handle:blockkill_enabled;

public 
Plugin:myinfo 
{
    
name "Block Kill",
    
author "Xuqe Noia",
    
description "Block's the cvar KILL",
    
version BLOCKKILL_VERSION,
    
url "http://LiquidBR.com"
};

public 
OnPluginStart()
{
    
CreateConVar"blockkill_varsion"BLOCKKILL_VERSION"KillBlock Version"FCVAR_NOTIFY );
    
blockkill_enabled CreateConVar("blockkill_enabled""1""Enable or disable KillBlock; 0 - disabled, 1 - enabled");
    
AddCommandListener(BlockKill"kill");
}

public 
Action:BlockKill(client, const String:command[], argc)
{
    if (
GetConVarInt(blockkill_enabled) == 1)
    {
        
PrintToChat(client"\x04[BlockKill]\x01 The \x05kill\x01 cvar is blocked!");
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;


Greetz
Attached Files
File Type: sp Get Plugin or Get Source (blockkill.sp - 936 views - 811 Bytes)
__________________

freakzoid is offline