AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Remove C4 (https://forums.alliedmods.net/showthread.php?t=74436)

DruGzOG 07-18-2008 17:20

Remove C4
 
Does anyone know how to script a plugin to block a c4 from the terrorist? Or if there is a plugin where it restricts the c4 from being planted? Please Help :'(

Exolent[jNr] 07-18-2008 18:22

Re: Remove C4
 
PHP Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
    
register_plugin("Can't Plant C4""0.1""Exolent");
    
register_forward(FM_CmdStart"FwdCmdStart"0);
    
    return 
PLUGIN_CONTINUE;
}

public 
FwdCmdStart(plruc_handleseed)
{
    static 
clipammo;
    if( !
is_user_alive(plr)
    || 
get_user_weapon(plrclipammo) != CSW_C4 )
    {
        return 
FMRES_IGNORED;
    }
    
    new 
buttons get_uc(uc_handleUC_Buttons);
    if( 
buttons&IN_ATTACK )
    {
        
buttons &= ~IN_ATTACK;
        
set_uc(uc_handleUC_Buttonsbuttons);
        
        return 
FMRES_SUPERCEDE;
    }
    
    return 
FMRES_IGNORED;



DruGzOG 08-20-2008 15:23

Re: Remove C4
 
Does this remove the C4?

Exolent[jNr] 08-20-2008 17:23

Re: Remove C4
 
If the terrorist has the c4 out, he cannot plant.

DruGzOG 08-22-2008 09:15

Re: Remove C4
 
Alright, Sweet Thanks +karma

kramesa 01-17-2012 18:03

Re: Remove C4
 
Can add cvar for enable/disable?

Exolent[jNr] 01-18-2012 16:40

Re: Remove C4
 
PHP Code:

#include <amxmodx>
#include <fakemeta>

new bool:gEnabled true;

public 
plugin_init()
{
    
register_plugin("Can't Plant C4""0.1""Exolent");
    
    
register_concmd("c4_enable""CmdEnable"ADMIN_RCON"Allows C4 to be planted");
    
register_concmd("c4_disable""CmdDisable"ADMIN_RCON"Stops C4 from being planted");
    
    
register_forward(FM_CmdStart"FwdCmdStart"0);
}

public 
CmdEnable(idlevelcid)
{
    if(
cmd_access(idlevelcid1))
    {
        
setEnabled(idtrue);
    }
    return 
PLUGIN_HANDLED;
}

public 
CmdDisable(idlevelcid)
{
    if(
cmd_access(idlevelcid1))
    {
        
setEnabled(idfalse);
    }
    return 
PLUGIN_HANDLED;
}

setEnabled(idbool:enabled)
{
    if(
enabled == gEnabled)
    {
        
console_print(id"C4 is already %sabled."enabled "en" "dis");
    }
    else
    {
        
gEnabled enabled;
        
console_print(id"C4 is now %sabled."enabled "en" "dis");
    }
}

public 
FwdCmdStart(plruc_handleseed)
{
    static 
clipammo;
    if( !
gEnabled
    
|| !is_user_alive(plr)
    || 
get_user_weapon(plrclipammo) != CSW_C4 )
    {
        return 
FMRES_IGNORED;
    }
    
    new 
buttons get_uc(uc_handleUC_Buttons);
    if( 
buttons&IN_ATTACK )
    {
        
buttons &= ~IN_ATTACK;
        
set_uc(uc_handleUC_Buttonsbuttons);
        
        return 
FMRES_SUPERCEDE;
    }
    
    return 
FMRES_IGNORED;



Exolent[jNr] 01-20-2012 10:53

Re: Remove C4
 
Quote:

Originally Posted by kramesa (Post 1635331)
Dont works

You realize that it's not a cvar, but a command. Right?

kramesa 01-20-2012 10:57

Re: Remove C4
 
Man, sorry, i used c4_enable for enables plant c4 -.-

thanks.

ConnorMcLeod 01-20-2012 11:08

Re: Remove C4
 
OMG don't hook CmdStart for this lol !!!

Set g_bCanPlantC4 anywhere and under any conditions you want :

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
// #include <cstrike>

#define VERSION "0.0.1"
#define PLUGIN ""

const XO_WEAPON 4

const m_pPlayer 41
const m_flNextPrimaryAttack 46

new bool:g_bCanPlantC4

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_c4""CC4_PrimaryAttack")
}

public 
CC4_PrimaryAttackiC4 )
{
    if( !
g_bCanPlantC4 )
    {
        new 
id get_pdata_cbase(iC4m_pPlayerXO_WEAPON)
        
client_print(idprint_chat"C4 is actually disabled !!")
        
set_pdata_float(iC4m_flNextPrimaryAttack1.0XO_WEAPON)
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED



Exolent[jNr] 01-20-2012 11:18

Re: Remove C4
 
Quote:

Originally Posted by ConnorMcLeod (Post 1635341)
OMG don't hook CmdStart for this lol !!!

Yo, that code is 4 years old. Give me a break, lol.

kramesa 01-20-2012 11:24

Re: Remove C4
 
What is the best? Connor, can you add a cvar for enable/disable?

Exolent[jNr] 01-20-2012 13:18

Re: Remove C4
 
Here is Connor's method with my commands:
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
// #include <cstrike>

#define VERSION "0.0.1"
#define PLUGIN ""

const XO_WEAPON 4

const m_pPlayer 41
const m_flNextPrimaryAttack 46

new bool:g_bCanPlantC4
new HamHook:g_hhC4PrimaryAttack

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
g_hhC4PrimaryAttack RegisterHam(Ham_Weapon_PrimaryAttack"weapon_c4""CC4_PrimaryAttack")
    
    
register_concmd("c4_enable""CmdEnable"ADMIN_RCON"Allows C4 to be planted");
    
register_concmd("c4_disable""CmdDisable"ADMIN_RCON"Stops C4 from being planted");
}

public 
CC4_PrimaryAttackiC4 )
{
    new 
id get_pdata_cbase(iC4m_pPlayerXO_WEAPON)
    
client_print(idprint_chat"C4 is actually disabled !!")
    
set_pdata_float(iC4m_flNextPrimaryAttack1.0XO_WEAPON)
    return 
HAM_SUPERCEDE
}

public 
CmdEnable(idlevelcid)
{
    if(
cmd_access(idlevelcid1))
    {
        
setEnabled(idtrue);
    }
    return 
PLUGIN_HANDLED;
}

public 
CmdDisable(idlevelcid)
{
    if(
cmd_access(idlevelcid1))
    {
        
setEnabled(idfalse);
    }
    return 
PLUGIN_HANDLED;
}

setEnabled(idbool:enabled)
{
    if(
enabled == g_bCanPlantC4)
    {
        
console_print(id"C4 is already %sabled."enabled "en" "dis");
    }
    else
    {
        
g_bCanPlantC4 enabled;
        
        if(
enabledEnableHamForward(g_hhC4PrimaryAttack)
        else        
DisableHamForward(g_hhC4PrimaryAttack)
        
        
console_print(id"C4 is now %sabled."enabled "en" "dis");
    }



briancmccoy 04-20-2013 03:17

Re: Remove C4
 
Include this line #include <amxmisc> in source code else compiling gives error

/tmp/textaKu2rM.sma(36) : error 017: undefined symbol "cmd_access" /tmp/textaKu2rM.sma(45) : error 017: undefined symbol "cmd_access" 2 Errors. Could not locate output file /home/groups/amxmodx/public_html/websc3/textaKu2rM.amx (compile failed).


All times are GMT -4. The time now is 00:43.

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