This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

No Clip - Stuck


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 00:13.


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