AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   NoClip Help, If Stuck In wall After Time You Will Die (https://forums.alliedmods.net/showthread.php?t=95676)

cikjam 06-26-2009 02:13

NoClip Help, If Stuck In wall After Time You Will Die
 
I need help with My noclip block for blockmaker, everything works but I want to make it so if you are stuck in a wall when the noclip time runs out you die.

Code:

actionNoclip(id, bool:OverrideTimer)
{
    new Float:fTime = halflife_time();
   
    if (fTime >= gfNoclipNextUse[id] || OverrideTimer)
    {
        new Float:fTimeout = get_cvar_float("bm_nocliptime");
       
        set_user_noclip(id, 1);
        set_task(fTimeout, "taskNoclipRemove", TASK_NOCLIP + id, "", 0, "a", 1);
       
        //only make player glow blue for noclip if player isn't already stealth
        if (fTime >= gfStealthTimeOut[id])
        {
            set_user_rendering(id, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 16);
        }
       
        //play invincibility sound
        emit_sound(id, CHAN_STATIC, gszInvincibleSound, 1.0, ATTN_NORM, 0, PITCH_NORM);
       
        gfNoclipTimeOut[id] = fTime + fTimeout;
        gfNoclipNextUse[id] = fTime + fTimeout + get_cvar_float("bm_noclipcooldown");
    }
    else
    {
        set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
        show_hudmessage(id, "Wait Time: %.1f", gfNoclipNextUse[id] - fTime);
    }
}


zacky 06-26-2009 03:31

Re: NoClip Help, If Stuck In wall After Time You Will Die
 
Show us the taskNoclipRemove.

cikjam 06-26-2009 04:32

Re: NoClip Help, If Stuck In wall After Time You Will Die
 
Code:

public taskNoclipRemove(id)
{
    id -= TASK_NOCLIP;
   
    //make sure player is alive
    if (is_user_alive(id))
    {
        set_user_noclip(id, 0);
       
        //only set players rendering back to normal if player is not stealth
        if (halflife_time() >= gfStealthTimeOut[id])
        {
            set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 16);
        }
    }
}


Xellath 06-26-2009 06:02

Re: NoClip Help, If Stuck In wall After Time You Will Die
 
PHP Code:

stock bool:is_user_stuck(id)
{
        static 
Float:Origin[3];
        
pev(idpev_originOrigin);
        
engfunc(EngFunc_TraceHullOriginOriginIGNORE_MONSTERSpev(idpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN00);
        if (
get_tr2(0TR_StartSolid))
                return 
true;
 
        return 
false;


In your code:

PHP Code:

if(is_user_stuck(id))
{
    
user_kill(id); // or something similiar.



cikjam 06-26-2009 06:15

Re: NoClip Help, If Stuck In wall After Time You Will Die
 
So where would i put them?
Also , Will this work once the time runs out? I dont want it to kill them when they still got time.

zacky 06-26-2009 06:51

Re: NoClip Help, If Stuck In wall After Time You Will Die
 
Put it in taskNoclipRemove inside the if (is_user_alive(id)) {

cikjam 06-26-2009 06:57

Re: NoClip Help, If Stuck In wall After Time You Will Die
 
I got it to work.
I put the Stock Stuff In front of ActionNoclip and i added the use_kill thing to tasknoclipremove.

I dont think thats the right place where i put the Stock stuff. Where should i put it.

zacky 06-26-2009 08:08

Re: NoClip Help, If Stuck In wall After Time You Will Die
 
i just said where to put it. In taskNoclipRemove inside the if(is_user_alive(id)) {

EDIT: I have noclip block in my bm too and it works fine when i put it there.

EDIT2: I dont have that stock, but try this stock instead:
PHP Code:

stock bool:is_user_stuck(index) {
    new 
Float:g_noclip_origin[3];
    
pev(indexpev_origing_noclip_origin);
    if ( 
trace_hull(g_noclip_originHULL_HUMAN,index) != )
    {
        return 
true;
    }
    return 
false;


and then do as Xellath said:
PHP Code:

if (is_user_stuck(id)) {
      
user_kill(id);



Bugsy 06-26-2009 09:14

Re: NoClip Help, If Stuck In wall After Time You Will Die
 
If that doesn't work you can try using EngFunc_PointContents

cikjam 06-26-2009 23:46

Re: NoClip Help, If Stuck In wall After Time You Will Die
 
I just found 1 problem, When the noclip runs out and im inside a Blockmaker Block, it doesnt kill me, i just stay stuck.

Code:

stock bool:is_user_stuck(id)
{
        static Float:Origin[3];
        pev(id, pev_origin, Origin);
        engfunc(EngFunc_TraceHull, Origin, Origin, IGNORE_MONSTERS, pev(id, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN, 0, 0);
        if (get_tr2(0, TR_StartSolid))
                return true;
 
        return false;
}

Is there anything i need to add?

Zacky does your one get slayed when in block?

EDIT: Tested Zacky's, Its working, So far so good.


All times are GMT -4. The time now is 15:40.

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