AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   No HE plugin (https://forums.alliedmods.net/showthread.php?t=56351)

Toster v2.1 06-12-2007 01:30

No HE plugin
 
Can someone tell me what I'm doing wrong? Sometimes it works sometimes not... :(

Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>

#define PLUGIN "Anti HE"
#define VERSION "1.0"
#define AUTHOR "Toster v 2.1"

new wname
new clip,ammo
new file[128]
new buf[128]

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_forward(FM_PlayerPreThink, "Prethink", 0)
    checkmap()
    register_cvar("amx_antihe","1")
}

public Prethink(id)
{
    wname=get_user_weapon(id,clip,ammo)
   
    if(get_cvar_num("amx_antihe")!=0)
    {
      if((pev(id,pev_button)&IN_ATTACK)&&wname==4)
      {
        set_pev(id,pev_button,IN_CANCEL)
      }
    }
}

public checkmap()
{
    if(get_cvar_num("amx_antihe")!=0)
    {
   
        set_cvar_num("amx_antihe",0)
        get_configsdir(file,127)
        format(file[strlen(file)],127-strlen(file),"/antihemaps.txt")
   
        new trash
        new next
        new cur[128]
   
        get_mapname(cur,127)
        while((next = read_file(file,next,buf,127,trash)) != 0)if(equali(cur,buf))set_cvar_num("amx_antihe",1)
    }
}

antihemaps.txt
Code:

cs_deagle5
deagleknivez
fy_pool_day


pRED* 06-12-2007 02:44

Re: No HE plugin
 
You'd probably need to make it something like

set_pev(id,pev_button, pev(id,pev_button) | IN_CANCEL)

Theres another way to do it too ~| IN_CANCEL maybe?

But anyway that's a really inefficient way to block HE throwing. Prethink is called every frame.. so lots.. 60 per second +?

What I'd do is hook the curweapon event (use register_event), this is called on every weapon switch, fire, reload and maybe a few other things.

Check if the current weapon is a HE and then force switch the user to knife or remove the grenade from them (set_user_weapons should work I think).

Toster v2.1 06-12-2007 03:40

Re: No HE plugin
 
I've got it! I had to put register_cvar("amx_antihe","1") before all the evnts!


All times are GMT -4. The time now is 10:32.

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