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

How to get fall distance?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sekac
Senior Member
Join Date: Nov 2016
Old 06-08-2018 , 07:18   How to get fall distance?
Reply With Quote #1

So I have this plugin but I want the landing sound to play only if the player falls from a place higher than 100 units. How would I do that?

PHP Code:
#include <amxmodx> 
#include <fakemeta> 
#include <engine> 
#include <csgo>

new snd_land[][] =  {"misc/land1.wav""misc/land2.wav""misc/land3.wav""misc/land4.wav"
new 
g_OffGroundg_LandEntityg_iMaxPlayersFloat:g_LandedTimer[33];

const 
BUTTONS = (IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT IN_JUMP);

public 
plugin_init()  

    
register_plugin("Hook Landing""0.1""bugsy"); 
    
register_forward(FM_CmdStart"fw_FMCmdStart"); 
    
g_iMaxPlayers get_maxplayers(); 


public 
plugin_precache() { 
    static 

    
for(0sizeof snd_landi++) 
        
precache_sound(snd_land[i]) 


public 
fw_FMCmdStart(iduc_handleseed

    if ((
get_uc(uc_handleUC_Buttons) | pev(idpev_oldbuttons)) & BUTTONS
    { 
        if (!(
pev(idpev_flags) & FL_ONGROUND)) 
        {            
            
g_OffGround |= (<< (id 31)); 
            
            if (!
g_LandEntity)
                
CreateLandEntity();
            
            
entity_set_float(g_LandEntityEV_FL_nextthinkget_gametime() + 0.01); 
        }                
    } 


public 
LandEntityThink(iEntity

    for (new 
id 1id <= g_iMaxPlayersid++) 
    { 
        if (
g_OffGround & (<< (id 31))) 
        { 
            if (
pev(idpev_flags) & FL_ONGROUND
            { 
                if(
g_LandedTimer[id] < get_gametime()) 
                { 
                    
g_LandedTimer[id] = get_gametime() + 2.2;
                    if(!
aiming_good(id))
                        
emit_sound(idCHAN_BODYsnd_land[random_num(0sizeof snd_land 1)], VOL_NORMATTN_NORM0PITCH_NORM);
                } 
                
                
g_OffGround &= ~(<< (id 31)); 
                
                if (!
g_OffGround
                    break; 
            } 
        } 
    } 
    
    if (
g_OffGround
        
entity_set_float(g_LandEntityEV_FL_nextthinkget_gametime() + 0.01); 


CreateLandEntity() 

    
g_LandEntity create_entity("info_target"); 
    
entity_set_string(g_LandEntityEV_SZ_classname"land_entity"); 
    
register_think("land_entity""LandEntityThink");     

sekac is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-10-2018 , 14:14   Re: How to get fall distance?
Reply With Quote #2

Get user origin when it jumps and get the origin on the landing compare origin[2] ( z axis ) in both.
maqi is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-10-2018 , 21:27   Re: How to get fall distance?
Reply With Quote #3

https://forums.alliedmods.net/showpo...92&postcount=4
__________________
Bugsy is offline
sekac
Senior Member
Join Date: Nov 2016
Old 06-11-2018 , 07:09   Re: How to get fall distance?
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
Thank you.
sekac 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 06:19.


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