AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cant catch landing (https://forums.alliedmods.net/showthread.php?t=163584)

avril-lavigne 07-31-2011 22:01

cant catch landing
 
I have two sounds - jump & landing

I cant get the landing sound to work
Ive tried fakemeta
engine
many many ways/hours to cath FL_onground //

with oldbutton /buttons
with pev .
other ways

pls give some working code to emit_sound on touch the ground

avril-lavigne 08-01-2011 06:18

Re: cant catch landing
 
and one more

how to properly kill task by its ID

eXtrem 08-01-2011 06:21

Re: cant catch landing
 
Quote:

Originally Posted by avril-lavigne (Post 1523233)
and one more

how to properly kill task by its ID

remove_task( id ) ?

avril-lavigne 08-01-2011 06:33

Re: cant catch landing
 
set_task(1.0,"show_hudquad",123,"",0,"b")
return PLUGIN_CONTINUE;

}

public show_hudquad(id) {
set_hudmessage(200, 100, 0, 0.05 , 0.85, 0, 6.0, 8.0, 0.1, 0.1, -1)
show_hudmessage(id," Quad")
}

I know but I have error Host_Error: UserMsg: Not Present on Client 235


public hook_Death()
{
new victim = read_data(2);
if(g_quad_owner == victim)
{
quad_disable
remove_task(123) // kill hud task if the owner is dead and stupid xD
}

return PLUGIN_CONTINUE;
}

Hunter-Digital 08-01-2011 07:11

Re: cant catch landing
 
Use [code] or [php] tags around code.

Quote:

Originally Posted by avril-lavigne (Post 1523249)
I know but I have error Host_Error: UserMsg: Not Present on Client 235

That error is not related to that code.

avril-lavigne 08-01-2011 07:19

Re: cant catch landing
 
yes, probably with ent touch.Ill try again (

what about LANDING SOUND ????
give me some WORKING code
I tried all variants with engine / fakemeta
pev FL_ONGROUND

but sound dont work, it works from cs, but not from my plugin (

Bugsy 08-02-2011 10:46

Re: cant catch landing
 
Not sure what your intentions are or if this is what you're looking for but I figured I would take a stab at it without using prethink (which may be the best way). Are you trying to hook every time a player lands or only if he lands hard and takes damage? If the first, then my code will work 95% of the time. The only downfall is I am able to avoid the sound if I'm standing on a ledge and press a move button only briefly resulting in the player falling off and landing. If you are only looking to hook when falling from a distance and where damage is taken then you can do this easily by hooking FM_EmitSound.

PHP Code:

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

new const Version[] = "0.1";

new const 
g_szLandSound[] = "player/sprayer.wav";

const 
BUTTONS = ( IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT IN_JUMP );
new 
g_OffGround g_LandEntity g_iMaxPlayers;

public 
plugin_init() 
{
    
register_plugin"Hook Landing" Version "bugsy" );
    
register_forwardFM_CmdStart "fw_FMCmdStart" );
    
g_iMaxPlayers get_maxplayers();
}

public 
fw_FMCmdStartid uc_handle seed )
{
    if ( ( 
get_ucuc_handle UC_Buttons ) | pevid pev_oldbuttons ) ) & BUTTONS )
    {
        if ( !( 
pevid pev_flags ) & FL_ONGROUND ) )
        {
            
g_OffGround |= ( << ( id 31 ) );

            if ( !
g_LandEntity )
                
CreateLandEntity();

            
entity_set_floatg_LandEntity EV_FL_nextthink get_gametime() + 0.01 );
        }
    }
}

public 
LandEntityThinkiEntity )
{
    for ( new 
id id <= g_iMaxPlayers id++ )
    {
        if ( 
g_OffGround & ( << ( id 31 ) ) )
        {
            if ( 
pevid pev_flags ) & FL_ONGROUND )
            {
                
emit_soundid CHAN_BODY g_szLandSound VOL_NORM ATTN_NORM PITCH_NORM );
                
                
g_OffGround &= ~( << ( id 31 ) );
                
                if ( !
g_OffGround )
                    break;
            }
        }
    }
    
    if ( 
g_OffGround )
        
entity_set_floatg_LandEntity EV_FL_nextthink get_gametime() + 0.01 );
}

CreateLandEntity()
{
    
g_LandEntity create_entity"info_target" );
    
entity_set_stringg_LandEntity EV_SZ_classname "land_entity" );
    
register_think"land_entity" "LandEntityThink" );    



avril-lavigne 08-02-2011 11:16

Re: cant catch landing
 
thanks bugsy I Know how to play sound on damage/landing.

avril-lavigne 08-02-2011 11:27

Re: cant catch landing
 
Bugsy you are my hero it works exactly as I need ( I have added my jump sound.) thanks!!!!!

jim_yang 08-02-2011 21:22

Re: cant catch landing
 
Code:

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

#define PLUGIN  "Test"
#define AUTHOR  "Jim"
#define VERSION  "1.0"

public plugin_init()
{
  register_plugin(PLUGIN, VERSION, AUTHOR)
}

public client_PostThink(id)
{
  if(is_user_alive(id) && pev(id, pev_flags) & FL_ONGROUND && get_pdata_float(id, 255) > 0)
  {
    client_print(id, print_chat, "landing!");
  }
}

if you want a "former" landing, you should use this, change 0 to 350.0
#define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast.


All times are GMT -4. The time now is 03:26.

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