Raised This Month: $ Target: $400
 0% 

AddToFullPack


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 05-09-2013 , 05:35   AddToFullPack
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <xs>

#define PLUGIN "[ZP] Addon: Infect-Effect"
#define VERSION "1.0"
#define AUTHOR "Dias"

new g_effect_id[33], g_had_effect[33]
new const 
effect_model[] = "sprites/infect-effect.spr"

new cvar_scalecvar_showtimecvar_lightlevel

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn"player""fw_spawn_post"1)
    
register_forward(FM_AddToFullPack"fw_WhatTheFuck_Post"1)
    
    
cvar_scale ryegister_cvar("zp_in-ef_scale""0.035")
    
cvar_showtime register_cvar("zp_in-ef_showtime""2.0")
    
cvar_lightlevel register_cvar("zp_in-ef_lightlevel""100.0")
}

public 
plugin_precache()
{
    
precache_model(effect_model)
}

public 
fw_spawn_post(id)
{
    if(
g_had_effect[id])
        
remove_effect(id)
}

public 
zp_user_infected_post(idattacker)
{
    if(
is_user_alive(attacker))
    {
        
show_effect(id)
    }
}

public 
show_effect(id)
{
    
g_effect_id[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"env_sprite"))
    
    if (!
pev_valid(g_effect_id[id]))
        return
    
    
g_had_effect[id] = 1
    
    set_pev
(g_effect_id[id], pev_solidSOLID_NOT)
    
set_pev(g_effect_id[id], pev_movetypeMOVETYPE_NONE)

    
engfunc(EngFunc_SetModelg_effect_id[id], effect_model)
    
    
set_pev(g_effect_id[id], pev_rendermodekRenderTransAlpha)
    
set_pev(g_effect_id[id], pev_renderamt0.0)
    
set_pev(g_effect_id[id], pev_ownerid)
    
set_pev(g_effect_id[id], pev_scaleget_pcvar_float(cvar_scale))
    
set_pev(g_effect_id[id], pev_light_levelget_pcvar_float(cvar_lightlevel))
    
    
set_task(get_pcvar_float(cvar_showtime), "remove_effect"g_effect_id[id])
}

public 
fw_WhatTheFuck_Post(eseenthosthost_flagsplayerp_set)
{
    if(!(
host 33))
        return 
FMRES_IGNORED
        
    
if(ent != g_effect_id[host] || !pev_valid(ent))
        return 
FMRES_IGNORED
        
    
if(pev(entpev_owner) != host)
        return 
FMRES_IGNORED
        
    
if(!is_user_alive(host))
        return 
FMRES_IGNORED
        
    
static Float:origin[3], Float:forvec[3], Float:voffsets[3], Float:Angles[3]
    
    
pev(hostpev_originorigin)
    
pev(hostpev_view_ofsvoffsets)
    
pev(hostpev_anglesAngles)
    
    
xs_vec_add(originvoffsetsorigin)
    
    
// Get a forward vector in the direction of player's aim
    
velocity_by_aim(host10forvec)
    
    
// Set the sprite on the new origin
    
xs_vec_add(originforvecorigin)
    
    
engfunc(EngFunc_SetOriginentorigin)
    
set_es(esES_Originorigin)
    
set_es(esES_AnglesAngles)
    
    
// Make the sprite visible
    
set_es(esES_RenderModekRenderTransAdd)
    
set_es(esES_RenderAmt200)
        
    return 
FMRES_HANDLED
}

public 
remove_effect(ent)
{
    
g_had_effect[pev(entpev_owner)] = 0
    
    
if(pev_valid(ent))
        
engfunc(EngFunc_RemoveEntityent)

This code works, but it sometimes bugs weapons or grenades. E.g. you want to throw a weapon, but it stays in front of you and follows you, the same thing with grenade. Why is that bug appearing? I looked through the code many times and still cant get whats wrong..
Podarok is offline
 


Thread Tools
Display Modes

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 10:53.


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