AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Invisibility (https://forums.alliedmods.net/showthread.php?t=130913)

Spunky 06-29-2010 01:10

Invisibility
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <tsfun>

new bool:g_bCloakEnabled[33]
new 
g_iLastRender[33]

public 
plugin_init()
{
    
register_plugin("Shadow Cloak""1.0""Spunky")

    
register_clcmd("say /cloak""cmd_cloak")
}

public 
client_disconnect(id)
{
    
g_bCloakEnabled[id] = false
    g_iLastRender
[id] = 0
}

public 
client_PostThink(id)
{
    if (!
is_user_alive(id))
        return 
PLUGIN_CONTINUE

    
else if (!g_bCloakEnabled[id])
        return 
PLUGIN_CONTINUE

    
static Float:fpVelocity[3]
    
entity_get_vector(idEV_VEC_velocityfpVelocity)

    new 
Float:fpSpeed fpVelocity[0] + fpVelocity[1] + fpVelocity[2]
    new 
iModifier fpSpeed != 0.0 : -1
    
new Float:fpRenderAmount float((g_iLastRender[id] = clamp(g_iLastRender[id] + iModifier0255)) + 50)
    static 
iDummy
    
new iWeapon ts_getuserwpn(idiDummyiDummyiDummyiDummy)

    switch (
iWeapon)
    {
        case 
TSW_KATANATSW_KUNG_FUTSW_CKNIFETSW_SKNIFETSW_TKNIFE:
            
fpRenderAmount -= 50.0
    
}

    
entity_set_int(idEV_INT_renderfxkRenderFxGlowShell)
    
entity_set_vector(idEV_VEC_rendercolorFloat:{0.00.00.0})
    
entity_set_int(idEV_INT_rendermodekRenderTransAlpha)
    
entity_set_float(idEV_FL_renderamtfpRenderAmount)

    return 
PLUGIN_CONTINUE
}

public 
cmd_cloak(id)
{
    if (!
is_user_alive(id))
        return 
PLUGIN_HANDLED

    
else if (!g_bCloakEnabled[id])
    {
        
g_bCloakEnabled[id] = true
        g_iLastRender
[id] = 0

        client_print
(idprint_chat"Cloak enabled.")
    }

    else
    {
        
g_bCloakEnabled[id] = false

        client_print
(idprint_chat"Cloak disabled.")
    }

    return 
PLUGIN_HANDLED


This doesn't seem to work but I can't for the life of me figure out why. It should work absolutely fine. I can't see anything wrong with it. When you enable the cloak, they're supposed to slowly fade out for as long as they're standing still. When they move, they fade in. I know it's been done before (and not much differently than this) but I want to know why this won't work.

And if you're wondering, yes, the code is mostly Hawk552's.

RedRobster 06-29-2010 02:40

Re: Invisibility
 
Try using set_user_rendering( ), although, that looks as if this might be the method that is used to do set_user_rendering( ) or fm_set_user_rendering( ).

grimvh2 06-29-2010 02:46

Re: Invisibility
 
Some things look really weird, I also have this, take a look at this :

PHP Code:

public client_PreThink(id// engine
{
        if(
buttons IN_MOVELEFT || buttons IN_MOVERIGHT || buttons IN_FORWARD || buttons IN_BACK)
        {
            if(
Invisible[id])
            {
                
RemoveInvisible(id)
            }
        }
        else
        {
            if(
Invisible[id] != && !aSetInvisible[id])
            {
                
aSetInvisible[id]++
                
set_task(2.0"SetInvisible"id)
            }
        }
}

public 
RemoveInvisible(id)
{
    
set_user_rendering(id)
    
Invisible[id]=0
}

public 
SetInvisible(id)
{
    if(
Invisible[id] < 5)
        
Invisible[id]++
    
    
aSetInvisible[id]=0
    
    
switch(Invisible[id])
    {
        case 
1:set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha200)
        case 
2:set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha150)
        case 
3:set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha100)
        case 
4:set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha50)
        case 
5:set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha10)
    }


This can probally be done way better, but it does the trick.

Spunky 06-29-2010 23:30

Re: Invisibility
 
PHP Code:

public client_PostThink(id)
{
    if (!
is_user_alive(id))
        return 
PLUGIN_CONTINUE

    
else if (!g_bCloakEnabled[id])
        return 
PLUGIN_CONTINUE

    
static Float:fpVelocity[3]
    
entity_get_vector(idEV_VEC_velocityfpVelocity)

    new 
Float:fpSpeed fpVelocity[0] * fpVelocity[0] + fpVelocity[1] * fpVelocity[1] - 400.0

    
if (entity_get_int(idEV_INT_button) & IN_DUCK)
        
fpSpeed -= 600.0

    g_iLastRender
[id] = clamp(g_iLastRender[id] + floatround(fpSpeed 50.0), 0255)

    
entity_set_int(idEV_INT_renderfxkRenderFxNone)
    
entity_set_vector(idEV_VEC_rendercolorFloat:{0.00.00.0})
    
entity_set_int(idEV_INT_rendermodekRenderTransAlpha)
    
entity_set_float(idEV_FL_renderamtfloat(g_iLastRender[id]))

    return 
PLUGIN_CONTINUE


Ok, this code works absolutely fine in Counter-Strike, but not in The Specialists. Whatever the problem is, it's TS-specific. I have no idea why though. Any ideas?

Edit: It's working now, for no explainable reason. I haven't changed ANYTHING about it. O_o


All times are GMT -4. The time now is 14:42.

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