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

[TF2] Disable kill command Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The_dr
Senior Member
Join Date: Jan 2012
Location: Canada
Old 08-19-2013 , 21:19   [TF2] Disable kill command Help
Reply With Quote #1

I am VERY new to sourcepawn and am making a simple Disable kill plugin.
i would like to have it so admins can bypass this mod and can use the kill/explode commands, plus have a ConVar so you can disable, enable the mod.
Here is what i have so far.
PHP Code:
#pragma semicolon 1

#include <sourcemod>

#define PL_VERSION "0.3.8"

public Plugin:myinfo = {
    
name        "disable_kill",
    
author      "Doktor",
    
description "Disable the Kill and explode command for TF2.",
    
version     PL_VERSION,
    
url         "http://iron.site.nfoservers.com/sourcemod_plugins/disable_kill.zip"
};

public 
OnPluginStart()
{
    
//translation
    
LoadTranslations("disable_kill.phrases");
    
// hooks
    
RegConsoleCmd("kill"cmd_kill);
    
RegConsoleCmd("explode"cmd_explode);
}

public 
Action:cmd_kill(clientargs) {
    
PrintToChat(client"\x04[SourceMod] %t""You are not allowed to kill yourself");
    return 
Plugin_Handled;
}

public 
Action:cmd_explode(clientargs) {
    
PrintToChat(client"\x03[SourceMod] %t""You are not allowed to explode yourself");
    return 
Plugin_Handled;

__________________
iRON Servers

Last edited by The_dr; 08-19-2013 at 22:09. Reason: added help to title
The_dr is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 08-19-2013 , 23:23   Re: [TF2] Disable kill command Help
Reply With Quote #2

Check out CheckCommandAccess and CreateConVar. Also, use AddCommandListener instead of RegConsoleCmd.
__________________
11530 is offline
Eden.Campo
Member
Join Date: Mar 2013
Old 08-20-2013 , 02:01   Re: [TF2] Disable kill command Help
Reply With Quote #3

Code:
#pragma semicolon 1 

#include <sourcemod> 

#define PL_VERSION "0.3.8" 

new Handle:g_IsEnabled = INVALID_HANDLE;

public Plugin:myinfo = { 
	name        = "disable_kill", 
	author      = "Doktor", 
	description = "Disable the Kill and explode command for TF2.", 
	version     = PL_VERSION, 
	url         = "http://iron.site.nfoservers.com/sourcemod_plugins/disable_kill.zip" 
}; 

public OnPluginStart() 
{ 
	//translation 
	LoadTranslations("disable_kill.phrases"); 
	// hooks - AddCommandListener is better then creating a new command called the same
	AddCommandListener(cmd_kill, "kill"); 
	AddCommandListener(cmd_explode, "explode"); 
	
	// Creating a CVar that will decide if this mod is enabled
	g_IsEnabled = CreateConVar("disable_kill_enabled", "1", "Is this mod enabled?", FCVAR_NOTIFY|FCVAR_PLUGIN);
	
	// Executing a CFG called disablekill.cfg
	AutoExecConfig(true, "disablekill");
} 

public Action:cmd_kill(client, const String:command[], args)
{ 
	// Skipping all the process if the mod is disabled
	if(!g_IsEnabled)
	{
		return Plugin_Continue;
	|

	// If the user ISN'T an admin, block the cmd. else? Let him kill himself
	if(GetUserAdmin(client) == INVALID_ADMIN_ID)
	{
		PrintToChat(client, "\x04[SourceMod] %t", "You are not allowed to kill yourself");
		return Plugin_Stop;
	}
	else
	{
		return Plugin_Continue;
	}
} 

public Action:cmd_explode(client, const String:command[], args)
{ 
	// Skipping all the process if the mod is disabled
	if(!g_IsEnabled)
	{
		return Plugin_Continue;
	|

	// If the user ISN'T an admin, block the cmd. else? Let him kill himself
	if(GetUserAdmin(client) == INVALID_ADMIN_ID)
	{
		PrintToChat(client, "\x03[SourceMod] %t", "You are not allowed to explode yourself");
		return Plugin_Stop;
	}
	else
	{
		return Plugin_Continue;
	}
}
Eden.Campo is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-20-2013 , 03:19   Re: [TF2] Disable kill command Help
Reply With Quote #4

use this plugin
Suicide Intercept

Admins who have access to so called command "bypass_suicideintercept", can suicide using commands kill, explode, etc. etc.
__________________
Do not Private Message @me

Last edited by Bacardi; 08-20-2013 at 03:20.
Bacardi is offline
The_dr
Senior Member
Join Date: Jan 2012
Location: Canada
Old 08-20-2013 , 21:24   Re: [TF2] Disable kill command Help
Reply With Quote #5

Quote:
Originally Posted by Eden.Campo View Post
Code:
#pragma semicolon 1 

#include <sourcemod> 

#define PL_VERSION "0.3.8" 

new Handle:g_IsEnabled = INVALID_HANDLE;

public Plugin:myinfo = { 
    name        = "disable_kill", 
    author      = "Doktor", 
    description = "Disable the Kill and explode command for TF2.", 
    version     = PL_VERSION, 
    url         = "http://iron.site.nfoservers.com/sourcemod_plugins/disable_kill.zip" 
}; 

public OnPluginStart() 
{ 
    //translation 
    LoadTranslations("disable_kill.phrases"); 
    // hooks - AddCommandListener is better then creating a new command called the same
    AddCommandListener(cmd_kill, "kill"); 
    AddCommandListener(cmd_explode, "explode"); 
    
    // Creating a CVar that will decide if this mod is enabled
    g_IsEnabled = CreateConVar("disable_kill_enabled", "1", "Is this mod enabled?", FCVAR_NOTIFY|FCVAR_PLUGIN);
    
    // Executing a CFG called disablekill.cfg
    AutoExecConfig(true, "disablekill");
} 

public Action:cmd_kill(client, const String:command[], args)
{ 
    // Skipping all the process if the mod is disabled
    if(!g_IsEnabled)
    {
        return Plugin_Continue;
    |

    // If the user ISN'T an admin, block the cmd. else? Let him kill himself
    if(GetUserAdmin(client) == INVALID_ADMIN_ID)
    {
        PrintToChat(client, "\x04[SourceMod] %t", "You are not allowed to kill yourself");
        return Plugin_Stop;
    }
    else
    {
        return Plugin_Continue;
    }
} 

public Action:cmd_explode(client, const String:command[], args)
{ 
    // Skipping all the process if the mod is disabled
    if(!g_IsEnabled)
    {
        return Plugin_Continue;
    |

    // If the user ISN'T an admin, block the cmd. else? Let him kill himself
    if(GetUserAdmin(client) == INVALID_ADMIN_ID)
    {
        PrintToChat(client, "\x03[SourceMod] %t", "You are not allowed to explode yourself");
        return Plugin_Stop;
    }
    else
    {
        return Plugin_Continue;
    }
}
thanks for the help, not only did you help me with the plugin, you also taught me a little more about sourcepawn. I'll add your name to the thanks on the plugin post as well.
__________________
iRON Servers
The_dr 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 07:33.


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