Raised This Month: $ Target: $400
 0% 

Invisibility


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 06-29-2010 , 01:10   Invisibility
Reply With Quote #1

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.
Spunky is offline
Send a message via AIM to Spunky
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 06-29-2010 , 02:40   Re: Invisibility
Reply With Quote #2

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( ).
RedRobster is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 06-29-2010 , 02:46   Re: Invisibility
Reply With Quote #3

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.
__________________
I am out of order!
grimvh2 is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 06-29-2010 , 23:30   Re: Invisibility
Reply With Quote #4

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

Last edited by Spunky; 06-30-2010 at 13:02.
Spunky is offline
Send a message via AIM to Spunky
Reply



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 01:14.


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