AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Jump direction problem , going elsewhere =/ (https://forums.alliedmods.net/showthread.php?t=89091)

dstopgunner 04-02-2009 06:24

Jump direction problem , going elsewhere =/
 
Hello all please solve my problem.
Im trying to make pple jump bigger & longer jumps by pressing the normal jump key (spacebar). I need to to be Higher and longer , not just higher , not just longer alone , to the direction where the player is aiming (crosshair).

Serached and found people only making higherjumps or giving longjump module , I dont want longjump module =/

Using this code I jump higher and longer but not in the direction of where my crosshair is , pls point out to me my errors.

PHP Code:

#include <amxmodx>
#include <engine>
#include <fakemeta>
 
public plugin_init()
{
register_plugin("Hugejump","1.0","DS_ToP_GunNeR")
register_forward(FM_PlayerPreThink,"FM_PreThink")
}
public 
FM_PreThink(id)
{
if((
pev(id,pev_button) & IN_JUMP) && (pev(id,pev_flags) & FL_ONGROUND))
{
if(!(
pev(id,pev_oldbuttons) & IN_JUMP))
{
new 
Floatvelocity[3]
new 
Floatorigin[3]
velocity_by_aim(id800origin)
 
velocity[0] += origin[0] + 1000
velocity
[1] += origin[1] + 1000
velocity
[2] += origin[2] + 500
entity_set_vector
(id,EV_VEC_velocity,velocity)
return 
PLUGIN_HANDLED

}
return 
PLUGIN_HANDLED



Exolent[jNr] 04-02-2009 13:52

Re: Jump direction problem , going elsewhere =/
 
PHP Code:

#include <amxmodx>
#include <fakemeta>
 
public plugin_init()
{
    
register_plugin("Hugejump","1.0","DS_ToP_GunNeR")
    
register_forward(FM_PlayerPreThink,"FM_PreThink")
}
public 
FM_PreThink(id)
{
    if((
pev(id,pev_button) & IN_JUMP) && (pev(id,pev_flags) & FL_ONGROUND))
    {
        if(!(
pev(id,pev_oldbuttons) & IN_JUMP))
        {
            new 
Floatvelocity[3]
            
velocity_by_aim(id800velocity)
            
set_pev(id,pev_velocity,velocity)
        } 
    }



SchlumPF* 04-02-2009 15:12

Re: Jump direction problem , going elsewhere =/
 
also, use fm_cmdstart instead of fm_prethink. using cmdstart will save a lot performance.

dstopgunner 04-03-2009 04:49

Re: Jump direction problem , going elsewhere =/
 
Quote:

also, use fm_cmdstart instead of fm_prethink. using cmdstart will save a lot performance.
So you mean..
PHP Code:

#include <amxmodx> 
#include <fakemeta> 
  
public plugin_init() 

    
register_plugin("Hugejump","1.0","DS_ToP_GunNeR"
    
register_forward(FM_PlayerPreThink,"FM_Cmdstart"

public 
FM_Cmdstart(id

    if((
pev(id,pev_button) & IN_JUMP) && (pev(id,pev_flags) & FL_ONGROUND)) 
    { 
        if(!(
pev(id,pev_oldbuttons) & IN_JUMP)) 
        { 
            new 
Floatvelocity[3
            
velocity_by_aim(id800velocity
            
set_pev(id,pev_velocity,velocity
        }  
    } 


???

Dores 04-03-2009 05:01

Re: Jump direction problem , going elsewhere =/
 
Like this.

PHP Code:

#include <amxmodx> 
#include <fakemeta> 
  
public plugin_init() 

    
register_plugin("Hugejump","1.0","DS_ToP_GunNeR"
    
register_forward(FM_CmdStart,"Forward_CmdStart"

public 
Forward_CmdStart(iduc_handleseed

    static 
ButtonoldButton;
    
Button get_uc(uc_handleUC_Buttons);
    
oldButton pev(idpev_oldbuttons);
    
    if(
Button IN_JUMP && !(oldButton IN_JUMP) && pev(id,pev_flags) & FL_ONGROUND
    {
        new 
Floatvelocity[3];
        
velocity_by_aim(id800velocity);
        
set_pev(id,pev_velocity,velocity);
    } 



SnoW 04-03-2009 09:05

Re: Jump direction problem , going elsewhere =/
 
Quote:

Originally Posted by Dores (Post 796054)
PHP Code:

&& !(oldButton IN_JUMP


Why? :o

SchlumPF* 04-03-2009 10:40

Re: Jump direction problem , going elsewhere =/
 
first of all look at dores code to know how FM_CmdStart works (get_uc and not pev). you just changed your forwards name although you were still using FM_PlayerPreThink.

UC_Buttons & IN_JUMP or pev_button & IN_JUMP will be true for more than a single frame which means you will accelerate the player faster than you want him to be. for this you can easily use !( pev_oldbuttons & IN_JUMP ).

example:
1st frame - you jump - pev_button & IN_JUMP && !( pev_oldbuttons & IN_JUMP ) - you are in air
2nd frame - your in air and still pressing +jump - pev_button & IN_JUMP && pev_oldbuttons & IN_JUMP
3rd frame - you release jump - !( pev_button & IN_JUMP ) && pev_oldbuttons & IN_JUMP
4th frame - still in air - !( pev_button & IN_JUMP ) && !( pev_oldbuttons & IN_JUMP )
...
~70th frame - you land - !( pev_button & IN_JUMP ) && !( pev_oldbuttons & IN_JUMP )


All times are GMT -4. The time now is 02:19.

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