AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   block event +jump (prevent from jumping) (https://forums.alliedmods.net/showthread.php?t=105471)

Mephisto_aka_Snake 10-04-2009 20:46

block event +jump (prevent from jumping)
 
Hey,
is it possible to hook the +jump event anyhow? I want to set jumping velocities manually and prevent from original jumping, because im aiming to code a charged jump where you have to hold down your jump button and the longer you hold it down, the higher you can jump.
Please help me!
greets

Alka 10-05-2009 03:16

Re: block event +jump (prevent from jumping)
 
Like this? I made it fast and seems to work fine, and i like the idea too.
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Alka"

#define DEFAULT_JUMP_VEL 250.0

#define MAX_JUMP_VEL 600.0

new Float:g_fJumpVel[33] = {DEFAULT_JUMP_VEL, ...};

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_forward(FM_PlayerPreThink"fwd_PlayerPreThink"0);
}

public 
fwd_PlayerPreThink(id)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;
    
    static 
iFlagsiButtoniOldButton;
    
iFlags pev(idpev_flags);
    
iButton pev(idpev_button);
    
iOldButton pev(idpev_oldbuttons);
    
    if(!(
iFlags FL_ONGROUND))
        return 
FMRES_IGNORED;
    
    if((
iButton IN_JUMP) && (iOldButton IN_JUMP))
    {
        static 
Float:vVel[3];
        
pev(idpev_velocityvVel);
        
        if(
g_fJumpVel[id] < MAX_JUMP_VEL)
        {
            
g_fJumpVel[id] += 50.0;
        }
        
vVel[2] = g_fJumpVel[id];
        
set_pev(idpev_velocityvVel);
    }
    else
    {
        
g_fJumpVel[id] = DEFAULT_JUMP_VEL;
    }
    return 
FMRES_IGNORED;



Alucard^ 10-05-2009 06:27

Re: block event +jump (prevent from jumping)
 
Sry for the offtopic but man, rly good idea o.o, and gj for the code alka.

Mephisto_aka_Snake 10-05-2009 09:05

Re: block event +jump (prevent from jumping)
 
well, thx Alka, but i already got, what you've got, your code isnt blocking the first jump, you know? you hold down jump button, but you will jump and when you land it starts charging... but i wanted to avoid that jump before charge... but i dont know how it should work with FMRES_SUPERCEDE or something....
well but actually its not that bad as my code is at the moment... yeah well... just to let you know ^^ it is for a new character in a mod... :P
so if anyone knows how to avoid that first little jump before you can charge pls tell me
thx!


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

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