View Single Post
BeAfraid
Senior Member
Join Date: Jun 2008
Location: Poland
Old 02-04-2009 , 15:05   Re: [ZP] Extra Item : Invisible || Updated v1.3.6
Reply With Quote #51

Code:
/*
/
/
/                [ZP] Extra Item : Invisible
/                  (ability for Humans and Zombies)
/
/                    by The_Thing
/
/    
/
/    Description :
/    
/            Have You ever wanted that if there are so many zombies around You and then You can't escape from them? 
/            Now You can just buy this ability and You will be invisible untill You will be dead.
/            Same for zombies. If there are so many Humans around You and can't hide from them then now You can, just buy this ability.
/
/
/
/    Cvars :
/
/            zp_invisible <1|0>         - Default is 1
/            zp_invisible_cost "55"         - How much this ability will cost to You 
/            zp_invisble_amount "55"        - Amount of invisible
/            zp_invisible_long "15.0"    - How long you will have invisibility
/
/
/    Command :
/
/            say /invis to buy invisibility or say it in team chat, 
/            say_team /invis
/
/
/
/    Credits :
/
/            Antibots - For little helping
/
/
/
/    Changelog :
/
/            19/10/2008 - v1.0 - First release
/            19/10/2008 - v1.1 - fixed invisibility and removed unnecessary cvar.
/            19/10/2008 - v1.1.1 - changed to lower render that at least someone could notice invisible person.
/            19/10/2008 - v1.1.2 - changed plugin name
/            19/10/2008 - v1.2 - removed unnecessary code and fun module, added some new one and using fakemeta instead. (Thanks for Antibots)
/            19/10/2008 - v1.2.1 - changed render stuff
/            24/10/2008 - v1.3 - rewrited plugin, added some cvars and commands.
/            25/10/2008 - v1.3.1 - fixed small typo. (Thanks to Mlk27)
/            22/11/2008 - v1.3.2 - added cvar for invisible amount
/            04/12/2008 - v1.3.4 - fixed invisible was working all the time, added cvar for after how long time invisibility will end.
/            05/12/2008 - v1.3.6 - corrected chat messages, added message when invisibility are over, changed glow shell cuz that was possibly for player glowing.
/
*/    

#include <amxmodx>
#include <fakemeta>
#include <zombieplague>

#define PLUGIN "[ZP] Extra Item : Invisible"
#define VERSION "1.3.6"
#define AUTHOR "The_Thing"


new g_item_name[] = { "Invisible" }
new g_itemid_invisible, invisible_toggle, invisible_amount, invisible_cost, invisible_long
new bool:g_hasInvisible[33]

public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)

    invisible_toggle = register_cvar("zp_invisible", "1")
    invisible_cost = register_cvar("zp_invisible_cost", "55")
    invisible_amount = register_cvar("zp_invisble_amount", "55")
    invisible_long = register_cvar("zp_invisible_long", "15.0")
    
    register_clcmd("say /invis", "buy_invisible")
    register_clcmd("say_team /invis", "buy_invisible")
    
    register_event("DeathMsg", "Death", "a")
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
    
    g_itemid_invisible = zp_register_extra_item(g_item_name, get_pcvar_num(invisible_cost), ZP_TEAM_HUMAN & ZP_TEAM_ZOMBIE)
}

public client_connect(id)
{
    g_hasInvisible[id] = false
    fm_set_rendering(id, kRenderFxNone, 0,0,0,kRenderNormal, 255)
}

public client_disconnect(id)
{
    g_hasInvisible[id] = false
    fm_set_rendering(id, kRenderFxNone, 0,0,0,kRenderNormal, 255)
}

public Death()
{
    g_hasInvisible[read_data(2)] = false
}

public event_round_start()
{
    for (new i = 1; i <= 32; i++)
    {
        g_hasInvisible[i] = false
        fm_set_rendering(i, kRenderFxNone, 0,0,0,kRenderNormal, 255)
    }

}

public zp_extra_item_selected(player, itemid)
{
    if (itemid == g_itemid_invisible)
    {
        g_hasInvisible[player] = true
        
        fm_set_rendering(player,kRenderFxGlowShell,0,0,0,kRenderTransAlpha, get_pcvar_num(invisible_amount))
        set_task(get_pcvar_float(invisible_long), "invisible_over", player)
        client_print(player, print_chat, "[ZP] You are now invisible, have fun to hunt.")
    }
}

public buy_invisible(id)
{
    if ( get_pcvar_num(invisible_toggle) == 0 )
    {
        client_print(id, print_chat, "[ZP] Invisibility are disabled.")
        return PLUGIN_HANDLED
    }
    
    if ( is_user_alive(id) && zp_get_user_zombie(id) )
    {
        client_print(id, print_chat, "[ZP] You have bought invisible ability.")
        return PLUGIN_CONTINUE
    }
    
    if ( !is_user_alive(id) )
    {
        client_print(id, print_chat, "[ZP] You are DEAD, you can't buy anything.")
        return PLUGIN_HANDLED
    }
    
    if ( g_hasInvisible[id] )
    {
        client_print(id, print_chat, "[ZP] You already bought this ability")
        return PLUGIN_HANDLED
    }
    
    new money = zp_get_user_ammo_packs(id)
    
    if ( money < get_pcvar_num(invisible_cost) )
    {
        client_print(id, print_chat, "[ZP] You don't have enough ammo packs to buy this ability")
        return PLUGIN_HANDLED
    }
    
    g_hasInvisible[id] = true
    
    fm_set_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha, get_pcvar_num(invisible_amount))
    set_task(get_pcvar_float(invisible_long), "invisible_over", id)
    client_print(id, print_chat, "[ZP] You are now invisible, have fun to hunt.")
    
    zp_set_user_ammo_packs(id, money - get_pcvar_num(invisible_cost))
    
    return PLUGIN_HANDLED
}

public invisible_over(id)
{
    g_hasInvisible[id] = false
    fm_set_rendering(id, kRenderFxNone, 0,0,0,kRenderNormal, 255)
    client_print(id, print_chat, "[ZP] Invisibility are over...")
}

stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) 
{
    new Float:RenderColor[3];
    RenderColor[0] = float(r);
    RenderColor[1] = float(g);
    RenderColor[2] = float(b);

    set_pev(entity, pev_renderfx, fx);
    set_pev(entity, pev_rendercolor, RenderColor);
    set_pev(entity, pev_rendermode, render);
    set_pev(entity, pev_renderamt, float(amount));

    return 1;
}
Here you are.
Attached Files
File Type: sma Get Plugin or Get Source (zp_extra_invisible.sma - 658 views - 5.4 KB)
BeAfraid is offline