AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to get fall distance? (https://forums.alliedmods.net/showthread.php?t=308138)

sekac 06-08-2018 07:18

How to get fall distance?
 
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");     



maqi 06-10-2018 14:14

Re: How to get fall distance?
 
Get user origin when it jumps and get the origin on the landing compare origin[2] ( z axis ) in both.

Bugsy 06-10-2018 21:27

Re: How to get fall distance?
 
https://forums.alliedmods.net/showpo...92&postcount=4

sekac 06-11-2018 07:09

Re: How to get fall distance?
 
Quote:

Originally Posted by Bugsy (Post 2596318)

Thank you.


All times are GMT -4. The time now is 04:42.

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