AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block Duck on rotating entitys (https://forums.alliedmods.net/showthread.php?t=106942)

uxMal 10-20-2009 17:24

Block Duck on rotating entitys
 
hey,

i don't want players to duck on entitys like func_rotating, func_door_rotating..

i wrote some code which already works but it just blocks your duck if your on the entity, if you jump and duck in jump and land on the entity in duck you won't stand up but still ducking...

i tried set_pev(id, pev_bInDuck, 0) or client_cmd(id,"-duck") but you can still duck on these entitys if you duck before in air...

heres my code

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>


#define PLUGIN "Deathrun_Anti-Duck-Bug"
#define VERSION "1.0"
#define AUTHOR "ulmax"



//--------------------------------------------------------------------------------------------------

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_forward(FM_PlayerPreThink,"fwThink");
}
//--------------------------------------------------------------------------------------------------
public fwThink(id) {
    
    
    
    if(
is_user_alive(id) && (pev(id,pev_button) & IN_DUCK)) {
        
        if(
pev(id,pev_groundentity) > 32) {
            new 
cname[32];
            
pev(pev(id,pev_groundentity),pev_classname,cname,31);
            
            if(
containi(cname,"rotating") > 0) {
                
set_pev(idpev_oldbuttonspev(idpev_oldbuttons) | IN_DUCK)
                                                        
            }
        }
    }
    
}
//-------------------------------------------------------------------------------------------------- 


Hawk552 10-20-2009 17:27

Re: Block Duck on rotating entitys
 
Try setting pev_buttons with a removed IN_DUCK flag. You could also try hooking FM_CmdStart.

uxMal 10-20-2009 17:41

Re: Block Duck on rotating entitys
 
I've already tried setting pev_button with | IN_DUCK but it didn't work

hooking CmdStart ?
there must be a cleaner way...
the player just has to get up

minimiller 10-20-2009 19:07

Re: Block Duck on rotating entitys
 
would it not be better to hook FM_Touch and check if its a "rotating"

Hawk552 10-20-2009 19:32

Re: Block Duck on rotating entitys
 
Quote:

Originally Posted by minimiller (Post 968048)
would it not be better to hook FM_Touch and check if its a "rotating"

I don't think you understand the problem.

Try hooking Ham_Player_Duck and setting pev_oldbuttons in that. I don't know if that will work, but if not, try setting pev_buttons in that forward too.

ConnorMcLeod 10-21-2009 01:11

Re: Block Duck on rotating entitys
 
Quote:

Originally Posted by Hawk552 (Post 968061)
I don't think you understand the problem.

Try hooking Ham_Player_Duck and setting pev_oldbuttons in that. I don't know if that will work, but if not, try setting pev_buttons in that forward too.

I think problem is that pev vars are not same as pmove vars, also you can't hook PM_Duck.
If your server is on linux you could try orpheu module and try to call PM_Unduck.

uxMal 10-21-2009 04:57

Re: Block Duck on rotating entitys
 
Hmmm just a quick idea , i can't test anything now

how about doaing a traceline to the bottom in PreThink so i can get when the player is in air just above the func_rotating (pev_groundentity only changes when you touch the ent first)
and you force the player to unduck in the air? aka setting bInDuck or sending -duck, buttons and stop all duck commands from then on

minimiller 10-21-2009 05:48

Re: Block Duck on rotating entitys
 
Quote:

Originally Posted by Hawk552 (Post 968061)
I don't think you understand the problem.

My understanding is that he dosent want people to duck on rotating stuff
So i thought it would be easier to hook touch, check if its a rotating and do a client_cmd(id, "wait;-duck") or some shit

Jon 10-21-2009 06:15

Re: Block Duck on rotating entitys
 
Quote:

Originally Posted by ConnorMcLeod (Post 968247)
If your server is on linux you could try orpheu module and try to call PM_Unduck.

//

Quote:

Originally Posted by Hawk552 (Post 968061)
Try hooking Ham_Player_Duck and setting pev_oldbuttons in that.

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

public plugin_init( )
{
    
RegisterHamHam_Player_Duck"player""FwdPlayerDuck" );
}

public 
FwdPlayerDuckiClient )
{
    new 
szClass32 ];
    
pevpeviClientpev_groundentity ), pev_classnameszClass31 );
    
    if( 
equalszClass"func_rotating" ) )
    {
        
set_peviClientpev_oldbuttonspeviClientpev_oldbuttons ) | IN_DUCK );

        
// client_cmd( iClient, "wait;-duck" );
    
}



uxMal 10-21-2009 06:47

Re: Block Duck on rotating entitys
 
Oh wow it works now :)

Thanks to minimiller for client_cmd("WAIT;-duck") ..

The wait was the thing i forgot , now it works properly

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>


#define PLUGIN "Deathrun_Anti-Duck-Bug"
#define VERSION "1.0"
#define AUTHOR "ulmax"

#define OFFSET_DUCKTIME 262
#define LINUXDIFF 5

//--------------------------------------------------------------------------------------------------

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_forward(FM_PlayerPreThink,"fwThink");
}
//--------------------------------------------------------------------------------------------------
public fwThink(id) {
    
    
    
    if(
is_user_alive(id) && (pev(id,pev_button) & IN_DUCK)) {
        
        if(
pev(id,pev_groundentity) > 32) {
            new 
cname[32];
            
pev(pev(id,pev_groundentity),pev_classname,cname,31);
            
            if(
containi(cname,"rotating") > 0) {
                
set_pev(idpev_oldbuttonspev(idpev_oldbuttons) | IN_DUCK)
                
//set_pev(id, pev_button, pev(id, pev_button) | IN_DUCK)
                
                
client_cmd(id,"wait;-duck");
            }
        }
    }
    
}
//-------------------------------------------------------------------------------------------------- 

One thing left any chance to check if they are in duck if they are on the rotating so i do not have to spam -duck ?
i tried making an if statement checking bInDuck, PhysicsFlags, fDuckTime and some other shit but it didn't work ...

Is this bad if it spams -duck so often?


All times are GMT -4. The time now is 17:37.

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