Raised This Month: $12 Target: $400
 3% 

No Clip - Stuck


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Scherzo
Senior Member
Join Date: Feb 2007
Location: Kwidzyn, Poland
Old 07-26-2009 , 10:52   No Clip - Stuck
Reply With Quote #1

I need to check if player stuck after use 10s NoClip mode and was looking for answer at question: how to check it? I found code of RTD, but in source was checked by run timer,force move and compare last with current origin...too complicated for me.

So started to seach other way and I think found it.

When player can`t move, stuck by other entity his flTimeStepSound go to 0. We have to little delay check function to give time for engine. There is one more situation, which flTimeStepSound is 0 - falling down, so we should check Z axis of velocity too.

Tested with silent footsteps too.

Fakemeta Way
Code:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "NoClip"
#define VERSION "1.0"
#define AUTHOR "R3X"

#define TASK_NOCLIP 14000


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_clcmd("+noclip","cmdStartNoClip");
    register_clcmd("-noclip","cmdStopNoClip");
}
public cmdStartNoClip(id){
    if(is_user_alive(id)){
        set_pev(id, pev_movetype, MOVETYPE_NOCLIP);
    
        new tid=id+TASK_NOCLIP;
        if(task_exists(tid))
            remove_task(tid);
    }
    return PLUGIN_HANDLED;
}
public cmdStopNoClip(id){
    set_pev(id, pev_movetype, MOVETYPE_WALK);
    
    new tid=id+TASK_NOCLIP;
    set_task(1.0, "taskStuck",tid);
    
    return PLUGIN_HANDLED;
}
public taskStuck(id){
    id -= TASK_NOCLIP;
    static velocity[3];
    pev(id, pev_velocity, velocity);
    if(pev(id, pev_flTimeStepSound) == 0 && velocity[2]==0.0){
        new szName[32];
        get_user_name(id, szName, 31);
        client_print(0, print_chat, "%s stuck, so will die :(", szName);
        user_kill(id);
    }
}
Engine Way
Code:
#include <amxmodx>
#include <engine>

#define PLUGIN "NoClip"
#define VERSION "1.0"
#define AUTHOR "R3X"

#define TASK_NOCLIP 14000


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_clcmd("+noclip","cmdStartNoClip");
    register_clcmd("-noclip","cmdStopNoClip");
}
public cmdStartNoClip(id){
    if(is_user_alive(id)){
        entity_set_int(id, EV_INT_movetype, MOVETYPE_NOCLIP);
    
        new tid=id+TASK_NOCLIP;
        if(task_exists(tid))
            remove_task(tid);
    }
    return PLUGIN_HANDLED;
}
public cmdStopNoClip(id){
    entity_set_int(id, EV_INT_movetype, MOVETYPE_WALK);
    
    new tid=id+TASK_NOCLIP;
    set_task(1.0, "taskStuck",tid);
    
    return PLUGIN_HANDLED;
}
public taskStuck(id){
    id -= TASK_NOCLIP;
    static velocity[3];
    entity_get_vector(id, EV_VEC_velocity, velocity);
    if(entity_get_int(id, EV_INT_flTimeStepSound) == 0 && velocity[2]==0.0){
        new szName[32];
        get_user_name(id, szName, 31);
        client_print(0, print_chat, "%s stuck, so will die :(", szName);
        user_kill(id);
    }
}
Scherzo is offline
crazyeffect
Veteran Member
Join Date: Jul 2008
Location: Belgium
Old 07-26-2009 , 11:23   Re: No Clip - Stuck
Reply With Quote #2

Scripting Help Forum...

This is Suggestions/Requests
__________________
crazyeffect is offline
Send a message via MSN to crazyeffect
Scherzo
Senior Member
Join Date: Feb 2007
Location: Kwidzyn, Poland
Old 07-26-2009 , 12:09   Re: No Clip - Stuck
Reply With Quote #3

No, i want show you how to easier check if player stuck.
Scherzo is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 07-26-2009 , 13:01   Re: No Clip - Stuck
Reply With Quote #4

Quote:
Originally Posted by crazyeffect View Post
Scripting Help Forum...

This is Suggestions/Requests
I lol'd. its Code Snippets/Tutorials.
__________________
xPaw is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-26-2009 , 13:42   Re: No Clip - Stuck
Reply With Quote #5

If I understand correctly ... the easiest way would be to check point-contents of the players origin when the no-clip expires.

Here's a little demo; add noclip onto yourself and then say /start in chat and then move in and out of boxes, walls, underground, and high in the sky outside of the maps upper boundary.

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Check if Stuck"
#define VERSION "1.0"
#define AUTHOR "bugsy"

public plugin_init() 
{
    
register_pluginPLUGIN VERSION AUTHOR );
    
register_clcmd"say /start" "DoStart" );
}

public 
DoStartid )
{
    
set_task0.5 "Stuck" id ,_"b" );
}

public 
Stuckid )
{
    static 
FloatfOrigin];
    
pevid pev_origin fOrigin );
    
    if ( 
engfuncEngFunc_PointContents fOrigin ) == CONTENTS_SOLID )
        
client_printid print_chat "Stuck in object" );
    else
        
client_printid print_chat "Can move freely" );

__________________

Last edited by Bugsy; 07-26-2009 at 13:50.
Bugsy is offline
Scherzo
Senior Member
Join Date: Feb 2007
Location: Kwidzyn, Poland
Old 07-26-2009 , 13:53   Re: No Clip - Stuck
Reply With Quote #6

User origin its not whole user entity.
Scherzo is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-26-2009 , 13:56   Re: No Clip - Stuck
Reply With Quote #7

Quote:
Originally Posted by Scherzo View Post
User origin its not whole user entity.
If that's an issue you can use EngFunc_GetBonePosition and check the point-contents of various body parts.

PHP Code:
static FloatfOrigin] , FloatfDummy];
engfuncEngFunc_GetBonePosition id BONE_SPINE1 fOrigin fDummy ); 
Try this:

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Check if Stuck"
#define VERSION "1.0"
#define AUTHOR "bugsy"

/*
#define BONE_SPINE1    3  //Spine
#define BONE_SPINE2    4  //Spine
#define BONE_SPINE3    5  //Spine
#define BONE_SPINE4     6  //Spine
#define BONE_HEAD    8  //Head
#define BONE_L_UPPERARM    11 //Left UpperArm
#define BONE_L_HAND    13 //Left Hand
#define BONE_L_SHOULDER    23 //Left shoulder outside
#define BONE_L_KNEE    40 //Left knee
#define BONE_L_FOOT    41 //Left Foot
#define BONE_R_UPPERARM    26 //Right UpperArm
#define BONE_R_HAND    28 //Right Hand
#define BONE_R_SHOULDER    39 //Right shoulder outside
#define BONE_R_KNEE    46 //Left knee
#define BONE_R_FOOT    47 //Left Foot 
*/

new const g_Bones[] = { 11 13 23 40 41 26 28 39 46 47 };

public 
plugin_init() 
{
    
register_pluginPLUGIN VERSION AUTHOR );
    
register_clcmd"say /start" "DoStart" );
}

public 
DoStartid )
{
    
set_task0.5 "Stuck" id ,_"b" );
}

public 
Stuckid )
{
    static 
FloatfOrigin] , FloatfDummy];
    
    for ( new 
sizeof g_Bones i++ )
    {
            
engfunc(EngFunc_GetBonePositionid g_Bones] , fOrigin fDummy );
            
            if ( 
engfuncEngFunc_PointContents fOrigin ) == CONTENTS_SOLID )
            {
                
client_printid print_chat "Stuck in object" );
                return;
            }
    }
    
    
client_printid print_chat "Can move freely" );

__________________

Last edited by Bugsy; 07-26-2009 at 14:13.
Bugsy is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 07-26-2009 , 14:36   Re: No Clip - Stuck
Reply With Quote #8

what about a tracehull using HULL_HUMAN / HULL_HEAD from pev_origin to pev_origin? idk whether that works but if it would return results it could be checked easily whetehr the player stucks.
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-26-2009 , 15:02   Re: No Clip - Stuck
Reply With Quote #9

My opinion is: this a technique to check if the user is stuck in a way with small resources wasted. Normally, this techniques don't work in every case. This particular one, will not work in players that get stuck when falling or jumping.
__________________
joaquimandrade is offline
Old 07-26-2009, 16:22
Exolent[jNr]
This message has been deleted by Exolent[jNr]. Reason: Wtf -.-
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 07-26-2009 , 16:50   Re: No Clip - Stuck
Reply With Quote #10

Quote:
Originally Posted by SchlumPF* View Post
what about a tracehull using HULL_HUMAN / HULL_HEAD from pev_origin to pev_origin? idk whether that works but if it would return results it could be checked easily whetehr the player stucks.
tested and works

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>

public plugin_init( )
{
    
register_clcmd"say noclip""Cmd_Noclip" );
    
register_clcmd"say test""Cmd_Test" );
}

public 
Cmd_Noclipplr )
{
    
set_user_noclipplrget_user_noclipplr ) ? );
}

public 
Cmd_Testplr )
{
    
client_printplrprint_chat"stuck = %s"is_user_stuckplr ) ? "true" "false" );
}

stock is_user_stuckplr )
{
    new 
Float:origin[3];
    
pevplrpev_originorigin );

    
engfuncEngFunc_TraceHulloriginoriginIGNORE_MONSTERSpevplrpev_flags ) & FL_DUCKING HULL_HEAD HULL_HUMANplr);

    return 
get_tr20TR_StartSolid );

__________________

Last edited by SchlumPF*; 07-26-2009 at 16:54.
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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