AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with Silencing Footsteps with FM (https://forums.alliedmods.net/showthread.php?t=83708)

Mlk27 01-13-2009 23:22

Problem with Silencing Footsteps with FM
 
i dont know what is wrong. when players join they can't hear their footsteps when they are walking until they make a jump.

Code:

#include <amxmodx>
#include <fakemeta>

new bool:g_footstep_set[33] = false;
new g_MaxPlayers

public plugin_init()
{
        register_clcmd("say /off_footsteps", "footsteps")

        register_event("DeathMsg", "eDeathMsg", "a")
        register_event("HLTV", "eNewRound", "a", "1=0", "2=0");
       
        register_forward(FM_PlayerPreThink, "fw_prethink")

        g_MaxPlayers = get_maxplayers()
}

public client_putinserver(id)
{
        g_footstep_set[id] = false;
        fm_set_user_footsteps(id, false)
}

public client_disconnect(id)
{
        g_footstep_set[id] = false;
        fm_set_user_footsteps(id, false)
}

public eDeathMsg()
{
        new id = read_data(2)

        fm_set_user_footsteps(id, false)
}

public eNewRound()
{
        for(new id; id <= g_MaxPlayers; id++)
        {
                g_footstep_set[id] = false;
                fm_set_user_footsteps(id, false)
        }
}

public fw_prethink(id)
{
    if(g_footstep_set[id])
        set_pev(id, pev_flTimeStepSound, 999);
}

public footsteps(id)
{
        fm_set_user_footsteps(id, true)
        client_print(id, print_chat, "Your footsteps are silenced.")
}

stock fm_set_user_footsteps(id, bool:set = true)
{
        set_pev(id, pev_flTimeStepSound, set ? 999.0 : 400.0)
        g_footstep_set[id] = set;
       
        return 1;
}


Dores 01-14-2009 00:00

Re: Problem with Silencing Footsteps with FM
 
Code:
#include <amxmodx> #include <fakemeta> #define VERSION "1.0" public plugin_init() {     register_plugin("No Footsteps", VERSION, "Dores");         register_forward(FM_PlayerPreThink, "Forward_PreThink"); } public Forward_PreThink(id) {     if(is_user_alive(id))     {         set_pev(id, pev_flTimeStepSound, 999999.0);     }         return FMRES_HANDLED; }

Mlk27 01-14-2009 00:20

Re: Problem with Silencing Footsteps with FM
 
so to enable footsteps back, use pev_flTimeStepSound 400.0 ?

aah never mind. i've just figured out that i need to make a boolean cvar in prethink to enable/disable that set_pev

thanks anyway!

+k

zwfgdlc 01-14-2009 00:55

Re: Problem with Silencing Footsteps with FM
 
try this.not tested.
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN_NAME    "No Footsteps"
#define PLUGIN_VERSION    "1.0"
#define PLUGIN_AUTHOR    "zwfgdlc"

public plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
registerham(Ham_Spawn,"player","fw_PlayerSpanw",1);
}

public 
fw_PlayerSpanw_Spanw(id)
{
    if(!
is_user_alive(id)) return HAM_IGNORED;
    
    
set_pev(id,pev_flags,pev(id,pev_flags)|FL_DUCKING);
    
    return 
HAM_HANDLED;



ConnorMcLeod 01-14-2009 01:00

Re: Problem with Silencing Footsteps with FM
 
Quote:

Originally Posted by zwfgdlc (Post 743791)
try this.not tested.
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN_NAME    "No Footsteps"
#define PLUGIN_VERSION    "1.0"
#define PLUGIN_AUTHOR    "zwfgdlc"

public plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
registerham(Ham_Spawn,"player","fw_PlayerSpanw",1);
}

public 
fw_PlayerSpanw_Spanw(id)
{
    if(!
is_user_alive(id)) return HAM_IGNORED;
    
    
set_pev(id,pev_flags,pev(id,pev_flags)|FL_DUCKING);
    
    return 
HAM_HANDLED;



Hum, this will have effects during 1 frame...

Mlk27 01-14-2009 01:04

Re: Problem with Silencing Footsteps with FM
 
actually i figured this..

Code:

#include <amxmodx>
#include <fakemeta>

new bool:g_footstep_set[33]
new g_MaxPlayers

public plugin_init()
{
        register_clcmd("say /off_footsteps", "Cmd_OffFootSteps")
        register_clcmd("say /on_footsteps", "Cmd_OnFootSteps")

        register_event("DeathMsg", "eDeathMsg", "a")
        register_event("HLTV", "eNewRound", "a", "1=0", "2=0");
       
        register_forward(FM_PlayerPreThink, "FM_PlayerPreThink")

        g_MaxPlayers = get_maxplayers()
}

public client_putinserver(id)
{
        g_footstep_set[id] = false;
}

public client_disconnect(id)
{
        g_footstep_set[id] = false
}

public eDeathMsg()
{
        new id = read_data(2)
       
        g_footstep_set[id] = false
}

public eNewRound()
{
        for(new id; id <= g_MaxPlayers; id++)
        {
                g_footstep_set[id] = false
        }
}

public FM_PlayerPreThink(id)
{
    if(g_footstep_set[id])
        set_pev(id, pev_flTimeStepSound, 999);
}

public Cmd_OffFootSteps(id)
{
        g_footstep_set[id] = true
        client_print(id, print_chat, "Your footsteps are silenced.")
}

public Cmd_OnFootSteps(id)
{
        g_footstep_set[id] = false
        client_print(id, print_chat, "Your footsteps are not silenced.")
}


ConnorMcLeod 01-14-2009 01:18

Re: Problem with Silencing Footsteps with FM
 
I think you're wrong here :

Code:

public FM_PlayerPreThink(id)
{
    if(g_footstep_set[id])
        set_pev(id, pev_flTimeStepSound, 999);
}

Should be 999.0 or 999.9 whatever but a float.

I would do :

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define MAX_PLAYERS    32

new bool:g_bNoFootSteps[MAX_PLAYERS+1]
new 
bool:g_bAlive[MAX_PLAYERS+1]

public 
plugin_init()
{
    
RegisterHam(Ham_Spawn"player""Player_Spawn"1)
    
RegisterHam(Ham_Killed"player""Player_Killed"1)
    
RegisterHam(Ham_Player_PreThink"player""Player_PreThink")

    
register_clcmd("say /footsteps""Cmd_FootSteps")
}

public 
client_putinserver(id)
{
    
g_bNoFootSteps[id] = false
}

public 
Player_Spawn(id)
{
    
g_bAlive[id] = bool:is_user_alive[id]
    
//g_bNoFootSteps[id] = false
}

public 
Player_Killed(id)
{
    
g_bAlive[id] = bool:is_user_alive[id]
}

public 
Player_PreThink(id
{
    if(
g_bAlive[id] && g_bNoFootSteps[id])
        
set_pev(idpev_flTimeStepSound999.0)
}

public 
Cmd_FootSteps(id)
{
    
g_bNoFootSteps[id] = !g_bNoFootSteps[id]
    
client_print(idprint_chat"Your footsteps are %ssilenced."g_bNoFootSteps[id] ? "" "not ")



Mlk27 01-14-2009 01:59

Re: Problem with Silencing Footsteps with FM
 
oh nice..

what's the different with FM prethink with ham prethink?

ConnorMcLeod 01-14-2009 06:32

Re: Problem with Silencing Footsteps with FM
 
Quote:

Originally Posted by Mlk27 (Post 743811)
what's the different with FM prethink with ham prethink?

I think no differences, as with engine forward client_PreThink


All times are GMT -4. The time now is 01:45.

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