AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Hook player land on ground! (https://forums.alliedmods.net/showthread.php?t=330910)

Natsheh 02-26-2021 05:46

Hook player land on ground!
 
Does anyone knows how to hook when a player lands on the ground or touch the ground?

Natsheh 02-26-2021 06:46

Re: Hook player land on ground!
 
Here's the code, i hoped for more efficient way but oh well :S

PHP Code:


#include <amxmodx>
#include <orpheu>
#include <orpheu_advanced>
#include <orpheu_memory>
#include <orpheu_stocks>

#define set_flag(%1,%2)            %1 |= (1<<(%2&31))
#define remove_flag(%1,%2)        %1 &= ~(1<<(%2&31))
#define check_flag(%1,%2)        (%1 & (1<<(%2&31)))

new OrpheuStruct:g_ppmove;

public 
plugin_init()
{
    
OrpheuRegisterHookOrpheuGetDLLFunction"pfnPM_Move""PM_Move" ), "OnPM_Move" );
    
OrpheuRegisterHookOrpheuGetFunction("PM_PlayerMove"), "OnPM_PlayerMove");
}

public 
OnPM_MoveOrpheuStruct:ppmoveserver )
{
    
g_ppmove ppmove;
}

public 
OnPM_PlayerMove()
{
    static 
idonground 0;
    
    
id OrpheuGetStructMember(g_ppmove,"player_index") + 1;
    
    
// player on ground.
    
if(OrpheuGetStructMember(g_ppmove,"onground") != -1)
    {
        if(!
check_flag(onground,id))
        {
            
set_flag(onground,id);
            
client_print(idprint_center"you're on ground!");
            
player_on_ground(id);
        }
    }
    else if(
check_flag(onground,id))
    {
        
client_print(idprint_center"you're not on ground!");
        
remove_flag(onground,id);
    }
}

// player landed on the ground, do something.
public player_on_ground(id)
{
    
// blah blah
    
client_print(idprint_chat"You've landed on the ground!");


TESTED and works

here're the signatures for the following functions...

PM_Move


PM_PlayerMove


All times are GMT -4. The time now is 09:34.

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