Raised This Month: $51 Target: $400
 12% 

[HELP] Vip extra


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
Johnnynho123
Member
Join Date: Dec 2011
Location: Gradiska, Republic of Sr
Old 02-21-2012 , 05:12   [HELP] Vip extra
#1

Can someone make VIP extra item Jetpack+ Bazooka ?? i have this code but i cannot compile
Code:
/*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|* 
*.  
* [ZP] VIP Plugin Item Jetpack+Bazooka 3.2 
* 
*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|* 
* 
* Original Plugin: 
*           AMX Jetpack 
*            BY 
*            (c) Copyright 2005, KleeneX 
*            This file is provided as is (no warranties) 
* 
* CREDITS: 
*             KleeneX   |>>>|  Original Plugin (http://forums.alliedmods.net/showthread.php?p=119727) 
*            Bad_Bud   |>>>|  TS_Jetpack (http://forums.alliedmods.net/showthread.php?t=55709&highlight=TS_Jetpack) 
*             MeRcyLeZZ |>>>|  bug fix, some code from [ZP] Stamina (http://forums.alliedmods.net/showpost.php?p=675697&postcount=1300) 
*              mogel     |>>>|  Icon code form Predator-Mod (http://forums.alliedmods.net/showthread.php?t=67305&highlight=predator) 
           bigbud    |>>>|  [ZP] Jetpack + bazooka 3.2 (http://forums.alliedmods.net/showpost.php?p=674810) 
* 
*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|* 
* 
* VIP Plagued Version 3.2 by B!GBUD and CarsonMotion 
* 
*  
* Allows Humans buy a Jetpack+Bazooka in Zombie Plague [4.0] 
*  
* 
* CVARS:     
*    zp_jetpack 2         // 0 = Off / 1 = have Knive & Hold ATTACK / 2 = Hold JUMP and DUCK       
* 
*    zp_jp_forward_speed 300 // Set the forward speed(when you fly and press FORWARD) 
*    zp_jp_up_speed 35    // Set the UP speed(when you press ATTACK and JUMP up) 
*    zp_jp_accelerate 100    // How fast you get to the max ForwardSpeed 
* 
*    zp_jp_rocket_delay 12    // How long you got to wait to shoot the next rocket(in sec.) 
*    zp_jp_rocket_speed 1500 // Set the rocket Speed 
*    zp_jp_rocket_damage 1500    // Set the max rocket Damage 
*    zp_jp_damage_radius 350 // Set the radius of a rocket explosion 
*     
*    zp_jp_max_engery 100     // Set the max Energy for the Jetpack 
*    zp_jp_engery 10     // Set how many Energy need the JP to fly (time interval is "zp_jp_energy_cal") 
*    zp_jp_regain_energy 3    // Set how fast you get JP_Energy back, when you on the ground (time interval is "zp_jp_energy_cal") 
*    zp_jp_energy_cal 1.0     // Set time interval for "zp_jp_engery" & "zp_jp_regain_energy" 
*    zp_jp_oneround 1    // 0 = jetpack stay on a new round if someone alive / 1 = jetpack for One Round only 
* 
*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|*/ 

#include <amxmodx> 
#include <fun> 
#include <engine> 
#include <fakemeta> 
#include <hamsandwich> 
#include <zombieplague> 
#include <zmvip> 

#define PLUGINNAME        "[ZP] VIP Plugin Item Jetpack+Bazooka" 
#define VERSION            "3.2" 
#define AUTHOR            "B!gBud, CarsonMotion" 

#define ACCESS_LEVEL    ADMIN_LEVEL_A 
#define VOTE_ACCESS    ADMIN_CFG 

#define TE_EXPLOSION    3 
#define TE_BEAMFOLLOW    22 
#define TE_BEAMCYLINDER    21 

#define JETPACK_COST 30 // set how may ammopacks the Jatpack+Rocket cost 

new ROCKET_MDL[64] = "models/rpgrocket.mdl" 
new ROCKET_SOUND[64] = "weapons/rocketfire1.wav" 
new getrocket[64] = "items/9mmclip2.wav" 

new bool:fly[33] = false 
new bool:rocket[33] = false 
new bool:rksound[33] = false 
new bool:shot[33] = false 

new Float:gltime = 0.0 
new Float:last_Rocket[33] = 0.0 
new Float:jp_cal[33] = 0.0 
new Float:jp_soun[33] = 0.0 
new flame, explosion, trail, white 
new g_flyEnergy[33], hasjet[33] 
new cvar_jetpack, cvar_jetpackSpeed, cvar_jetpackUpSpeed, cvar_jetpackAcrate ,cvar_RocketDelay, cvar_RocketSpeed, cvar_RocketDmg, cvar_Dmg_range, cvar_fly_max_engery, cvar_fly_engery, cvar_regain_energy, g_item_jetpack, cvar_cal_time, cvar_oneround 


public plugin_init() { 
    register_plugin(PLUGINNAME, VERSION, AUTHOR) 
     
    g_item_jetpack = zv_register_extra_item("Jetpack+Bazooka (one Round)", JETPACK_COST, ZV_TEAM_HUMAN) 
    register_clcmd("drop","cmdDrop") 
    register_clcmd("say /jphelp","cmdHelp",0,": Displays Jetpack help") 
     
    new ver[64] 
    format(ver,63,"%s v%s",PLUGINNAME,VERSION) 
    register_cvar("zp_jp_version",ver,FCVAR_SERVER)     
     
    cvar_jetpack = register_cvar("zp_jetpack", "2") 
     
    cvar_jetpackSpeed=register_cvar("zp_jp_forward_speed","300.0") 
    cvar_jetpackUpSpeed=register_cvar("zp_jp_up_speed","35.0") 
    cvar_jetpackAcrate=register_cvar("zp_jp_accelerate","100.0") 
     
    cvar_RocketDelay=register_cvar("zp_jp_rocket_delay","12.0") 
    cvar_RocketSpeed=register_cvar("zp_jp_rocket_speed","1500") 
    cvar_RocketDmg=register_cvar("zp_jp_rocket_damage","1500") 
    cvar_Dmg_range=register_cvar("zp_jp_damage_radius","350") 
     
    cvar_fly_max_engery = register_cvar("zp_jp_max_engery", "100") 
    cvar_fly_engery = register_cvar("zp_jp_engery", "10") 
    cvar_regain_energy = register_cvar("zp_jp_regain_energy", "3") 
    cvar_cal_time = register_cvar("zp_jp_energy_cal", "1.0") 
    cvar_oneround = register_cvar("zp_jp_oneround", "0") 

     
    register_event("CurWeapon", "check_models", "be") 
    register_event("DeathMsg", "player_die", "a") 
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0") 
     
    register_forward(FM_StartFrame, "fm_startFrame") 
    register_forward(FM_EmitSound, "emitsound") 
} 

public plugin_precache() { 
    precache_model("models/p_egon.mdl") 
    precache_model("models/v_egon.mdl") 
    precache_model("models/w_egon.mdl") 
    precache_sound("jetpack.wav") 
    precache_sound("jp_blow.wav") 
     
    precache_model(ROCKET_MDL) 
    precache_sound(ROCKET_SOUND) 
    precache_sound(getrocket) 
     
    explosion = precache_model("sprites/zerogxplode.spr") 
    trail = precache_model("sprites/smoke.spr") 
    flame = precache_model("sprites/xfireball3.spr") 
    white = precache_model("sprites/white.spr") 
} 

public client_putinserver(id) { 
    fly[id] = false 
    rocket[id] = false 
    hasjet[id] = 0 
    g_flyEnergy[id] = 0 
} 

public client_disconnect(id) { 
    fly[id] = false 
    rocket[id] = false 
    hasjet[id] = 0 
    g_flyEnergy[id] = 0 
} 

public event_round_start() 
{ 
    remove_jetpacks(); 
    if (get_pcvar_num(cvar_oneround) == 1) { 
        for (new id; id <= 32; id++) hasjet[id] = 0, g_flyEnergy[id] = 0,    fly[id] = false; 
    } 
} 

public fm_startFrame(){ 
         
    gltime = get_gametime() 
    static id 
    for (id = 1; id <= 32; id++) 
    { 
        jp_forward(id) 
    } 
} 

public jp_forward(player) { 
     
    if (!is_user_alive(player) && (zp_get_user_zombie(player) || zp_get_user_nemesis(player) || zp_get_user_survivor(player))) 
        return FMRES_IGNORED         
         
    if (!hasjet[player]) 
        return FMRES_IGNORED 
     
    if(jp_cal[player] < gltime){ 
        jp_energy(player); jp_cal[player] = gltime + get_pcvar_float(cvar_cal_time) 
    } 
     
    check_rocket(player) 
     
    new clip,ammo 
    new wpnid = get_user_weapon(player,clip,ammo) 
    if (wpnid == CSW_KNIFE){ 
        if(get_pcvar_num(cvar_jetpack) == 1){ 
            if(!(pev(player, pev_flags)&FL_ONGROUND) && pev(player,pev_button)&IN_ATTACK){ 
                if((g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.3) && (g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery))){ 
                    if(jp_soun[player] < gltime){ 
                        emit_sound(player,CHAN_ITEM,"jetpack.wav",1.0,ATTN_NORM,1,PITCH_HIGH) 
                        jp_soun[player] = gltime + 1.0 
                    } 
                }             
                else if((g_flyEnergy[player] > 0) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.3)){ 
                    if(jp_soun[player] < gltime){ 
                            emit_sound(player,CHAN_ITEM,"jp_blow.wav",1.0,ATTN_NORM,1,PITCH_HIGH) 
                            jp_soun[player] = gltime + 1.0 
                    } 
                } 
            } 
            human_fly(player) 
            attack(player)     
        } 
        if((pev(player,pev_button)&IN_ATTACK2)){ 
                attack2(player)     
            }     
    } 
    if((get_pcvar_num(cvar_jetpack) == 2 && !(pev(player, pev_flags)&FL_ONGROUND)) && (pev(player,pev_button)&IN_JUMP && pev(player,pev_button)&IN_DUCK)){             
        if((g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.3) && (g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery))){ 
            if(jp_soun[player] < gltime){ 
                emit_sound(player,CHAN_ITEM,"jetpack.wav",1.0,ATTN_NORM,1,PITCH_HIGH) 
                jp_soun[player] = gltime + 1.0 
            } 
        }                     
        else if((g_flyEnergy[player] > 0) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.3)){ 
            if(jp_soun[player] < gltime){ 
                emit_sound(player,CHAN_ITEM,"jp_blow.wav",1.0,ATTN_NORM,1,PITCH_HIGH) 
                jp_soun[player] = gltime + 1.0 
            } 
        } 
        human_fly(player) 
        attack(player) 
    } 
    // Icon Show system 
    /*if (!is_user_alive(player) && zp_get_user_zombie(player) && zp_get_user_nemesis(player) && zp_get_user_survivor(player))     
        Icon_Energy({0, 255, 0}, 0, player); 
                //Icon_Energy({128, 128, 0}, 0, player); 
                //Icon_Energy({255, 255, 0}, 0, player); 
                         
    }*/ 
    if((g_flyEnergy[player] >= get_pcvar_num(cvar_fly_max_engery)*0.8) && (g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery))){ 
        Icon_Energy({0, 255, 0}, 1, player); // Green 
    } 
    else if((g_flyEnergy[player] >= get_pcvar_num(cvar_fly_max_engery)*0.5) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.8)){ 
        Icon_Energy({255, 255, 0}, 1, player); // yellow 
    } 
    else if((g_flyEnergy[player] >= get_pcvar_num(cvar_fly_max_engery)*0.3) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.5)){ 
        Icon_Energy({255, 215, 0}, 2, player); 
    } 
    else if((g_flyEnergy[player] > 0) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.3)){ 
        Icon_Energy({255, 0, 0}, 1, player); 
    } 
     
    return FMRES_IGNORED 
} 

public jp_energy(player) { 
             
        if (!(pev(player, pev_flags)&FL_ONGROUND) && pev(player,pev_button)&IN_ATTACK)     
        { 
            // Get our current velocity         
            new clip,ammo 
            new wpnid = get_user_weapon(player,clip,ammo) 
            if (wpnid == CSW_KNIFE)  
            { 
            // flying 
            if(g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.09) 
                g_flyEnergy[player] = g_flyEnergy[player] - get_pcvar_num(cvar_fly_engery);     // Increase distance counter         
            } 
        } 
        else if ((get_pcvar_num(cvar_jetpack) == 2 && !(pev(player, pev_flags)&FL_ONGROUND)) && (pev(player,pev_button)&IN_JUMP && pev(player,pev_button)&IN_DUCK)) 
        { 
            if(g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.09) 
                g_flyEnergy[player] = g_flyEnergy[player] - get_pcvar_num(cvar_fly_engery);     // Increase distance counter     
        } 
        // Walking/Runnig 
        if (pev(player, pev_flags) & FL_ONGROUND)     
            g_flyEnergy[player] = g_flyEnergy[player] + get_pcvar_num(cvar_regain_energy);// Decrease distance counter 
} 

public attack(player) { 
//code snippa from TS_Jetpack 1.0 - Jetpack plugin for The Specialists. 
//http://forums.alliedmods.net/showthread.php?t=55709&highlight=jetpack 
//By: Bad_Bud 
    if(fly[player]) 
    {     
        static Float:JetpackData[3] 
        pev(player,pev_velocity,JetpackData) 
                     
        new fOrigin[3],Float:Aim[3] 
        VelocityByAim(player, 10, Aim) 
        get_user_origin(player,fOrigin) 
        fOrigin[0] -= floatround(Aim[0]) 
        fOrigin[1] -= floatround(Aim[1]) 
        fOrigin[2] -= floatround(Aim[2]) 
         
         
        if((pev(player,pev_button)&IN_FORWARD) && !(pev(player, pev_flags) & FL_ONGROUND)) 
            { 
                 
                message_begin(MSG_ALL,SVC_TEMPENTITY) 
                write_byte(17)  
                write_coord(fOrigin[0]) 
                write_coord(fOrigin[1]) 
                write_coord(fOrigin[2]) 
                write_short(flame) 
                write_byte(10) 
                write_byte(255) 
                message_end()     
                 
                static Float:Speed 
                Speed=floatsqroot(JetpackData[0]*JetpackData[0]+JetpackData[1]*JetpackData[1]) 
                     
                if(Speed!=0.0)//Makes players only lay down if their speed isn't 0; if they are thrusting forward. 
                { 
                    set_pev(player,pev_gaitsequence,0) 
                    set_pev(player,pev_sequence,111) 
                } 
                     
                if(Speed<get_pcvar_float(cvar_jetpackSpeed)) 
                    Speed+=get_pcvar_float(cvar_jetpackAcrate) 
                         
                static Float:JetpackData2[3] 
                pev(player,pev_angles,JetpackData2) 
                JetpackData2[2]=0.0//Remove the Z value/ 
                     
                angle_vector(JetpackData2,ANGLEVECTOR_FORWARD,JetpackData2) 
                JetpackData2[0]*=Speed 
                JetpackData2[1]*=Speed 
                     
                JetpackData[0]=JetpackData2[0] 
                JetpackData[1]=JetpackData2[1] 
            } 
             
        if(JetpackData[2]<get_pcvar_float(cvar_jetpackSpeed)&&JetpackData[2]>0.0)//Jetpacks get more power on the way down -- it helps landing. 
                JetpackData[2]+=get_pcvar_float(cvar_jetpackUpSpeed) 
            else if(JetpackData[2]<0.0) 
                JetpackData[2]+=(get_pcvar_float(cvar_jetpackUpSpeed)*1.15) 
                     
        set_pev(player,pev_velocity,JetpackData) 
    } 
} 

public attack2(player) { 
         
    if (rocket[player]) 
    { 
         
        new rocket = create_entity("info_target") 
        if(rocket == 0) return PLUGIN_CONTINUE 
         
        entity_set_string(rocket, EV_SZ_classname, "zp_jp_rocket") 
        entity_set_model(rocket, ROCKET_MDL) 
         
        entity_set_size(rocket, Float:{0.0, 0.0, 0.0}, Float:{0.0, 0.0, 0.0}) 
        entity_set_int(rocket, EV_INT_movetype, MOVETYPE_FLY) 
        entity_set_int(rocket, EV_INT_solid, SOLID_BBOX) 
         
        new Float:vSrc[3] 
        entity_get_vector(player, EV_VEC_origin, vSrc) 
         
        new Float:Aim[3],Float:origin[3] 
        VelocityByAim(player, 64, Aim) 
        entity_get_vector(player,EV_VEC_origin,origin) 
         
        vSrc[0] += Aim[0] 
        vSrc[1] += Aim[1] 
        entity_set_origin(rocket, vSrc) 
         
        new Float:velocity[3], Float:angles[3] 
        VelocityByAim(player, get_pcvar_num(cvar_RocketSpeed), velocity) 
         
        entity_set_vector(rocket, EV_VEC_velocity, velocity) 
        vector_to_angle(velocity, angles) 
        entity_set_vector(rocket, EV_VEC_angles, angles) 
        entity_set_edict(rocket,EV_ENT_owner,player) 
        entity_set_float(rocket, EV_FL_takedamage, 1.0) 
         
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY) 
        write_byte(TE_BEAMFOLLOW) 
        write_short(rocket) 
        write_short(trail) 
        write_byte(25) 
        write_byte(5) 
        write_byte(224) 
        write_byte(224) 
        write_byte(255) 
        write_byte(255) 
        message_end() 

        emit_sound(rocket, CHAN_WEAPON, ROCKET_SOUND, 1.0, ATTN_NORM, 0, PITCH_NORM) 
         
        shot[player] = true 
        last_Rocket[player] = gltime + get_pcvar_num(cvar_RocketDelay) 
    } 
    return PLUGIN_CONTINUE 
} 

public check_models(id) { 

    if (zp_get_user_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_survivor(id)) 
        return FMRES_IGNORED 
     
    if(hasjet[id]) { 
        new clip,ammo 
        new wpnid = get_user_weapon(id,clip,ammo) 
         
        if ( wpnid == CSW_KNIFE ) { 
            switchmodel(id) 
        } 
        return PLUGIN_CONTINUE 
    } 
    return PLUGIN_CONTINUE 
} 

public switchmodel(id) { 
    entity_set_string(id,EV_SZ_viewmodel,"models/v_egon.mdl") 
    entity_set_string(id,EV_SZ_weaponmodel,"models/p_egon.mdl") 
} 

public remove_jetpacks() { 
    new nextitem  = find_ent_by_class(-1,"zp_jp_jetpack") 
    while(nextitem) { 
        remove_entity(nextitem) 
        nextitem = find_ent_by_class(-1,"zp_jp_jetpack") 
    } 
    return PLUGIN_CONTINUE 
} 

public emitsound(entity, channel, const sample[]) { 
    if(is_user_alive(entity)) { 
        new clip,ammo 
        new weapon = get_user_weapon(entity,clip,ammo) 
         
        if(hasjet[entity] && weapon == CSW_KNIFE) { 
            if(equal(sample,"weapons/knife_slash1.wav")) return FMRES_SUPERCEDE 
            if(equal(sample,"weapons/knife_slash2.wav")) return FMRES_SUPERCEDE 
             
            if(equal(sample,"weapons/knife_deploy1.wav")) return FMRES_SUPERCEDE 
            if(equal(sample,"weapons/knife_hitwall1.wav")) return FMRES_SUPERCEDE 
             
            if(equal(sample,"weapons/knife_hit1.wav")) return FMRES_SUPERCEDE 
            if(equal(sample,"weapons/knife_hit2.wav")) return FMRES_SUPERCEDE 
            if(equal(sample,"weapons/knife_hit3.wav")) return FMRES_SUPERCEDE 
            if(equal(sample,"weapons/knife_hit4.wav")) return FMRES_SUPERCEDE 
             
            if(equal(sample,"weapons/knife_stab.wav")) return FMRES_SUPERCEDE 
        } 
    } 
    return FMRES_IGNORED 
} 

public Icon_Show(icon[], color[3], mode, player) { 
             
    message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("StatusIcon"), {0,0,0}, player); 
    write_byte(mode);     // status (0=hide, 1=show, 2=flash) 
    write_string(icon);     // sprite name 
    write_byte(color[0]);     // red 
    write_byte(color[1]);     // green 
    write_byte(color[2]);     // blue 
    message_end(); 

} 

public Icon_Energy(color[3], mode, player) { 
     
    Icon_Show("item_longjump", color, mode, player) 
} 

public human_fly(player) { 
     
    if (g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery)*0.1) 
    { 
        jp_off(player);     
    } 
    if (g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.1) 
    { 
        jp_on(player); 
    } 
} 

public jp_on(player) { 

    fly[player] = true 
     
} 

public jp_off(player) { 

    fly[player] = false 
     
} 

public check_rocket(player) { 
         
    if (last_Rocket[player] > gltime) 
    {     
        rk_forbidden(player) 
        rksound[player] = true 
    } 
    else 
    {     

        if (shot[player]) 
        { 
            rksound[player] = false 
            shot[player] = false 
        } 
        rk_sound(player) 
        rk_allow(player) 
    } 
     
} 

public rk_allow(player) { 
         
    rocket[player] = true 
} 

public rk_forbidden(player) { 

    rocket[player] = false 
     
} 

public rk_sound(player) { 

    if (!rksound[player]) 
    { 
        engfunc(EngFunc_EmitSound, player, CHAN_WEAPON, getrocket, 1.0, ATTN_NORM, 0, PITCH_NORM) 
        client_print(player, print_center, "[Bazooka] Reloaded & Ready to use!!!") 
        rksound[player] = true 
    } 
    else if (rksound[player]) 
    { 
         
    } 
     
} 
         
public cmdHelp(id) { 
     
    new g_max = get_pcvar_num(cvar_fly_max_engery) 
    new g_lost = get_pcvar_num(cvar_fly_engery) 
    new g_back = get_pcvar_num(cvar_regain_energy) 
    new g_dmg = get_pcvar_num(cvar_RocketDmg) 
    new g_delay = get_pcvar_num(cvar_RocketDelay)  
     
    new jpmotd[2048], title[64], dpos = 0 
    format(title,63,"[ZP] %s ver.%s",PLUGINNAME,VERSION) 
     
     
    dpos += format(jpmotd[dpos],2047-dpos,"<html><head><style type=^"text/css^">pre{color:#FF0505;}body{background:#000000;margin-left:16px;margin-top:1px;}</style></head><pre><body>") 
    dpos += format(jpmotd[dpos],2047-dpos,"<b>%s</b>^n^n",title) 
     
    dpos += format(jpmotd[dpos],2047-dpos,"How to use:^n") 
    dpos += format(jpmotd[dpos],2047-dpos,"=============^n^n") 
    if(get_pcvar_num(cvar_jetpack) == 1) { 
        dpos += format(jpmotd[dpos],2047-dpos,"- choose/have Knive & use/hold ATTACK to fly^n") 
        dpos += format(jpmotd[dpos],2047-dpos,"^n") 
        dpos += format(jpmotd[dpos],2047-dpos,"- choose/have Knive(Bazooka) & use ATTACK2 to shoot a Rocket^n^n") 
    } 
    else if(get_pcvar_num(cvar_jetpack) == 2){ 
        dpos += format(jpmotd[dpos],2047-dpos,"- use/hold JUMP & DUCK to flyn") 
        dpos += format(jpmotd[dpos],2047-dpos,"^n") 
        dpos += format(jpmotd[dpos],2047-dpos,"choose/have Knive(Bazooka) & use ATTACK2 to shoot a Rocket^n^n") 
    } 
    dpos += format(jpmotd[dpos],2047-dpos,"INFO's^n") 
    dpos += format(jpmotd[dpos],2047-dpos,"MAX Energy set to : <b>%i Units</b>^n^n", g_max) 
    dpos += format(jpmotd[dpos],2047-dpos,"Jetpack need %i Units per 1 Sec. to work^n", g_lost) 
    dpos += format(jpmotd[dpos],2047-dpos,"Energy regain %i Units per 1 Sec. (when you are on the ground)^n^n", g_back) 
    dpos += format(jpmotd[dpos],2047-dpos,"MAX Rocket Dmg set to: <b>%i dmg</b>^n",g_dmg) 
    dpos += format(jpmotd[dpos],2047-dpos,"New Rocket comes ervry <b>%i Sec.</b>^n^n", g_delay ) 
    dpos += format(jpmotd[dpos],2047-dpos,"-Have Fun!^n") 
     

    show_motd(id,jpmotd,title) 
} 

public player_die() { 
     
    new id = read_data(2) 
    if(hasjet[id]) { 
        drop_jetpack(id) 
        hasjet[id] = 0 
        rocket[id] = false 
        g_flyEnergy[id] = 0 
    } 
     
    return PLUGIN_CONTINUE 
} 

public cmdDrop(id) { 

    if(hasjet[id]) { 
        new clip,ammo 
        new weapon = get_user_weapon(id,clip,ammo) 
        if(weapon == CSW_KNIFE) { 
            drop_jetpack(id) 
            if(!zp_get_user_zombie(id)){ 
                entity_set_string(id,EV_SZ_viewmodel,"models/v_knife.mdl") 
                entity_set_string(id,EV_SZ_weaponmodel,"models/p_knife.mdl") 
                } 
            return PLUGIN_HANDLED 
        } 
    } 
    return PLUGIN_CONTINUE 
} 

public drop_jetpack(player) { 
    if(hasjet[player]) { 
        new Float:Aim[3],Float:origin[3] 
        VelocityByAim(player, 64, Aim) 
        entity_get_vector(player,EV_VEC_origin,origin) 
         
        origin[0] += Aim[0] 
        origin[1] += Aim[1] 
         
        new jetpack = create_entity("info_target") 
        entity_set_string(jetpack,EV_SZ_classname,"zp_jp_jetpack") 
        entity_set_model(jetpack,"models/w_egon.mdl")     
         
        entity_set_size(jetpack,Float:{-16.0,-16.0,-16.0},Float:{16.0,16.0,16.0}) 
        entity_set_int(jetpack,EV_INT_solid,1) 
         
        entity_set_int(jetpack,EV_INT_movetype,6) 
         
        entity_set_vector(jetpack,EV_VEC_origin,origin) 
         
        Icon_Energy({255, 255, 0}, 0, player) 
        Icon_Energy({128, 128, 0}, 0, player ) 
        Icon_Energy({0, 255, 0}, 0, player) 
         
        hasjet[player] = 0 
        rocket[player] = false 
    }     
} 

public pfn_touch(ptr, ptd) { 
    if(is_valid_ent(ptr)) { 
        new classname[32] 
        entity_get_string(ptr,EV_SZ_classname,classname,31) 
         
        if(equal(classname, "zp_jp_jetpack")) { 
            if(is_valid_ent(ptd)) { 
                new id = ptd 
                if(id > 0 && id < 34) { 
                    if(!hasjet[id] && !zp_get_user_zombie(id) && is_user_alive(id)) { 
                         
                        hasjet[id] = 1 
                        g_flyEnergy[id] = get_pcvar_num(cvar_fly_max_engery) 
                        rocket[id] = true 
                        client_cmd(id,"spk items/gunpickup2.wav") 
                        engclient_cmd(id,"weapon_knife") 
                        switchmodel(id) 
                        remove_entity(ptr) 
                    } 
                } 
            } 
        }else if(equal(classname, "zp_jp_rocket")) { 
            new Float:fOrigin[3] 
            new iOrigin[3] 
            entity_get_vector(ptr, EV_VEC_origin, fOrigin) 
            FVecIVec(fOrigin,iOrigin) 
            jp_radius_damage(ptr) 
                 
            message_begin(MSG_BROADCAST,SVC_TEMPENTITY,iOrigin) 
            write_byte(TE_EXPLOSION) 
            write_coord(iOrigin[0]) 
            write_coord(iOrigin[1]) 
            write_coord(iOrigin[2]) 
            write_short(explosion) 
            write_byte(30) 
            write_byte(15) 
            write_byte(0) 
            message_end() 
                 
            message_begin(MSG_ALL,SVC_TEMPENTITY,iOrigin) 
            write_byte(TE_BEAMCYLINDER) 
            write_coord(iOrigin[0]) 
            write_coord(iOrigin[1]) 
            write_coord(iOrigin[2]) 
            write_coord(iOrigin[0]) 
            write_coord(iOrigin[1]) 
            write_coord(iOrigin[2]+200) 
            write_short(white) 
            write_byte(0) 
            write_byte(1) 
            write_byte(6) 
            write_byte(8) 
            write_byte(1) 
            write_byte(255) 
            write_byte(255) 
            write_byte(192) 
            write_byte(128) 
            write_byte(5) 
            message_end() 
             
            if(is_valid_ent(ptd)) { 
                new classname2[32] 
                entity_get_string(ptd,EV_SZ_classname,classname2,31) 
                 
                if(equal(classname2,"func_breakable")) 
                    force_use(ptr,ptd) 
            } 
             
            remove_entity(ptr) 
        } 
    } 
    return PLUGIN_CONTINUE 
} 

public zp_user_infected_pre(player, infector){ 
     
    Icon_Energy({0, 255, 0}, 0, player); 
    cmdDrop(player); 
    hasjet[player] = 0; 
    g_flyEnergy[player] = 0; 
    rocket[player] = false; 
} 

public zv_extra_item_selected(player, itemid){ 
     

    new clip,ammo 
    new weapon = get_user_weapon(player,clip,ammo) 
         
    if (itemid == g_item_jetpack) 
    { 
        client_print(player, print_chat, "[ZP] say /jphelp for Display the help page") 
        hasjet[player] = 1 
        g_flyEnergy[player] = get_pcvar_num(cvar_fly_max_engery) 
        rocket[player] = true 
        client_cmd(player,"spk items/gunpickup2.wav") 
        if(weapon == CSW_KNIFE){ 
            switchmodel(player) 
        } 
        else 
        { 
            engclient_cmd(player,"weapon_knife"),switchmodel(player) 
        } 
    } 
} 

stock jp_radius_damage(entity) { 
    new id = entity_get_edict(entity,EV_ENT_owner) 
    for(new i = 1; i < 33; i++) { 
        if(is_user_alive(i)) { 
            new dist = floatround(entity_range(entity,i)) 
             
            if(dist <= get_pcvar_num(cvar_Dmg_range)) { 
                new hp = get_user_health(i) 
                new Float:damage = get_pcvar_float(cvar_RocketDmg)-(get_pcvar_float(cvar_RocketDmg)/get_pcvar_float(cvar_Dmg_range))*float(dist) 
                 
                new Origin[3] 
                get_user_origin(i,Origin) 
                 
                if(zp_get_user_zombie(id) != zp_get_user_zombie(i)) { 
                        if(hp > damage) 
                            jp_take_damage(i,floatround(damage),Origin,DMG_BLAST) 
                        else 
                            log_kill(id,i,"Jetpack Rocket",0) 
                    } 
            } 
        } 
    } 
} 

stock log_kill(killer, victim, weapon[], headshot) 
{ 
// code from MeRcyLeZZ 
    set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET) 
    ExecuteHamB(Ham_Killed, victim, killer, 2) // set last param to 2 if you want victim to gib 
    set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT) 

     
    message_begin(MSG_BROADCAST, get_user_msgid("DeathMsg")) 
    write_byte(killer) 
    write_byte(victim) 
    write_byte(headshot) 
    write_string(weapon) 
    message_end() 
// 
     
    if(get_user_team(killer)!=get_user_team(victim)) 
        set_user_frags(killer,get_user_frags(killer) +1) 
    if(get_user_team(killer)==get_user_team(victim)) 
        set_user_frags(killer,get_user_frags(killer) -1) 
         
    new kname[32], vname[32], kauthid[32], vauthid[32], kteam[10], vteam[10] 

    get_user_name(killer, kname, 31) 
    get_user_team(killer, kteam, 9) 
    get_user_authid(killer, kauthid, 31) 
  
    get_user_name(victim, vname, 31) 
    get_user_team(victim, vteam, 9) 
    get_user_authid(victim, vauthid, 31) 
         
    log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"",  
    kname, get_user_userid(killer), kauthid, kteam,  
     vname, get_user_userid(victim), vauthid, vteam, weapon) 

     return PLUGIN_CONTINUE; 
} 

stock jp_take_damage(victim,damage,origin[3],bit) { 
    message_begin(MSG_ONE,get_user_msgid("Damage"),{0,0,0},victim) 
    write_byte(21) 
    write_byte(20) 
    write_long(bit) 
    write_coord(origin[0]) 
    write_coord(origin[1]) 
    write_coord(origin[2]) 
    message_end() 
     
    set_user_health(victim,get_user_health(victim)-damage) 
}
Please help !!
__________________


Forum: www.Adrenaline-Zone.info
Johnnynho123 is offline
DeMNiX
Veteran Member
Join Date: Nov 2011
Location: Russia
Old 02-21-2012 , 09:09   Re: [HELP] Vip extra
#2

Try.


PHP Code:
/*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|* 
*.  
* [ZP] VIP Plugin Item Jetpack+Bazooka 3.2 

*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|* 

* Original Plugin: 
*           AMX Jetpack 
*            BY 
*            (c) Copyright 2005, KleeneX 
*            This file is provided as is (no warranties) 

* CREDITS: 
*             KleeneX   |>>>|  Original Plugin (http://forums.alliedmods.net/showthread.php?p=119727) 
*            Bad_Bud   |>>>|  TS_Jetpack (http://forums.alliedmods.net/showthread.php?t=55709&highlight=TS_Jetpack) 
*             MeRcyLeZZ |>>>|  bug fix, some code from [ZP] Stamina (http://forums.alliedmods.net/showpost.php?p=675697&postcount=1300) 
*              mogel     |>>>|  Icon code form Predator-Mod (http://forums.alliedmods.net/showthread.php?t=67305&highlight=predator) 
           bigbud    |>>>|  [ZP] Jetpack + bazooka 3.2 (http://forums.alliedmods.net/showpost.php?p=674810) 

*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|* 

* VIP Plagued Version 3.2 by B!GBUD and CarsonMotion 

*  
* Allows Humans buy a Jetpack+Bazooka in Zombie Plague [4.0] 
*  

* CVARS:     
*    zp_jetpack 2         // 0 = Off / 1 = have Knive & Hold ATTACK / 2 = Hold JUMP and DUCK       

*    zp_jp_forward_speed 300 // Set the forward speed(when you fly and press FORWARD) 
*    zp_jp_up_speed 35    // Set the UP speed(when you press ATTACK and JUMP up) 
*    zp_jp_accelerate 100    // How fast you get to the max ForwardSpeed 

*    zp_jp_rocket_delay 12    // How long you got to wait to shoot the next rocket(in sec.) 
*    zp_jp_rocket_speed 1500 // Set the rocket Speed 
*    zp_jp_rocket_damage 1500    // Set the max rocket Damage 
*    zp_jp_damage_radius 350 // Set the radius of a rocket explosion 
*     
*    zp_jp_max_engery 100     // Set the max Energy for the Jetpack 
*    zp_jp_engery 10     // Set how many Energy need the JP to fly (time interval is "zp_jp_energy_cal") 
*    zp_jp_regain_energy 3    // Set how fast you get JP_Energy back, when you on the ground (time interval is "zp_jp_energy_cal") 
*    zp_jp_energy_cal 1.0     // Set time interval for "zp_jp_engery" & "zp_jp_regain_energy" 
*    zp_jp_oneround 1    // 0 = jetpack stay on a new round if someone alive / 1 = jetpack for One Round only 

*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|*/ 

#include <amxmodx> 
#include <fun> 
#include <engine> 
#include <fakemeta> 
#include <hamsandwich> 
#include <zombieplague> 
#include <zmvip> 

#define PLUGINNAME        "[ZP] VIP Plugin Item Jetpack+Bazooka" 
#define VERSION            "3.2" 
#define AUTHOR            "B!gBud, CarsonMotion" 

#define ACCESS_LEVEL    ADMIN_LEVEL_A 
#define VOTE_ACCESS    ADMIN_CFG 

#define TE_EXPLOSION    3 
#define TE_BEAMFOLLOW    22 
#define TE_BEAMCYLINDER    21 

#define JETPACK_COST 30 // set how may ammopacks the Jatpack+Rocket cost 

new ROCKET_MDL[64] = "models/rpgrocket.mdl" 
new ROCKET_SOUND[64] = "weapons/rocketfire1.wav" 
new getrocket[64] = "items/9mmclip2.wav" 

new bool:fly[33] = false 
new bool:rocket[33] = false 
new bool:rksound[33] = false 
new bool:shot[33] = false 

new Float:gltime 0.0 
new Float:last_Rocket[33] = 0.0 
new Float:jp_cal[33] = 0.0 
new Float:jp_soun[33] = 0.0 
new flameexplosiontrailwhite 
new g_flyEnergy[33], hasjet[33
new 
cvar_jetpackcvar_jetpackSpeedcvar_jetpackUpSpeedcvar_jetpackAcrate ,cvar_RocketDelaycvar_RocketSpeedcvar_RocketDmgcvar_Dmg_rangecvar_fly_max_engerycvar_fly_engerycvar_regain_energyg_item_jetpackcvar_cal_timecvar_oneround 


public plugin_init() { 
    
register_plugin(PLUGINNAMEVERSIONAUTHOR
     
    
g_item_jetpack zv_register_extra_item("Jetpack+Bazooka""(one Round)" JETPACK_COSTZV_TEAM_HUMAN
    
register_clcmd("drop","cmdDrop"
    
register_clcmd("say /jphelp","cmdHelp",0,": Displays Jetpack help"
     
    new 
ver[64
    
format(ver,63,"%s v%s",PLUGINNAME,VERSION
    
register_cvar("zp_jp_version",ver,FCVAR_SERVER)     
     
    
cvar_jetpack register_cvar("zp_jetpack""2"
     
    
cvar_jetpackSpeed=register_cvar("zp_jp_forward_speed","300.0"
    
cvar_jetpackUpSpeed=register_cvar("zp_jp_up_speed","35.0"
    
cvar_jetpackAcrate=register_cvar("zp_jp_accelerate","100.0"
     
    
cvar_RocketDelay=register_cvar("zp_jp_rocket_delay","12.0"
    
cvar_RocketSpeed=register_cvar("zp_jp_rocket_speed","1500"
    
cvar_RocketDmg=register_cvar("zp_jp_rocket_damage","1500"
    
cvar_Dmg_range=register_cvar("zp_jp_damage_radius","350"
     
    
cvar_fly_max_engery register_cvar("zp_jp_max_engery""100"
    
cvar_fly_engery register_cvar("zp_jp_engery""10"
    
cvar_regain_energy register_cvar("zp_jp_regain_energy""3"
    
cvar_cal_time register_cvar("zp_jp_energy_cal""1.0"
    
cvar_oneround register_cvar("zp_jp_oneround""0"

     
    
register_event("CurWeapon""check_models""be"
    
register_event("DeathMsg""player_die""a"
    
register_event("HLTV""event_round_start""a""1=0""2=0"
     
    
register_forward(FM_StartFrame"fm_startFrame"
    
register_forward(FM_EmitSound"emitsound"


public 
plugin_precache() { 
    
precache_model("models/p_egon.mdl"
    
precache_model("models/v_egon.mdl"
    
precache_model("models/w_egon.mdl"
    
precache_sound("jetpack.wav"
    
precache_sound("jp_blow.wav"
     
    
precache_model(ROCKET_MDL
    
precache_sound(ROCKET_SOUND
    
precache_sound(getrocket
     
    
explosion precache_model("sprites/zerogxplode.spr"
    
trail precache_model("sprites/smoke.spr"
    
flame precache_model("sprites/xfireball3.spr"
    
white precache_model("sprites/white.spr"


public 
client_putinserver(id) { 
    
fly[id] = false 
    rocket
[id] = false 
    hasjet
[id] = 
    g_flyEnergy
[id] = 


public 
client_disconnect(id) { 
    
fly[id] = false 
    rocket
[id] = false 
    hasjet
[id] = 
    g_flyEnergy
[id] = 


public 
event_round_start() 

    
remove_jetpacks(); 
    if (
get_pcvar_num(cvar_oneround) == 1) { 
        for (new 
idid <= 32id++) hasjet[id] = 0g_flyEnergy[id] = 0,    fly[id] = false
    } 


public 
fm_startFrame(){ 
         
    
gltime get_gametime() 
    static 
id 
    
for (id 1id <= 32id++) 
    { 
        
jp_forward(id
    } 


public 
jp_forward(player) { 
     
    if (!
is_user_alive(player) && (zp_get_user_zombie(player) || zp_get_user_nemesis(player) || zp_get_user_survivor(player))) 
        return 
FMRES_IGNORED         
         
    
if (!hasjet[player]) 
        return 
FMRES_IGNORED 
     
    
if(jp_cal[player] < gltime){ 
        
jp_energy(player); jp_cal[player] = gltime get_pcvar_float(cvar_cal_time
    } 
     
    
check_rocket(player
     
    new 
clip,ammo 
    
new wpnid get_user_weapon(player,clip,ammo
    if (
wpnid == CSW_KNIFE){ 
        if(
get_pcvar_num(cvar_jetpack) == 1){ 
            if(!(
pev(playerpev_flags)&FL_ONGROUND) && pev(player,pev_button)&IN_ATTACK){ 
                if((
g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.3) && (g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery))){ 
                    if(
jp_soun[player] < gltime){ 
                        
emit_sound(player,CHAN_ITEM,"jetpack.wav",1.0,ATTN_NORM,1,PITCH_HIGH
                        
jp_soun[player] = gltime 1.0 
                    

                }             
                else if((
g_flyEnergy[player] > 0) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.3)){ 
                    if(
jp_soun[player] < gltime){ 
                            
emit_sound(player,CHAN_ITEM,"jp_blow.wav",1.0,ATTN_NORM,1,PITCH_HIGH
                            
jp_soun[player] = gltime 1.0 
                    

                } 
            } 
            
human_fly(player
            
attack(player)     
        } 
        if((
pev(player,pev_button)&IN_ATTACK2)){ 
                
attack2(player)     
            }     
    } 
    if((
get_pcvar_num(cvar_jetpack) == && !(pev(playerpev_flags)&FL_ONGROUND)) && (pev(player,pev_button)&IN_JUMP && pev(player,pev_button)&IN_DUCK)){             
        if((
g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.3) && (g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery))){ 
            if(
jp_soun[player] < gltime){ 
                
emit_sound(player,CHAN_ITEM,"jetpack.wav",1.0,ATTN_NORM,1,PITCH_HIGH
                
jp_soun[player] = gltime 1.0 
            

        }                     
        else if((
g_flyEnergy[player] > 0) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.3)){ 
            if(
jp_soun[player] < gltime){ 
                
emit_sound(player,CHAN_ITEM,"jp_blow.wav",1.0,ATTN_NORM,1,PITCH_HIGH
                
jp_soun[player] = gltime 1.0 
            

        } 
        
human_fly(player
        
attack(player
    } 
    
// Icon Show system 
    /*if (!is_user_alive(player) && zp_get_user_zombie(player) && zp_get_user_nemesis(player) && zp_get_user_survivor(player))     
        Icon_Energy({0, 255, 0}, 0, player); 
                //Icon_Energy({128, 128, 0}, 0, player); 
                //Icon_Energy({255, 255, 0}, 0, player); 
                         
    }*/ 
    
if((g_flyEnergy[player] >= get_pcvar_num(cvar_fly_max_engery)*0.8) && (g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery))){ 
        
Icon_Energy({02550}, 1player); // Green 
    

    else if((
g_flyEnergy[player] >= get_pcvar_num(cvar_fly_max_engery)*0.5) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.8)){ 
        
Icon_Energy({2552550}, 1player); // yellow 
    

    else if((
g_flyEnergy[player] >= get_pcvar_num(cvar_fly_max_engery)*0.3) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.5)){ 
        
Icon_Energy({2552150}, 2player); 
    } 
    else if((
g_flyEnergy[player] > 0) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.3)){ 
        
Icon_Energy({25500}, 1player); 
    } 
     
    return 
FMRES_IGNORED 


public 
jp_energy(player) { 
             
        if (!(
pev(playerpev_flags)&FL_ONGROUND) && pev(player,pev_button)&IN_ATTACK)     
        { 
            
// Get our current velocity         
            
new clip,ammo 
            
new wpnid get_user_weapon(player,clip,ammo
            if (
wpnid == CSW_KNIFE)  
            { 
            
// flying 
            
if(g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.09
                
g_flyEnergy[player] = g_flyEnergy[player] - get_pcvar_num(cvar_fly_engery);     // Increase distance counter         
            

        } 
        else if ((
get_pcvar_num(cvar_jetpack) == && !(pev(playerpev_flags)&FL_ONGROUND)) && (pev(player,pev_button)&IN_JUMP && pev(player,pev_button)&IN_DUCK)) 
        { 
            if(
g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.09
                
g_flyEnergy[player] = g_flyEnergy[player] - get_pcvar_num(cvar_fly_engery);     // Increase distance counter     
        

        
// Walking/Runnig 
        
if (pev(playerpev_flags) & FL_ONGROUND)     
            
g_flyEnergy[player] = g_flyEnergy[player] + get_pcvar_num(cvar_regain_energy);// Decrease distance counter 


public 
attack(player) { 
//code snippa from TS_Jetpack 1.0 - Jetpack plugin for The Specialists. 
//http://forums.alliedmods.net/showthread.php?t=55709&highlight=jetpack 
//By: Bad_Bud 
    
if(fly[player]) 
    {     
        static 
Float:JetpackData[3
        
pev(player,pev_velocity,JetpackData
                     
        new 
fOrigin[3],Float:Aim[3
        
VelocityByAim(player10Aim
        
get_user_origin(player,fOrigin
        
fOrigin[0] -= floatround(Aim[0]) 
        
fOrigin[1] -= floatround(Aim[1]) 
        
fOrigin[2] -= floatround(Aim[2]) 
         
         
        if((
pev(player,pev_button)&IN_FORWARD) && !(pev(playerpev_flags) & FL_ONGROUND)) 
            { 
                 
                
message_begin(MSG_ALL,SVC_TEMPENTITY
                
write_byte(17)  
                
write_coord(fOrigin[0]) 
                
write_coord(fOrigin[1]) 
                
write_coord(fOrigin[2]) 
                
write_short(flame
                
write_byte(10
                
write_byte(255
                
message_end()     
                 
                static 
Float:Speed 
                Speed
=floatsqroot(JetpackData[0]*JetpackData[0]+JetpackData[1]*JetpackData[1]) 
                     
                if(
Speed!=0.0)//Makes players only lay down if their speed isn't 0; if they are thrusting forward. 
                

                    
set_pev(player,pev_gaitsequence,0
                    
set_pev(player,pev_sequence,111
                } 
                     
                if(
Speed<get_pcvar_float(cvar_jetpackSpeed)) 
                    
Speed+=get_pcvar_float(cvar_jetpackAcrate
                         
                static 
Float:JetpackData2[3
                
pev(player,pev_angles,JetpackData2
                
JetpackData2[2]=0.0//Remove the Z value/ 
                     
                
angle_vector(JetpackData2,ANGLEVECTOR_FORWARD,JetpackData2
                
JetpackData2[0]*=Speed 
                JetpackData2
[1]*=Speed 
                     
                JetpackData
[0]=JetpackData2[0
                
JetpackData[1]=JetpackData2[1
            } 
             
        if(
JetpackData[2]<get_pcvar_float(cvar_jetpackSpeed)&&JetpackData[2]>0.0)//Jetpacks get more power on the way down -- it helps landing. 
                
JetpackData[2]+=get_pcvar_float(cvar_jetpackUpSpeed
            else if(
JetpackData[2]<0.0
                
JetpackData[2]+=(get_pcvar_float(cvar_jetpackUpSpeed)*1.15
                     
        
set_pev(player,pev_velocity,JetpackData
    } 


public 
attack2(player) { 
         
    if (
rocket[player]) 
    { 
         
        new 
rocket create_entity("info_target"
        if(
rocket == 0) return PLUGIN_CONTINUE 
         
        entity_set_string
(rocketEV_SZ_classname"zp_jp_rocket"
        
entity_set_model(rocketROCKET_MDL
         
        
entity_set_size(rocketFloat:{0.00.00.0}, Float:{0.00.00.0}) 
        
entity_set_int(rocketEV_INT_movetypeMOVETYPE_FLY
        
entity_set_int(rocketEV_INT_solidSOLID_BBOX
         
        new 
Float:vSrc[3
        
entity_get_vector(playerEV_VEC_originvSrc
         
        new 
Float:Aim[3],Float:origin[3
        
VelocityByAim(player64Aim
        
entity_get_vector(player,EV_VEC_origin,origin
         
        
vSrc[0] += Aim[0
        
vSrc[1] += Aim[1
        
entity_set_origin(rocketvSrc
         
        new 
Float:velocity[3], Float:angles[3
        
VelocityByAim(playerget_pcvar_num(cvar_RocketSpeed), velocity
         
        
entity_set_vector(rocketEV_VEC_velocityvelocity
        
vector_to_angle(velocityangles
        
entity_set_vector(rocketEV_VEC_anglesangles
        
entity_set_edict(rocket,EV_ENT_owner,player
        
entity_set_float(rocketEV_FL_takedamage1.0
         
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY
        
write_byte(TE_BEAMFOLLOW
        
write_short(rocket
        
write_short(trail
        
write_byte(25
        
write_byte(5
        
write_byte(224
        
write_byte(224
        
write_byte(255
        
write_byte(255
        
message_end() 

        
emit_sound(rocketCHAN_WEAPONROCKET_SOUND1.0ATTN_NORM0PITCH_NORM
         
        
shot[player] = true 
        last_Rocket
[player] = gltime get_pcvar_num(cvar_RocketDelay
    } 
    return 
PLUGIN_CONTINUE 


public 
check_models(id) { 

    if (
zp_get_user_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_survivor(id)) 
        return 
FMRES_IGNORED 
     
    
if(hasjet[id]) { 
        new 
clip,ammo 
        
new wpnid get_user_weapon(id,clip,ammo
         
        if ( 
wpnid == CSW_KNIFE ) { 
            
switchmodel(id
        } 
        return 
PLUGIN_CONTINUE 
    

    return 
PLUGIN_CONTINUE 


public 
switchmodel(id) { 
    
entity_set_string(id,EV_SZ_viewmodel,"models/v_egon.mdl"
    
entity_set_string(id,EV_SZ_weaponmodel,"models/p_egon.mdl"


public 
remove_jetpacks() { 
    new 
nextitem  find_ent_by_class(-1,"zp_jp_jetpack"
    while(
nextitem) { 
        
remove_entity(nextitem
        
nextitem find_ent_by_class(-1,"zp_jp_jetpack"
    } 
    return 
PLUGIN_CONTINUE 


public 
emitsound(entitychannel, const sample[]) { 
    if(
is_user_alive(entity)) { 
        new 
clip,ammo 
        
new weapon get_user_weapon(entity,clip,ammo
         
        if(
hasjet[entity] && weapon == CSW_KNIFE) { 
            if(
equal(sample,"weapons/knife_slash1.wav")) return FMRES_SUPERCEDE 
            
if(equal(sample,"weapons/knife_slash2.wav")) return FMRES_SUPERCEDE 
             
            
if(equal(sample,"weapons/knife_deploy1.wav")) return FMRES_SUPERCEDE 
            
if(equal(sample,"weapons/knife_hitwall1.wav")) return FMRES_SUPERCEDE 
             
            
if(equal(sample,"weapons/knife_hit1.wav")) return FMRES_SUPERCEDE 
            
if(equal(sample,"weapons/knife_hit2.wav")) return FMRES_SUPERCEDE 
            
if(equal(sample,"weapons/knife_hit3.wav")) return FMRES_SUPERCEDE 
            
if(equal(sample,"weapons/knife_hit4.wav")) return FMRES_SUPERCEDE 
             
            
if(equal(sample,"weapons/knife_stab.wav")) return FMRES_SUPERCEDE 
        

    } 
    return 
FMRES_IGNORED 


public 
Icon_Show(icon[], color[3], modeplayer) { 
             
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("StatusIcon"), {0,0,0}, player); 
    
write_byte(mode);     // status (0=hide, 1=show, 2=flash) 
    
write_string(icon);     // sprite name 
    
write_byte(color[0]);     // red 
    
write_byte(color[1]);     // green 
    
write_byte(color[2]);     // blue 
    
message_end(); 



public 
Icon_Energy(color[3], modeplayer) { 
     
    
Icon_Show("item_longjump"colormodeplayer


public 
human_fly(player) { 
     
    if (
g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery)*0.1
    { 
        
jp_off(player);     
    } 
    if (
g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.1
    { 
        
jp_on(player); 
    } 


public 
jp_on(player) { 

    
fly[player] = true 
     


public 
jp_off(player) { 

    
fly[player] = false 
     


public 
check_rocket(player) { 
         
    if (
last_Rocket[player] > gltime
    {     
        
rk_forbidden(player
        
rksound[player] = true 
    

    else 
    {     

        if (
shot[player]) 
        { 
            
rksound[player] = false 
            shot
[player] = false 
        

        
rk_sound(player
        
rk_allow(player
    } 
     


public 
rk_allow(player) { 
         
    
rocket[player] = true 


public 
rk_forbidden(player) { 

    
rocket[player] = false 
     


public 
rk_sound(player) { 

    if (!
rksound[player]) 
    { 
        
engfunc(EngFunc_EmitSoundplayerCHAN_WEAPONgetrocket1.0ATTN_NORM0PITCH_NORM
        
client_print(playerprint_center"[Bazooka] Reloaded & Ready to use!!!"
        
rksound[player] = true 
    

    else if (
rksound[player]) 
    { 
         
    } 
     

         
public 
cmdHelp(id) { 
     
    new 
g_max get_pcvar_num(cvar_fly_max_engery
    new 
g_lost get_pcvar_num(cvar_fly_engery
    new 
g_back get_pcvar_num(cvar_regain_energy
    new 
g_dmg get_pcvar_num(cvar_RocketDmg
    new 
g_delay get_pcvar_num(cvar_RocketDelay)  
     
    new 
jpmotd[2048], title[64], dpos 
    format
(title,63,"[ZP] %s ver.%s",PLUGINNAME,VERSION
     
     
    
dpos += format(jpmotd[dpos],2047-dpos,"<html><head><style type=^"text/css^">pre{color:#FF0505;}body{background:#000000;margin-left:16px;margin-top:1px;}</style></head><pre><body>"
    
dpos += format(jpmotd[dpos],2047-dpos,"<b>%s</b>^n^n",title
     
    
dpos += format(jpmotd[dpos],2047-dpos,"How to use:^n"
    
dpos += format(jpmotd[dpos],2047-dpos,"=============^n^n"
    if(
get_pcvar_num(cvar_jetpack) == 1) { 
        
dpos += format(jpmotd[dpos],2047-dpos,"- choose/have Knive & use/hold ATTACK to fly^n"
        
dpos += format(jpmotd[dpos],2047-dpos,"^n"
        
dpos += format(jpmotd[dpos],2047-dpos,"- choose/have Knive(Bazooka) & use ATTACK2 to shoot a Rocket^n^n"
    } 
    else if(
get_pcvar_num(cvar_jetpack) == 2){ 
        
dpos += format(jpmotd[dpos],2047-dpos,"- use/hold JUMP & DUCK to flyn"
        
dpos += format(jpmotd[dpos],2047-dpos,"^n"
        
dpos += format(jpmotd[dpos],2047-dpos,"choose/have Knive(Bazooka) & use ATTACK2 to shoot a Rocket^n^n"
    } 
    
dpos += format(jpmotd[dpos],2047-dpos,"INFO's^n"
    
dpos += format(jpmotd[dpos],2047-dpos,"MAX Energy set to : <b>%i Units</b>^n^n"g_max
    
dpos += format(jpmotd[dpos],2047-dpos,"Jetpack need %i Units per 1 Sec. to work^n"g_lost
    
dpos += format(jpmotd[dpos],2047-dpos,"Energy regain %i Units per 1 Sec. (when you are on the ground)^n^n"g_back
    
dpos += format(jpmotd[dpos],2047-dpos,"MAX Rocket Dmg set to: <b>%i dmg</b>^n",g_dmg
    
dpos += format(jpmotd[dpos],2047-dpos,"New Rocket comes ervry <b>%i Sec.</b>^n^n"g_delay 
    
dpos += format(jpmotd[dpos],2047-dpos,"-Have Fun!^n"
     

    
show_motd(id,jpmotd,title


public 
player_die() { 
     
    new 
id read_data(2
    if(
hasjet[id]) { 
        
drop_jetpack(id
        
hasjet[id] = 
        rocket
[id] = false 
        g_flyEnergy
[id] = 
    

     
    return 
PLUGIN_CONTINUE 


public 
cmdDrop(id) { 

    if(
hasjet[id]) { 
        new 
clip,ammo 
        
new weapon get_user_weapon(id,clip,ammo
        if(
weapon == CSW_KNIFE) { 
            
drop_jetpack(id
            if(!
zp_get_user_zombie(id)){ 
                
entity_set_string(id,EV_SZ_viewmodel,"models/v_knife.mdl"
                
entity_set_string(id,EV_SZ_weaponmodel,"models/p_knife.mdl"
                } 
            return 
PLUGIN_HANDLED 
        

    } 
    return 
PLUGIN_CONTINUE 


public 
drop_jetpack(player) { 
    if(
hasjet[player]) { 
        new 
Float:Aim[3],Float:origin[3
        
VelocityByAim(player64Aim
        
entity_get_vector(player,EV_VEC_origin,origin
         
        
origin[0] += Aim[0
        
origin[1] += Aim[1
         
        new 
jetpack create_entity("info_target"
        
entity_set_string(jetpack,EV_SZ_classname,"zp_jp_jetpack"
        
entity_set_model(jetpack,"models/w_egon.mdl")     
         
        
entity_set_size(jetpack,Float:{-16.0,-16.0,-16.0},Float:{16.0,16.0,16.0}) 
        
entity_set_int(jetpack,EV_INT_solid,1
         
        
entity_set_int(jetpack,EV_INT_movetype,6
         
        
entity_set_vector(jetpack,EV_VEC_origin,origin
         
        
Icon_Energy({2552550}, 0player
        
Icon_Energy({1281280}, 0player 
        
Icon_Energy({02550}, 0player
         
        
hasjet[player] = 
        rocket
[player] = false 
    
}     


public 
pfn_touch(ptrptd) { 
    if(
is_valid_ent(ptr)) { 
        new 
classname[32
        
entity_get_string(ptr,EV_SZ_classname,classname,31
         
        if(
equal(classname"zp_jp_jetpack")) { 
            if(
is_valid_ent(ptd)) { 
                new 
id ptd 
                
if(id && id 34) { 
                    if(!
hasjet[id] && !zp_get_user_zombie(id) && is_user_alive(id)) { 
                         
                        
hasjet[id] = 
                        g_flyEnergy
[id] = get_pcvar_num(cvar_fly_max_engery
                        
rocket[id] = true 
                        client_cmd
(id,"spk items/gunpickup2.wav"
                        
engclient_cmd(id,"weapon_knife"
                        
switchmodel(id
                        
remove_entity(ptr
                    } 
                } 
            } 
        }else if(
equal(classname"zp_jp_rocket")) { 
            new 
Float:fOrigin[3
            new 
iOrigin[3
            
entity_get_vector(ptrEV_VEC_originfOrigin
            
FVecIVec(fOrigin,iOrigin
            
jp_radius_damage(ptr
                 
            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY,iOrigin
            
write_byte(TE_EXPLOSION
            
write_coord(iOrigin[0]) 
            
write_coord(iOrigin[1]) 
            
write_coord(iOrigin[2]) 
            
write_short(explosion
            
write_byte(30
            
write_byte(15
            
write_byte(0
            
message_end() 
                 
            
message_begin(MSG_ALL,SVC_TEMPENTITY,iOrigin
            
write_byte(TE_BEAMCYLINDER
            
write_coord(iOrigin[0]) 
            
write_coord(iOrigin[1]) 
            
write_coord(iOrigin[2]) 
            
write_coord(iOrigin[0]) 
            
write_coord(iOrigin[1]) 
            
write_coord(iOrigin[2]+200
            
write_short(white
            
write_byte(0
            
write_byte(1
            
write_byte(6
            
write_byte(8
            
write_byte(1
            
write_byte(255
            
write_byte(255
            
write_byte(192
            
write_byte(128
            
write_byte(5
            
message_end() 
             
            if(
is_valid_ent(ptd)) { 
                new 
classname2[32
                
entity_get_string(ptd,EV_SZ_classname,classname2,31
                 
                if(
equal(classname2,"func_breakable")) 
                    
force_use(ptr,ptd
            } 
             
            
remove_entity(ptr
        } 
    } 
    return 
PLUGIN_CONTINUE 


public 
zp_user_infected_pre(playerinfector){ 
     
    
Icon_Energy({02550}, 0player); 
    
cmdDrop(player); 
    
hasjet[player] = 0
    
g_flyEnergy[player] = 0
    
rocket[player] = false


public 
zv_extra_item_selected(playeritemid){ 
     

    new 
clip,ammo 
    
new weapon get_user_weapon(player,clip,ammo
         
    if (
itemid == g_item_jetpack
    { 
        
client_print(playerprint_chat"[ZP] say /jphelp for Display the help page"
        
hasjet[player] = 
        g_flyEnergy
[player] = get_pcvar_num(cvar_fly_max_engery
        
rocket[player] = true 
        client_cmd
(player,"spk items/gunpickup2.wav"
        if(
weapon == CSW_KNIFE){ 
            
switchmodel(player
        } 
        else 
        { 
            
engclient_cmd(player,"weapon_knife"),switchmodel(player
        } 
    } 


stock jp_radius_damage(entity) { 
    new 
id entity_get_edict(entity,EV_ENT_owner
    for(new 
133i++) { 
        if(
is_user_alive(i)) { 
            new 
dist floatround(entity_range(entity,i)) 
             
            if(
dist <= get_pcvar_num(cvar_Dmg_range)) { 
                new 
hp get_user_health(i
                new 
Float:damage get_pcvar_float(cvar_RocketDmg)-(get_pcvar_float(cvar_RocketDmg)/get_pcvar_float(cvar_Dmg_range))*float(dist
                 
                new 
Origin[3
                
get_user_origin(i,Origin
                 
                if(
zp_get_user_zombie(id) != zp_get_user_zombie(i)) { 
                        if(
hp damage
                            
jp_take_damage(i,floatround(damage),Origin,DMG_BLAST
                        else 
                            
log_kill(id,i,"Jetpack Rocket",0
                    } 
            } 
        } 
    } 


stock log_kill(killervictimweapon[], headshot

// code from MeRcyLeZZ 
    
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET
    
ExecuteHamB(Ham_Killedvictimkiller2// set last param to 2 if you want victim to gib 
    
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT

     
    
message_begin(MSG_BROADCASTget_user_msgid("DeathMsg")) 
    
write_byte(killer
    
write_byte(victim
    
write_byte(headshot
    
write_string(weapon
    
message_end() 
// 
     
    
if(get_user_team(killer)!=get_user_team(victim)) 
        
set_user_frags(killer,get_user_frags(killer) +1
    if(
get_user_team(killer)==get_user_team(victim)) 
        
set_user_frags(killer,get_user_frags(killer) -1
         
    new 
kname[32], vname[32], kauthid[32], vauthid[32], kteam[10], vteam[10

    
get_user_name(killerkname31
    
get_user_team(killerkteam9
    
get_user_authid(killerkauthid31
  
    
get_user_name(victimvname31
    
get_user_team(victimvteam9
    
get_user_authid(victimvauthid31
         
    
log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"",  
    
knameget_user_userid(killer), kauthidkteam,  
     
vnameget_user_userid(victim), vauthidvteamweapon

     return 
PLUGIN_CONTINUE


stock jp_take_damage(victim,damage,origin[3],bit) { 
    
message_begin(MSG_ONE,get_user_msgid("Damage"),{0,0,0},victim
    
write_byte(21
    
write_byte(20
    
write_long(bit
    
write_coord(origin[0]) 
    
write_coord(origin[1]) 
    
write_coord(origin[2]) 
    
message_end() 
     
    
set_user_health(victim,get_user_health(victim)-damage
DeMNiX is offline
Johnnynho123
Member
Join Date: Dec 2011
Location: Gradiska, Republic of Sr
Old 02-22-2012 , 12:49   Re: [HELP] Vip extra
#3

Quote:
Originally Posted by DeMNiX View Post
Try.


PHP Code:
/*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|* 
*.  
* [ZP] VIP Plugin Item Jetpack+Bazooka 3.2 

*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|* 

* Original Plugin: 
*           AMX Jetpack 
*            BY 
*            (c) Copyright 2005, KleeneX 
*            This file is provided as is (no warranties) 

* CREDITS: 
*             KleeneX   |>>>|  Original Plugin (http://forums.alliedmods.net/showthread.php?p=119727) 
*            Bad_Bud   |>>>|  TS_Jetpack (http://forums.alliedmods.net/showthread.php?t=55709&highlight=TS_Jetpack) 
*             MeRcyLeZZ |>>>|  bug fix, some code from [ZP] Stamina (http://forums.alliedmods.net/showpost.php?p=675697&postcount=1300) 
*              mogel     |>>>|  Icon code form Predator-Mod (http://forums.alliedmods.net/showthread.php?t=67305&highlight=predator) 
           bigbud    |>>>|  [ZP] Jetpack + bazooka 3.2 (http://forums.alliedmods.net/showpost.php?p=674810) 

*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|* 

* VIP Plagued Version 3.2 by B!GBUD and CarsonMotion 

*  
* Allows Humans buy a Jetpack+Bazooka in Zombie Plague [4.0] 
*  

* CVARS:     
*    zp_jetpack 2         // 0 = Off / 1 = have Knive & Hold ATTACK / 2 = Hold JUMP and DUCK       

*    zp_jp_forward_speed 300 // Set the forward speed(when you fly and press FORWARD) 
*    zp_jp_up_speed 35    // Set the UP speed(when you press ATTACK and JUMP up) 
*    zp_jp_accelerate 100    // How fast you get to the max ForwardSpeed 

*    zp_jp_rocket_delay 12    // How long you got to wait to shoot the next rocket(in sec.) 
*    zp_jp_rocket_speed 1500 // Set the rocket Speed 
*    zp_jp_rocket_damage 1500    // Set the max rocket Damage 
*    zp_jp_damage_radius 350 // Set the radius of a rocket explosion 
*     
*    zp_jp_max_engery 100     // Set the max Energy for the Jetpack 
*    zp_jp_engery 10     // Set how many Energy need the JP to fly (time interval is "zp_jp_energy_cal") 
*    zp_jp_regain_energy 3    // Set how fast you get JP_Energy back, when you on the ground (time interval is "zp_jp_energy_cal") 
*    zp_jp_energy_cal 1.0     // Set time interval for "zp_jp_engery" & "zp_jp_regain_energy" 
*    zp_jp_oneround 1    // 0 = jetpack stay on a new round if someone alive / 1 = jetpack for One Round only 

*|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|**|_/=\_|*/ 

#include <amxmodx> 
#include <fun> 
#include <engine> 
#include <fakemeta> 
#include <hamsandwich> 
#include <zombieplague> 
#include <zmvip> 

#define PLUGINNAME        "[ZP] VIP Plugin Item Jetpack+Bazooka" 
#define VERSION            "3.2" 
#define AUTHOR            "B!gBud, CarsonMotion" 

#define ACCESS_LEVEL    ADMIN_LEVEL_A 
#define VOTE_ACCESS    ADMIN_CFG 

#define TE_EXPLOSION    3 
#define TE_BEAMFOLLOW    22 
#define TE_BEAMCYLINDER    21 

#define JETPACK_COST 30 // set how may ammopacks the Jatpack+Rocket cost 

new ROCKET_MDL[64] = "models/rpgrocket.mdl" 
new ROCKET_SOUND[64] = "weapons/rocketfire1.wav" 
new getrocket[64] = "items/9mmclip2.wav" 

new bool:fly[33] = false 
new bool:rocket[33] = false 
new bool:rksound[33] = false 
new bool:shot[33] = false 

new Float:gltime 0.0 
new Float:last_Rocket[33] = 0.0 
new Float:jp_cal[33] = 0.0 
new Float:jp_soun[33] = 0.0 
new flameexplosiontrailwhite 
new g_flyEnergy[33], hasjet[33
new 
cvar_jetpackcvar_jetpackSpeedcvar_jetpackUpSpeedcvar_jetpackAcrate ,cvar_RocketDelaycvar_RocketSpeedcvar_RocketDmgcvar_Dmg_rangecvar_fly_max_engerycvar_fly_engerycvar_regain_energyg_item_jetpackcvar_cal_timecvar_oneround 


public plugin_init() { 
    
register_plugin(PLUGINNAMEVERSIONAUTHOR
     
    
g_item_jetpack zv_register_extra_item("Jetpack+Bazooka""(one Round)" JETPACK_COSTZV_TEAM_HUMAN
    
register_clcmd("drop","cmdDrop"
    
register_clcmd("say /jphelp","cmdHelp",0,": Displays Jetpack help"
     
    new 
ver[64
    
format(ver,63,"%s v%s",PLUGINNAME,VERSION
    
register_cvar("zp_jp_version",ver,FCVAR_SERVER)     
     
    
cvar_jetpack register_cvar("zp_jetpack""2"
     
    
cvar_jetpackSpeed=register_cvar("zp_jp_forward_speed","300.0"
    
cvar_jetpackUpSpeed=register_cvar("zp_jp_up_speed","35.0"
    
cvar_jetpackAcrate=register_cvar("zp_jp_accelerate","100.0"
     
    
cvar_RocketDelay=register_cvar("zp_jp_rocket_delay","12.0"
    
cvar_RocketSpeed=register_cvar("zp_jp_rocket_speed","1500"
    
cvar_RocketDmg=register_cvar("zp_jp_rocket_damage","1500"
    
cvar_Dmg_range=register_cvar("zp_jp_damage_radius","350"
     
    
cvar_fly_max_engery register_cvar("zp_jp_max_engery""100"
    
cvar_fly_engery register_cvar("zp_jp_engery""10"
    
cvar_regain_energy register_cvar("zp_jp_regain_energy""3"
    
cvar_cal_time register_cvar("zp_jp_energy_cal""1.0"
    
cvar_oneround register_cvar("zp_jp_oneround""0"

     
    
register_event("CurWeapon""check_models""be"
    
register_event("DeathMsg""player_die""a"
    
register_event("HLTV""event_round_start""a""1=0""2=0"
     
    
register_forward(FM_StartFrame"fm_startFrame"
    
register_forward(FM_EmitSound"emitsound"


public 
plugin_precache() { 
    
precache_model("models/p_egon.mdl"
    
precache_model("models/v_egon.mdl"
    
precache_model("models/w_egon.mdl"
    
precache_sound("jetpack.wav"
    
precache_sound("jp_blow.wav"
     
    
precache_model(ROCKET_MDL
    
precache_sound(ROCKET_SOUND
    
precache_sound(getrocket
     
    
explosion precache_model("sprites/zerogxplode.spr"
    
trail precache_model("sprites/smoke.spr"
    
flame precache_model("sprites/xfireball3.spr"
    
white precache_model("sprites/white.spr"


public 
client_putinserver(id) { 
    
fly[id] = false 
    rocket
[id] = false 
    hasjet
[id] = 
    g_flyEnergy
[id] = 


public 
client_disconnect(id) { 
    
fly[id] = false 
    rocket
[id] = false 
    hasjet
[id] = 
    g_flyEnergy
[id] = 


public 
event_round_start() 

    
remove_jetpacks(); 
    if (
get_pcvar_num(cvar_oneround) == 1) { 
        for (new 
idid <= 32id++) hasjet[id] = 0g_flyEnergy[id] = 0,    fly[id] = false
    } 


public 
fm_startFrame(){ 
         
    
gltime get_gametime() 
    static 
id 
    
for (id 1id <= 32id++) 
    { 
        
jp_forward(id
    } 


public 
jp_forward(player) { 
     
    if (!
is_user_alive(player) && (zp_get_user_zombie(player) || zp_get_user_nemesis(player) || zp_get_user_survivor(player))) 
        return 
FMRES_IGNORED         
         
    
if (!hasjet[player]) 
        return 
FMRES_IGNORED 
     
    
if(jp_cal[player] < gltime){ 
        
jp_energy(player); jp_cal[player] = gltime get_pcvar_float(cvar_cal_time
    } 
     
    
check_rocket(player
     
    new 
clip,ammo 
    
new wpnid get_user_weapon(player,clip,ammo
    if (
wpnid == CSW_KNIFE){ 
        if(
get_pcvar_num(cvar_jetpack) == 1){ 
            if(!(
pev(playerpev_flags)&FL_ONGROUND) && pev(player,pev_button)&IN_ATTACK){ 
                if((
g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.3) && (g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery))){ 
                    if(
jp_soun[player] < gltime){ 
                        
emit_sound(player,CHAN_ITEM,"jetpack.wav",1.0,ATTN_NORM,1,PITCH_HIGH
                        
jp_soun[player] = gltime 1.0 
                    

                }             
                else if((
g_flyEnergy[player] > 0) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.3)){ 
                    if(
jp_soun[player] < gltime){ 
                            
emit_sound(player,CHAN_ITEM,"jp_blow.wav",1.0,ATTN_NORM,1,PITCH_HIGH
                            
jp_soun[player] = gltime 1.0 
                    

                } 
            } 
            
human_fly(player
            
attack(player)     
        } 
        if((
pev(player,pev_button)&IN_ATTACK2)){ 
                
attack2(player)     
            }     
    } 
    if((
get_pcvar_num(cvar_jetpack) == && !(pev(playerpev_flags)&FL_ONGROUND)) && (pev(player,pev_button)&IN_JUMP && pev(player,pev_button)&IN_DUCK)){             
        if((
g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.3) && (g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery))){ 
            if(
jp_soun[player] < gltime){ 
                
emit_sound(player,CHAN_ITEM,"jetpack.wav",1.0,ATTN_NORM,1,PITCH_HIGH
                
jp_soun[player] = gltime 1.0 
            

        }                     
        else if((
g_flyEnergy[player] > 0) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.3)){ 
            if(
jp_soun[player] < gltime){ 
                
emit_sound(player,CHAN_ITEM,"jp_blow.wav",1.0,ATTN_NORM,1,PITCH_HIGH
                
jp_soun[player] = gltime 1.0 
            

        } 
        
human_fly(player
        
attack(player
    } 
    
// Icon Show system 
    /*if (!is_user_alive(player) && zp_get_user_zombie(player) && zp_get_user_nemesis(player) && zp_get_user_survivor(player))     
        Icon_Energy({0, 255, 0}, 0, player); 
                //Icon_Energy({128, 128, 0}, 0, player); 
                //Icon_Energy({255, 255, 0}, 0, player); 
                         
    }*/ 
    
if((g_flyEnergy[player] >= get_pcvar_num(cvar_fly_max_engery)*0.8) && (g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery))){ 
        
Icon_Energy({02550}, 1player); // Green 
    

    else if((
g_flyEnergy[player] >= get_pcvar_num(cvar_fly_max_engery)*0.5) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.8)){ 
        
Icon_Energy({2552550}, 1player); // yellow 
    

    else if((
g_flyEnergy[player] >= get_pcvar_num(cvar_fly_max_engery)*0.3) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.5)){ 
        
Icon_Energy({2552150}, 2player); 
    } 
    else if((
g_flyEnergy[player] > 0) && (g_flyEnergy[player] < get_pcvar_num(cvar_fly_max_engery)*0.3)){ 
        
Icon_Energy({25500}, 1player); 
    } 
     
    return 
FMRES_IGNORED 


public 
jp_energy(player) { 
             
        if (!(
pev(playerpev_flags)&FL_ONGROUND) && pev(player,pev_button)&IN_ATTACK)     
        { 
            
// Get our current velocity         
            
new clip,ammo 
            
new wpnid get_user_weapon(player,clip,ammo
            if (
wpnid == CSW_KNIFE)  
            { 
            
// flying 
            
if(g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.09
                
g_flyEnergy[player] = g_flyEnergy[player] - get_pcvar_num(cvar_fly_engery);     // Increase distance counter         
            

        } 
        else if ((
get_pcvar_num(cvar_jetpack) == && !(pev(playerpev_flags)&FL_ONGROUND)) && (pev(player,pev_button)&IN_JUMP && pev(player,pev_button)&IN_DUCK)) 
        { 
            if(
g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.09
                
g_flyEnergy[player] = g_flyEnergy[player] - get_pcvar_num(cvar_fly_engery);     // Increase distance counter     
        

        
// Walking/Runnig 
        
if (pev(playerpev_flags) & FL_ONGROUND)     
            
g_flyEnergy[player] = g_flyEnergy[player] + get_pcvar_num(cvar_regain_energy);// Decrease distance counter 


public 
attack(player) { 
//code snippa from TS_Jetpack 1.0 - Jetpack plugin for The Specialists. 
//http://forums.alliedmods.net/showthread.php?t=55709&highlight=jetpack 
//By: Bad_Bud 
    
if(fly[player]) 
    {     
        static 
Float:JetpackData[3
        
pev(player,pev_velocity,JetpackData
                     
        new 
fOrigin[3],Float:Aim[3
        
VelocityByAim(player10Aim
        
get_user_origin(player,fOrigin
        
fOrigin[0] -= floatround(Aim[0]) 
        
fOrigin[1] -= floatround(Aim[1]) 
        
fOrigin[2] -= floatround(Aim[2]) 
         
         
        if((
pev(player,pev_button)&IN_FORWARD) && !(pev(playerpev_flags) & FL_ONGROUND)) 
            { 
                 
                
message_begin(MSG_ALL,SVC_TEMPENTITY
                
write_byte(17)  
                
write_coord(fOrigin[0]) 
                
write_coord(fOrigin[1]) 
                
write_coord(fOrigin[2]) 
                
write_short(flame
                
write_byte(10
                
write_byte(255
                
message_end()     
                 
                static 
Float:Speed 
                Speed
=floatsqroot(JetpackData[0]*JetpackData[0]+JetpackData[1]*JetpackData[1]) 
                     
                if(
Speed!=0.0)//Makes players only lay down if their speed isn't 0; if they are thrusting forward. 
                

                    
set_pev(player,pev_gaitsequence,0
                    
set_pev(player,pev_sequence,111
                } 
                     
                if(
Speed<get_pcvar_float(cvar_jetpackSpeed)) 
                    
Speed+=get_pcvar_float(cvar_jetpackAcrate
                         
                static 
Float:JetpackData2[3
                
pev(player,pev_angles,JetpackData2
                
JetpackData2[2]=0.0//Remove the Z value/ 
                     
                
angle_vector(JetpackData2,ANGLEVECTOR_FORWARD,JetpackData2
                
JetpackData2[0]*=Speed 
                JetpackData2
[1]*=Speed 
                     
                JetpackData
[0]=JetpackData2[0
                
JetpackData[1]=JetpackData2[1
            } 
             
        if(
JetpackData[2]<get_pcvar_float(cvar_jetpackSpeed)&&JetpackData[2]>0.0)//Jetpacks get more power on the way down -- it helps landing. 
                
JetpackData[2]+=get_pcvar_float(cvar_jetpackUpSpeed
            else if(
JetpackData[2]<0.0
                
JetpackData[2]+=(get_pcvar_float(cvar_jetpackUpSpeed)*1.15
                     
        
set_pev(player,pev_velocity,JetpackData
    } 


public 
attack2(player) { 
         
    if (
rocket[player]) 
    { 
         
        new 
rocket create_entity("info_target"
        if(
rocket == 0) return PLUGIN_CONTINUE 
         
        entity_set_string
(rocketEV_SZ_classname"zp_jp_rocket"
        
entity_set_model(rocketROCKET_MDL
         
        
entity_set_size(rocketFloat:{0.00.00.0}, Float:{0.00.00.0}) 
        
entity_set_int(rocketEV_INT_movetypeMOVETYPE_FLY
        
entity_set_int(rocketEV_INT_solidSOLID_BBOX
         
        new 
Float:vSrc[3
        
entity_get_vector(playerEV_VEC_originvSrc
         
        new 
Float:Aim[3],Float:origin[3
        
VelocityByAim(player64Aim
        
entity_get_vector(player,EV_VEC_origin,origin
         
        
vSrc[0] += Aim[0
        
vSrc[1] += Aim[1
        
entity_set_origin(rocketvSrc
         
        new 
Float:velocity[3], Float:angles[3
        
VelocityByAim(playerget_pcvar_num(cvar_RocketSpeed), velocity
         
        
entity_set_vector(rocketEV_VEC_velocityvelocity
        
vector_to_angle(velocityangles
        
entity_set_vector(rocketEV_VEC_anglesangles
        
entity_set_edict(rocket,EV_ENT_owner,player
        
entity_set_float(rocketEV_FL_takedamage1.0
         
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY
        
write_byte(TE_BEAMFOLLOW
        
write_short(rocket
        
write_short(trail
        
write_byte(25
        
write_byte(5
        
write_byte(224
        
write_byte(224
        
write_byte(255
        
write_byte(255
        
message_end() 

        
emit_sound(rocketCHAN_WEAPONROCKET_SOUND1.0ATTN_NORM0PITCH_NORM
         
        
shot[player] = true 
        last_Rocket
[player] = gltime get_pcvar_num(cvar_RocketDelay
    } 
    return 
PLUGIN_CONTINUE 


public 
check_models(id) { 

    if (
zp_get_user_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_survivor(id)) 
        return 
FMRES_IGNORED 
     
    
if(hasjet[id]) { 
        new 
clip,ammo 
        
new wpnid get_user_weapon(id,clip,ammo
         
        if ( 
wpnid == CSW_KNIFE ) { 
            
switchmodel(id
        } 
        return 
PLUGIN_CONTINUE 
    

    return 
PLUGIN_CONTINUE 


public 
switchmodel(id) { 
    
entity_set_string(id,EV_SZ_viewmodel,"models/v_egon.mdl"
    
entity_set_string(id,EV_SZ_weaponmodel,"models/p_egon.mdl"


public 
remove_jetpacks() { 
    new 
nextitem  find_ent_by_class(-1,"zp_jp_jetpack"
    while(
nextitem) { 
        
remove_entity(nextitem
        
nextitem find_ent_by_class(-1,"zp_jp_jetpack"
    } 
    return 
PLUGIN_CONTINUE 


public 
emitsound(entitychannel, const sample[]) { 
    if(
is_user_alive(entity)) { 
        new 
clip,ammo 
        
new weapon get_user_weapon(entity,clip,ammo
         
        if(
hasjet[entity] && weapon == CSW_KNIFE) { 
            if(
equal(sample,"weapons/knife_slash1.wav")) return FMRES_SUPERCEDE 
            
if(equal(sample,"weapons/knife_slash2.wav")) return FMRES_SUPERCEDE 
             
            
if(equal(sample,"weapons/knife_deploy1.wav")) return FMRES_SUPERCEDE 
            
if(equal(sample,"weapons/knife_hitwall1.wav")) return FMRES_SUPERCEDE 
             
            
if(equal(sample,"weapons/knife_hit1.wav")) return FMRES_SUPERCEDE 
            
if(equal(sample,"weapons/knife_hit2.wav")) return FMRES_SUPERCEDE 
            
if(equal(sample,"weapons/knife_hit3.wav")) return FMRES_SUPERCEDE 
            
if(equal(sample,"weapons/knife_hit4.wav")) return FMRES_SUPERCEDE 
             
            
if(equal(sample,"weapons/knife_stab.wav")) return FMRES_SUPERCEDE 
        

    } 
    return 
FMRES_IGNORED 


public 
Icon_Show(icon[], color[3], modeplayer) { 
             
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("StatusIcon"), {0,0,0}, player); 
    
write_byte(mode);     // status (0=hide, 1=show, 2=flash) 
    
write_string(icon);     // sprite name 
    
write_byte(color[0]);     // red 
    
write_byte(color[1]);     // green 
    
write_byte(color[2]);     // blue 
    
message_end(); 



public 
Icon_Energy(color[3], modeplayer) { 
     
    
Icon_Show("item_longjump"colormodeplayer


public 
human_fly(player) { 
     
    if (
g_flyEnergy[player] <= get_pcvar_num(cvar_fly_max_engery)*0.1
    { 
        
jp_off(player);     
    } 
    if (
g_flyEnergy[player] > get_pcvar_num(cvar_fly_max_engery)*0.1
    { 
        
jp_on(player); 
    } 


public 
jp_on(player) { 

    
fly[player] = true 
     


public 
jp_off(player) { 

    
fly[player] = false 
     


public 
check_rocket(player) { 
         
    if (
last_Rocket[player] > gltime
    {     
        
rk_forbidden(player
        
rksound[player] = true 
    

    else 
    {     

        if (
shot[player]) 
        { 
            
rksound[player] = false 
            shot
[player] = false 
        

        
rk_sound(player
        
rk_allow(player
    } 
     


public 
rk_allow(player) { 
         
    
rocket[player] = true 


public 
rk_forbidden(player) { 

    
rocket[player] = false 
     


public 
rk_sound(player) { 

    if (!
rksound[player]) 
    { 
        
engfunc(EngFunc_EmitSoundplayerCHAN_WEAPONgetrocket1.0ATTN_NORM0PITCH_NORM
        
client_print(playerprint_center"[Bazooka] Reloaded & Ready to use!!!"
        
rksound[player] = true 
    

    else if (
rksound[player]) 
    { 
         
    } 
     

         
public 
cmdHelp(id) { 
     
    new 
g_max get_pcvar_num(cvar_fly_max_engery
    new 
g_lost get_pcvar_num(cvar_fly_engery
    new 
g_back get_pcvar_num(cvar_regain_energy
    new 
g_dmg get_pcvar_num(cvar_RocketDmg
    new 
g_delay get_pcvar_num(cvar_RocketDelay)  
     
    new 
jpmotd[2048], title[64], dpos 
    format
(title,63,"[ZP] %s ver.%s",PLUGINNAME,VERSION
     
     
    
dpos += format(jpmotd[dpos],2047-dpos,"<html><head><style type=^"text/css^">pre{color:#FF0505;}body{background:#000000;margin-left:16px;margin-top:1px;}</style></head><pre><body>"
    
dpos += format(jpmotd[dpos],2047-dpos,"<b>%s</b>^n^n",title
     
    
dpos += format(jpmotd[dpos],2047-dpos,"How to use:^n"
    
dpos += format(jpmotd[dpos],2047-dpos,"=============^n^n"
    if(
get_pcvar_num(cvar_jetpack) == 1) { 
        
dpos += format(jpmotd[dpos],2047-dpos,"- choose/have Knive & use/hold ATTACK to fly^n"
        
dpos += format(jpmotd[dpos],2047-dpos,"^n"
        
dpos += format(jpmotd[dpos],2047-dpos,"- choose/have Knive(Bazooka) & use ATTACK2 to shoot a Rocket^n^n"
    } 
    else if(
get_pcvar_num(cvar_jetpack) == 2){ 
        
dpos += format(jpmotd[dpos],2047-dpos,"- use/hold JUMP & DUCK to flyn"
        
dpos += format(jpmotd[dpos],2047-dpos,"^n"
        
dpos += format(jpmotd[dpos],2047-dpos,"choose/have Knive(Bazooka) & use ATTACK2 to shoot a Rocket^n^n"
    } 
    
dpos += format(jpmotd[dpos],2047-dpos,"INFO's^n"
    
dpos += format(jpmotd[dpos],2047-dpos,"MAX Energy set to : <b>%i Units</b>^n^n"g_max
    
dpos += format(jpmotd[dpos],2047-dpos,"Jetpack need %i Units per 1 Sec. to work^n"g_lost
    
dpos += format(jpmotd[dpos],2047-dpos,"Energy regain %i Units per 1 Sec. (when you are on the ground)^n^n"g_back
    
dpos += format(jpmotd[dpos],2047-dpos,"MAX Rocket Dmg set to: <b>%i dmg</b>^n",g_dmg
    
dpos += format(jpmotd[dpos],2047-dpos,"New Rocket comes ervry <b>%i Sec.</b>^n^n"g_delay 
    
dpos += format(jpmotd[dpos],2047-dpos,"-Have Fun!^n"
     

    
show_motd(id,jpmotd,title


public 
player_die() { 
     
    new 
id read_data(2
    if(
hasjet[id]) { 
        
drop_jetpack(id
        
hasjet[id] = 
        rocket
[id] = false 
        g_flyEnergy
[id] = 
    

     
    return 
PLUGIN_CONTINUE 


public 
cmdDrop(id) { 

    if(
hasjet[id]) { 
        new 
clip,ammo 
        
new weapon get_user_weapon(id,clip,ammo
        if(
weapon == CSW_KNIFE) { 
            
drop_jetpack(id
            if(!
zp_get_user_zombie(id)){ 
                
entity_set_string(id,EV_SZ_viewmodel,"models/v_knife.mdl"
                
entity_set_string(id,EV_SZ_weaponmodel,"models/p_knife.mdl"
                } 
            return 
PLUGIN_HANDLED 
        

    } 
    return 
PLUGIN_CONTINUE 


public 
drop_jetpack(player) { 
    if(
hasjet[player]) { 
        new 
Float:Aim[3],Float:origin[3
        
VelocityByAim(player64Aim
        
entity_get_vector(player,EV_VEC_origin,origin
         
        
origin[0] += Aim[0
        
origin[1] += Aim[1
         
        new 
jetpack create_entity("info_target"
        
entity_set_string(jetpack,EV_SZ_classname,"zp_jp_jetpack"
        
entity_set_model(jetpack,"models/w_egon.mdl")     
         
        
entity_set_size(jetpack,Float:{-16.0,-16.0,-16.0},Float:{16.0,16.0,16.0}) 
        
entity_set_int(jetpack,EV_INT_solid,1
         
        
entity_set_int(jetpack,EV_INT_movetype,6
         
        
entity_set_vector(jetpack,EV_VEC_origin,origin
         
        
Icon_Energy({2552550}, 0player
        
Icon_Energy({1281280}, 0player 
        
Icon_Energy({02550}, 0player
         
        
hasjet[player] = 
        rocket
[player] = false 
    
}     


public 
pfn_touch(ptrptd) { 
    if(
is_valid_ent(ptr)) { 
        new 
classname[32
        
entity_get_string(ptr,EV_SZ_classname,classname,31
         
        if(
equal(classname"zp_jp_jetpack")) { 
            if(
is_valid_ent(ptd)) { 
                new 
id ptd 
                
if(id && id 34) { 
                    if(!
hasjet[id] && !zp_get_user_zombie(id) && is_user_alive(id)) { 
                         
                        
hasjet[id] = 
                        g_flyEnergy
[id] = get_pcvar_num(cvar_fly_max_engery
                        
rocket[id] = true 
                        client_cmd
(id,"spk items/gunpickup2.wav"
                        
engclient_cmd(id,"weapon_knife"
                        
switchmodel(id
                        
remove_entity(ptr
                    } 
                } 
            } 
        }else if(
equal(classname"zp_jp_rocket")) { 
            new 
Float:fOrigin[3
            new 
iOrigin[3
            
entity_get_vector(ptrEV_VEC_originfOrigin
            
FVecIVec(fOrigin,iOrigin
            
jp_radius_damage(ptr
                 
            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY,iOrigin
            
write_byte(TE_EXPLOSION
            
write_coord(iOrigin[0]) 
            
write_coord(iOrigin[1]) 
            
write_coord(iOrigin[2]) 
            
write_short(explosion
            
write_byte(30
            
write_byte(15
            
write_byte(0
            
message_end() 
                 
            
message_begin(MSG_ALL,SVC_TEMPENTITY,iOrigin
            
write_byte(TE_BEAMCYLINDER
            
write_coord(iOrigin[0]) 
            
write_coord(iOrigin[1]) 
            
write_coord(iOrigin[2]) 
            
write_coord(iOrigin[0]) 
            
write_coord(iOrigin[1]) 
            
write_coord(iOrigin[2]+200
            
write_short(white
            
write_byte(0
            
write_byte(1
            
write_byte(6
            
write_byte(8
            
write_byte(1
            
write_byte(255
            
write_byte(255
            
write_byte(192
            
write_byte(128
            
write_byte(5
            
message_end() 
             
            if(
is_valid_ent(ptd)) { 
                new 
classname2[32
                
entity_get_string(ptd,EV_SZ_classname,classname2,31
                 
                if(
equal(classname2,"func_breakable")) 
                    
force_use(ptr,ptd
            } 
             
            
remove_entity(ptr
        } 
    } 
    return 
PLUGIN_CONTINUE 


public 
zp_user_infected_pre(playerinfector){ 
     
    
Icon_Energy({02550}, 0player); 
    
cmdDrop(player); 
    
hasjet[player] = 0
    
g_flyEnergy[player] = 0
    
rocket[player] = false


public 
zv_extra_item_selected(playeritemid){ 
     

    new 
clip,ammo 
    
new weapon get_user_weapon(player,clip,ammo
         
    if (
itemid == g_item_jetpack
    { 
        
client_print(playerprint_chat"[ZP] say /jphelp for Display the help page"
        
hasjet[player] = 
        g_flyEnergy
[player] = get_pcvar_num(cvar_fly_max_engery
        
rocket[player] = true 
        client_cmd
(player,"spk items/gunpickup2.wav"
        if(
weapon == CSW_KNIFE){ 
            
switchmodel(player
        } 
        else 
        { 
            
engclient_cmd(player,"weapon_knife"),switchmodel(player
        } 
    } 


stock jp_radius_damage(entity) { 
    new 
id entity_get_edict(entity,EV_ENT_owner
    for(new 
133i++) { 
        if(
is_user_alive(i)) { 
            new 
dist floatround(entity_range(entity,i)) 
             
            if(
dist <= get_pcvar_num(cvar_Dmg_range)) { 
                new 
hp get_user_health(i
                new 
Float:damage get_pcvar_float(cvar_RocketDmg)-(get_pcvar_float(cvar_RocketDmg)/get_pcvar_float(cvar_Dmg_range))*float(dist
                 
                new 
Origin[3
                
get_user_origin(i,Origin
                 
                if(
zp_get_user_zombie(id) != zp_get_user_zombie(i)) { 
                        if(
hp damage
                            
jp_take_damage(i,floatround(damage),Origin,DMG_BLAST
                        else 
                            
log_kill(id,i,"Jetpack Rocket",0
                    } 
            } 
        } 
    } 


stock log_kill(killervictimweapon[], headshot

// code from MeRcyLeZZ 
    
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET
    
ExecuteHamB(Ham_Killedvictimkiller2// set last param to 2 if you want victim to gib 
    
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT

     
    
message_begin(MSG_BROADCASTget_user_msgid("DeathMsg")) 
    
write_byte(killer
    
write_byte(victim
    
write_byte(headshot
    
write_string(weapon
    
message_end() 
// 
     
    
if(get_user_team(killer)!=get_user_team(victim)) 
        
set_user_frags(killer,get_user_frags(killer) +1
    if(
get_user_team(killer)==get_user_team(victim)) 
        
set_user_frags(killer,get_user_frags(killer) -1
         
    new 
kname[32], vname[32], kauthid[32], vauthid[32], kteam[10], vteam[10

    
get_user_name(killerkname31
    
get_user_team(killerkteam9
    
get_user_authid(killerkauthid31
  
    
get_user_name(victimvname31
    
get_user_team(victimvteam9
    
get_user_authid(victimvauthid31
         
    
log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"",  
    
knameget_user_userid(killer), kauthidkteam,  
     
vnameget_user_userid(victim), vauthidvteamweapon

     return 
PLUGIN_CONTINUE


stock jp_take_damage(victim,damage,origin[3],bit) { 
    
message_begin(MSG_ONE,get_user_msgid("Damage"),{0,0,0},victim
    
write_byte(21
    
write_byte(20
    
write_long(bit
    
write_coord(origin[0]) 
    
write_coord(origin[1]) 
    
write_coord(origin[2]) 
    
message_end() 
     
    
set_user_health(victim,get_user_health(victim)-damage

Tnx, but what did you do ?? i got more items but when i put ZV it won't compile ... says
Code:
Error 035: argument type mismatch <argument 2>
__________________


Forum: www.Adrenaline-Zone.info
Johnnynho123 is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 02-22-2012 , 12:53   Re: [HELP] Vip extra
#4

Look carefully
Code:
g_item_jetpack = zv_register_extra_item("Jetpack+Bazooka", "(one Round)" , JETPACK_COST, ZV_TEAM_HUMAN)
Code:
g_item_jetpack = zv_register_extra_item("Jetpack+Bazooka (one Round)", JETPACK_COST, ZV_TEAM_HUMAN)
Code:
mismatch <argument 2>
This is argument 2
Code:
(one Round)
__________________

Last edited by H.RED.ZONE; 02-22-2012 at 12:55.
H.RED.ZONE is offline
Johnnynho123
Member
Join Date: Dec 2011
Location: Gradiska, Republic of Sr
Old 02-22-2012 , 19:52   Re: [HELP] Vip extra
#5

and what is wrong here ?
Code:
/*
	[ZP] Extra Item: Tau Cannon
	Copyright (C) 2009-2010 by NiHiLaNTh

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
	
	In addition, as a special exception, the author gives permission to
	link the code of this program with the Half-Life Game Engine ("HL
	Engine") and Modified Game Libraries ("MODs") developed by Valve,
	L.L.C ("Valve"). You must obey the GNU General Public License in all
	respects for all of the code used other than the HL Engine and MODs
	from Valve. If you modify this file, you may extend this exception
	to your version of the file, but you are not obligated to do so. If
	you do not wish to do so, delete this exception statement from your
	version.
	
	--- Introduction ---
	This plugin adds new weapon - Tau Cannon.Basically, this is almost
	the same weapon as in Half-Life.An experimental, highly unstable weapon. 
	One of the most important abilities is that it can shoot through walls, 
	making it so that you can't take cover against it. The gauss's primary 
	fire shoots out tiny spurts that are only effective in close to medium 
	range due to its erratic spread. You can charge up the gauss by holding 
	down alternate fire; the longer you charge it up, the stronger it gets. 
	The longer you charge it up is directly proportional to the thickness 
	of the wall you can shoot through. Lookout campers, retribution has come.
	
	---CVARs---
	zp_tcannon_oneround - Should Tau Cannon be in players inventory only for 1 round?
	zp_tcannon_dmgprim - Primary attack damage
	zp_tcannon_dmgsec - Maximal secondary attack damage
	zp_tcannon_clip - Clip amount
	
	--- Credits ---
	Arkshine, HL SDK, meTaLiCroSS and more...
	
	--- Changelog ---
	1.0 - Initial release.
	1.1 - Added some statics
	1.2 - Fixed ammo buy bug
	    - Fixed possible server crash
*/	
	
#include < amxmodx >
#include < cstrike >
#include < csx >
#include < engine >
#include < fakemeta >
#include < hamsandwich >
#include < fun >
#include < xs >
#include < zombieplague >
#include < zmvip >

// Plugin information
#define Plugin	"[ZP] Extra Item: Tau Cannon"
#define Version	"1.2"
#define Author	"NiHiLaNTh"

// Maxplayers
const MaxPlayers = 32

// Weapon models
new const g_szModelGaussP[ ] = "models/p_gauss.mdl"
new const g_szModelGaussV[ ] = "models/v_alt_gauss.mdl"
new const g_szModelGaussW[ ] = "models/w_gauss.mdl"

// Weapon sounds
new const g_szSoundGaussFire[ ] = "weapons/gauss2.wav"
new const g_szSoundGaussSpin[ ] = "ambience/pulsemachine.wav"
new const g_szSoundElectro1[ ] = "weapons/electro4.wav"
new const g_szSoundElectro2[ ] = "weapons/electro5.wav"
new const g_szSoundElectro3[ ] = "weapons/electro6.wav"

// Some gauss/beam stuff
#define GAUSS_REFIRERATE	0.2 // Primary attack
#define GAUSS_REFIRERATE2	0.1 // Secondary attack(you shouldnt change this!)
#define GAUSS_RECOIL		-2.0 // Only X axis!
#define GAUSS_CHARGETIME	4.0 // From HLSDK
#define GAUSS_RELOADTIME	2.0 // Reload time
#define BEAM_RED		255 // Red amount
#define BEAM_GREEN		128 // Green amount
#define BEAM_BLUE		0 // Blue amount
#define BEAM_ALPHA		255 // Brightness(Alpha)
#define BALL_AMOUNT		8 // How many balls should appear :p

// Ammo given when buy weapons	
new const BUYAMMO[] = { -1, 13, -1, 30, -1, 8, -1, 12, 30, -1, 30, 50, 12, 30, 30, 30, 12, 30,
1, 30, 30, 8, 30, 30, 30, -1, 7, 30, 30, -1, 50 }

// Max. bp ammo amount
new const MAXBPAMMO[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120,
	5, 120, 200, // This is gauss max bp ammo.Change it if you want!
32, 90, 120, 90, 2, 35, 90, 90, -1, 100 }

// Weapon ammo ID's
new const AMMOID[] = { -1, 9, -1, 2, 12, 5, 14, 6, 4, 13, 10, 7, 6, 4, 4, 4, 6, 10,
1, 10, 3, 5, 4, 10, 2, 11, 8, 4, 2, -1, 7 }

// Player variables
new g_iHasGauss[ MaxPlayers+1 ] // Whether player has gauss
new g_iSoundState[ MaxPlayers+1 ] // Weapon sound state
new g_bInAttack[ MaxPlayers+1 ] // Current gauss attack state
new g_iCurrentWeapon[ MaxPlayers+1 ] // Current weapon player is holding
new Float:g_flLastShotTime[ MaxPlayers+1 ] // Last shot time
new Float:g_fflPlayAfterShock[ MaxPlayers+1 ] // Play aftershock sound
new Float:g_flWeaponIdleTime[ MaxPlayers+1 ] // Weapon idle time
new Float:g_flNextAmmoBurn[ MaxPlayers+1 ] // Next ammo burn time
new Float:g_flStartCharge[ MaxPlayers+1 ] // Weapon start charge
new Float:g_flAmmoStartCharge[ MaxPlayers+1 ] // Ammo start charge
new bool:g_bIsAlive[ MaxPlayers+1 ] // Whether player is alive
new bool:g_bIsConnected[ MaxPlayers+1 ] // Whether player is connected
new bool:g_bPrimaryFire[ MaxPlayers+1 ] // Does this weapon is using primary attack ?
new bool:g_bKilledByLaser[ MaxPlayers+1 ] // Imma firin mah lazor O.o

// CVAR pointers
new cvar_oneround // Whether gun should be only for 1 round
new cvar_dmgprim // Primary attack damage
new cvar_dmgsec // Secondary attack damage
new cvar_clip // Clip amount

// Cached CVAR
new g_pOneRound
new Float:g_pDmgPrim
new Float:g_pDmgSec
new g_pClip

// Global varibles
new g_iMaxPlayers // Maxplayers
new bool:g_bGameRestart // Detect game restart
new g_iBeam // Beam sprite
new g_iBalls // Balls :p
new g_iGaussID // Item ID
new gmsgScreenFade // Screen fade
new gmsgAmmoPickup // Ammo pickup

// CS Offsets
const m_pPlayer = 41
const m_flNextPrimaryAttack = 46
const m_flNextSecondaryAttack = 47
const m_flTimeWeaponIdle = 48
const m_iPrimaryAmmoType = 49
const m_iClip = 51
const m_fInReload = 54
const m_flNextAttack  = 83
const m_rgAmmo_player_Slot0 = 376

// Macro 
#define is_user_valid_connected(%1)		( 1 <= %1 <= g_iMaxPlayers && g_bIsConnected [ %1 ] )
#define is_user_in_water(%1)			( pev ( %1, pev_waterlevel ) == 3 )
#define VectorSubtract(%1,%2,%3)		( %3[ 0 ] = %1[ 0 ] - %2[ 0 ], %3[ 1 ] = %1[ 1 ] - %2[ 1 ], %3[ 2 ] = %1[ 2 ] - %2[ 2 

] )
#define VectorAdd(%1,%2,%3)			( %3[ 0 ] = %1[ 0 ] + %2[ 0 ], %3[ 1 ] = %1[ 1 ] + %2[ 2 ], %3[ 2 ] = %1[ 

2 ] + %2[ 2 ] )
#define VectorScale(%1,%2,%3)    		( %3[ 0 ] = %2 * %1[ 0 ], %3[ 1 ] = %2 * %1[ 1 ], %3[ 2 ] = %2 * %1[ 2 ] )
#define VectorLength(%1)         		( floatsqroot ( %1[ 0 ] * %1[ 0 ] + %1[ 1 ] * %1[ 1 ] + %1[ 2 ] * %1[ 2 ] ) )

// Hack!Custom fields
#define pev_weaponkey		pev_impulse
#define pev_bpammo		pev_iuser3

// Misc stuff
#define FCVAR_FLAGS		( FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED )
#define GAUSS_WEAPONKEY	42856
#define NULLENT		-1
#define FFADE_IN		0x0000
#define UNIT_SECOND		(1<<12)

// Entity classnames
new const g_szClassPlayer[ ] = "player"
new const g_szClassM249[ ] = "weapon_m249"

// Primary weapon bitsum
const PRIMARY_WEAPONS_BITSUM = 

(1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GA

LIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TM

P)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)

// Animation sequnces
enum
{
	gauss_idle,
	gauss_idle2,
	gauss_fidget,
	gauss_spinup,
	gauss_spin,
	gauss_fire,
	gauss_fire2,
	gauss_holster,
	gauss_draw
}

// Precache
public plugin_precache( )
{
	// Weapon models
	precache_model( g_szModelGaussP )
	precache_model( g_szModelGaussV )
	precache_model( g_szModelGaussW )
	
	// Sounds
	precache_sound( g_szSoundGaussFire )
	precache_sound( g_szSoundGaussSpin )
	precache_sound( g_szSoundElectro1 )
	precache_sound( g_szSoundElectro2 )
	precache_sound( g_szSoundElectro3 )
	precache_sound( "items/9mmclip1.wav" )
	
	// Sprites
	g_iBeam = precache_model( "sprites/smoke.spr" )
	g_iBalls = precache_model( "sprites/hotglow.spr" )
}

// Initialization
public plugin_init( )
{
	// New plugin
	register_plugin( Plugin, Version, Author )
	
	// For Game-Monitor support
	register_cvar( "zp_tcannon_version", Version, FCVAR_FLAGS )
	
	// New extra item
	g_iGaussID = zv_register_extra_item( "Tau Cannon", 60, ZV_TEAM_HUMAN )
	
	// Client commands
	register_clcmd( "buyammo1", "fn_BuyAmmo" )
	register_clcmd( "buyammo2", "fn_BuyAmmo" )
	
	// Events
	register_event( "CurWeapon", "EV_CurWeapon", "be", "1=1" )
	register_event( "DeathMsg", "EV_DeathMsg", "a" )
	register_event( "HLTV", "EV_RoundStart", "a", "1=0", "2=0" )
	register_event( "TextMsg", "EV_GameRestart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in" )
	
	// FakeMeta forwards
	register_forward( FM_SetModel, "fw_SetModel" )
	register_forward( FM_CmdStart, "fw_CmdStart" )
	register_forward( FM_UpdateClientData, "fw_UpdateClientData_Post", 1 )
	register_forward( FM_PlayerPreThink, "fw_PlayerPreThink" )
	
	// HamSandwich forwards
	RegisterHam( Ham_Spawn, g_szClassPlayer, "fw_PlayerSpawn_Post", 1 )
	RegisterHam( Ham_Item_Deploy, g_szClassM249, "fw_TCannonDeploy_Post", 1 )
	RegisterHam( Ham_Item_Holster, g_szClassM249, "fw_TCannonHolster_Post", 1 )
	RegisterHam( Ham_Item_AddToPlayer, g_szClassM249, "fw_TCannonAddToPlayer" )
	RegisterHam( Ham_Item_PostFrame, g_szClassM249, "fw_TCannonPostFrame" )
	RegisterHam( Ham_Weapon_Reload, g_szClassM249, "fw_TCannonReload_Post", 1 )
	
	// CVARs are in Load_Cvars( ) function!
	
	// Messages
	register_message( get_user_msgid( "DeathMsg" ), "fn_DeathMsg" )
	gmsgScreenFade = get_user_msgid( "ScreenFade" )
	gmsgAmmoPickup = get_user_msgid( "AmmoPickup" )
	
	// Store maxplayers in a global variable
	g_iMaxPlayers = get_maxplayers( )
}	

// Configuration
public plugin_cfg( )
{
	// Cache CVARs
	set_task( 1.5, "Load_Cvars" )
}

// ------------------------------- Game Events ----------------------------------------

// Client connected
public client_connect( Player )
{
	// Make a lot of updates
	g_iHasGauss[ Player ] = false
	g_bInAttack[ Player ] = 0
	g_fflPlayAfterShock[ Player ] = 0.0
	g_flWeaponIdleTime[ Player ] = 0.0
	g_bPrimaryFire[ Player ] = false
	g_bIsAlive[ Player ] = false
	g_bIsConnected[ Player ] = true
}

// Client disconnected
public client_disconnect( Player )
{
	// Only few important updates
	g_bIsAlive[ Player ] = false
	g_bIsConnected[ Player ] = false
}

// Someone selected our extra item
public zv_extra_item_selected( Player, Item )
{
	// Tau Cannon
	if ( Item == g_iGaussID )
	{
		// Drop all primary weapons
		UTIL_DropPrimary( Player )
		
		// Update
		g_iHasGauss[ Player ] = true
		
		// Give m249
		give_item( Player, "weapon_m249" )
		
		// Find weapon entity
		new iEnt = find_ent_by_owner( NULLENT, g_szClassM249, Player )
		
		// Apply new clip
		cs_set_weapon_ammo( iEnt, g_pClip )
		
		// Back pack ammo
		cs_set_user_bpammo( Player, CSW_M249, MAXBPAMMO[ 20 ] )
	}
}

// Player is trying to buy something
public fn_BuyAmmo( Player )
{
	// Not alive
	if( !g_bIsAlive[ Player ] )
		return PLUGIN_HANDLED
	
	// Dont have Tau Cannon
	if( !g_iHasGauss[ Player ] )
		return PLUGIN_CONTINUE
	
	// Retrieve ammo pack amount
	static iAmmoPack
	iAmmoPack = zp_get_user_ammo_packs( Player )
	
	// Out of ammo packs
	if( iAmmoPack <= 0 )
		return PLUGIN_HANDLED
	
	// Get players weapons
	static weapons[ 32 ], num, i, currentammo, weaponid, refilled
	num = 0 // reset passed weapons count (bugfix)
	refilled = false
	get_user_weapons( Player, weapons, num )
	
	// Loop through them and give the right ammo type
	for( i = 0; i < num; i++ )
	{
		// Prevents re-indexing the array
		weaponid = weapons[ i ]
		
		// Primary and secondary only
		if( MAXBPAMMO[ weaponid ] > 2 )
		{
			// Get current ammo of the weapon
			currentammo = cs_get_user_bpammo( Player, weaponid)
			
			// Check if we are close to the BP ammo limit
			if (currentammo < MAXBPAMMO[weaponid]-BUYAMMO[weaponid])
			{
				// Flash ammo in hud
				message_begin(MSG_ONE_UNRELIABLE, gmsgAmmoPickup, _, Player )
				write_byte(AMMOID[weaponid]) // ammo id
				write_byte(BUYAMMO[weaponid]) // ammo amount
				message_end()
				
				// Increase BP ammo
				cs_set_user_bpammo ( Player, weaponid, currentammo + BUYAMMO[weaponid])
				
				refilled = true
			}
			else if (currentammo < MAXBPAMMO[weaponid])
			{
				// Flash ammo in hud
				message_begin(MSG_ONE_UNRELIABLE, gmsgAmmoPickup, _, Player )
				write_byte(AMMOID[weaponid]) // ammo id
				write_byte(MAXBPAMMO[weaponid]-currentammo) // ammo amount
				message_end()
				
				// Reached the limit
				cs_set_user_bpammo ( Player, weaponid, MAXBPAMMO[weaponid])
				
				refilled = true
			}
		}
	}
	
	// Weapons already have full ammo
	if (!refilled) return PLUGIN_HANDLED
	
	// Deduce ammo packs, play clip purchase sound, and notify the player
	zp_set_user_ammo_packs( Player, --iAmmoPack )
	engfunc(EngFunc_EmitSound, Player, CHAN_ITEM, "items/9mmclip1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
	client_print( Player, print_chat, "[ZP] You purchased extra ammo for your guns." )
	
	return PLUGIN_HANDLED
}	

// Current weapon player is holding
public EV_CurWeapon( Player )
{
	// Not alive
	if( !g_bIsAlive[ Player ] )
		return PLUGIN_CONTINUE
	
	// Update
	g_iCurrentWeapon[ Player ] = read_data( 2 )
	
	return PLUGIN_CONTINUE
}

// Someone died
public EV_DeathMsg( )
{
	// Get victim
	static iVictim
	iVictim = read_data( 2 )
	
	// Not connected
	if( !is_user_valid_connected( iVictim ) )
		return
	
	// Update
	g_bIsAlive[ iVictim ] = false
	
	// Check if victim has gauss
	if( g_iHasGauss[ iVictim ] && !is_user_bot( iVictim ) )
	{
		// Force to drop
		engclient_cmd( iVictim, "drop weapon_m249" )
	}
}

// Round started
public EV_RoundStart( )
{
	// Restart/One round only
	if( g_bGameRestart || g_pOneRound )
	{
		// Reset array value
		arrayset( g_iHasGauss, false, MaxPlayers+1 )
	}
	
	// Update
	g_bGameRestart = false
}

// Game restart
public EV_GameRestart( )
{
	// Update
	g_bGameRestart = true
}

// Hook death message
public fn_DeathMsg( Player, Dest, iEntity )
{
	// Get victim
	static iVictim, iKiller
	iKiller = get_msg_arg_int( 1 )
	iVictim = get_msg_arg_int( 2 )
	
	// Not connected
	if( !is_user_valid_connected( iVictim ) || iKiller == iVictim )
		return PLUGIN_CONTINUE
	
	// We were killed by laser
	if ( g_bKilledByLaser[ iVictim ] )
	{
		// Replace name in console
		set_msg_arg_string ( 4, "tau cannon" )
	}
	return PLUGIN_CONTINUE
}

// ------------------------------- Forwards ----------------------------------------

// Replace world model
public fw_SetModel ( Entity, const Model [ ] )
{
	// Prevent invalid entity messages
	if( !pev_valid( Entity ) )
		return FMRES_IGNORED
	
	// Not w_awp.mdl
	if( !equal( Model, "models/w_m249.mdl" ) )
		return FMRES_IGNORED
	
	// Get entity classname
	static szClassname[ 32 ]
	pev( Entity, pev_classname, szClassname, charsmax( szClassname ) )
	
	// Not weaponbox
	if( !equal( szClassname, "weaponbox" ) )
		return FMRES_IGNORED
	
	// Get owner
	static iOwner
	iOwner = pev( Entity, pev_owner )
	
	// Get awp ID
	static iWeaponID
	iWeaponID = find_ent_by_owner( NULLENT, g_szClassM249, Entity )
	
	// Make sure that we have gauss
	if( g_iHasGauss [ iOwner ] && is_valid_ent( iWeaponID ) )
	{
		// Hack! Store weaponkey
		set_pev( iWeaponID, pev_weaponkey, GAUSS_WEAPONKEY )
		
		// Hack! Store bp ammo
		set_pev( iWeaponID, pev_bpammo, cs_get_user_bpammo( iOwner, CSW_M249 ) )
		
		// Update
		g_iHasGauss[ iOwner ] = false
		
		// Replace models
		engfunc( EngFunc_SetModel, Entity, g_szModelGaussW )
		return FMRES_SUPERCEDE
	}
	return FMRES_IGNORED
}

// Command start
public fw_CmdStart( Player, UC_Handle, Seed )
{
	// Not alive/dont have gauss/not m249
	if( !g_bIsAlive[ Player ] || !g_iHasGauss[ Player ] || g_iCurrentWeapon[ Player ] != CSW_M249 )
		return FMRES_IGNORED
	
	// Retrieve pressed button bitsum
	static iButtons
	iButtons = get_uc( UC_Handle, UC_Buttons )
	
	// Retrieve game time
	static Float:flGameTime
	flGameTime = get_gametime( )
	
	// Retrieve weapon entity
	static iEnt
	iEnt = find_ent_by_owner( NULLENT, g_szClassM249, Player )
	
	// Retrieve clip amount
	static iClip
	iClip = cs_get_weapon_ammo( iEnt )
	
	// Primary attack
	if( iButtons & IN_ATTACK )
	{
		// Remove attack buttons from their button mask
		iButtons &= ~IN_ATTACK
		set_uc( UC_Handle, UC_Buttons, iButtons )
		
		// Prevent too fast shooting
		if( flGameTime - g_flLastShotTime[ Player ] < GAUSS_REFIRERATE )
			return FMRES_IGNORED
		
		// Dont fire while reloading
		if( get_pdata_int( iEnt, m_fInReload, 4 ) )
			return FMRES_IGNORED
		
		// Not enough clip/under water
		if( iClip < 2 || is_user_in_water( Player ) )
		{
			// Emit empty sound
			ExecuteHamB( Ham_Weapon_PlayEmptySound, iEnt )
			return FMRES_IGNORED
		}
		
		// Update
		g_bPrimaryFire[ Player ] = true
		
		// Start to fire
		StartFire( Player )
		
		// Decrease clip
		cs_set_weapon_ammo( iEnt, iClip-2 )
		
		// Reset weapon attack status
		g_bInAttack[ Player ] = 0
		
		// Set time when idle animation should be played
		g_flWeaponIdleTime[ Player ] = flGameTime + 1.0
		
		// Remember last shot time
		g_flLastShotTime[ Player ] = flGameTime
	}
	// Secondary attack
	else if( iButtons & IN_ATTACK2 )
	{
		// Prevent too fast shooting
		if( flGameTime - g_flLastShotTime[ Player ] < GAUSS_REFIRERATE2 )
			return FMRES_IGNORED
		
		// Dont fire while reloading
		if( get_pdata_int( iEnt, m_fInReload, 4 ) )
			return FMRES_IGNORED
		
		// Are we swimming ?
		if( is_user_in_water( Player ) )
		{
			// We are in a middle of attack
			if( g_bInAttack[ Player ] != 0 )
			{
				// Stop attack
				emit_sound( Player, CHAN_WEAPON, g_szSoundElectro1, VOL_NORM, ATTN_NORM, 0, 

80 + random_num( 0, 0x3f ) )
				
				// Gun idle
				UTIL_PlayWeaponAnimation( Player, gauss_idle )
				return FMRES_IGNORED
			}
			else
			{
				// Empty sound
				ExecuteHamB( Ham_Weapon_PlayEmptySound, iEnt )
				return FMRES_IGNORED
			}
		}
		
		// Get player oldbuttons
		static iOldButtons
		iOldButtons = pev( Player, pev_oldbuttons )
		
		// Make sure that we are holding secondary attack button
		if( iOldButtons & IN_ATTACK2 )
		{
			// Which attack state do we have
			switch ( g_bInAttack[ Player ] )
			{
				case 0: // Attack start
				{
					// Out of ammo
					if ( iClip <= 0 )
					{
						ExecuteHamB( Ham_Weapon_PlayEmptySound, iEnt )
						return FMRES_IGNORED
					}
					
					// We aren't using primary attack anymore
					g_bPrimaryFire[ Player ] = false
					
					// Decrease clip
					cs_set_weapon_ammo( iEnt, --iClip )
					
					// Update
					g_flNextAmmoBurn[ Player ] = flGameTime
					
					// Send spinup animation
					UTIL_PlayWeaponAnimation( Player, gauss_spinup )
					
					// Update attack state
					g_bInAttack[ Player ] = 1
					
					// Next idle time
					g_flWeaponIdleTime[ Player ] = flGameTime + 0.5
					
					// Update
					g_flStartCharge[ Player ] = flGameTime
					g_flAmmoStartCharge[ Player ] = flGameTime + GAUSS_CHARGETIME
					
					// Update sound state
					g_iSoundState[ Player ] = 0
					
					// Spin sound
					emit_sound( Player, CHAN_WEAPON, g_szSoundGaussSpin, VOL_NORM, 

ATTN_NORM, g_iSoundState[Player ], 110 )
					
					// Change sound state
					g_iSoundState[ Player ] = SND_CHANGE_PITCH
				}
				case 1: // In a middle of attack
				{
					if( g_flWeaponIdleTime[ Player ] < flGameTime )
					{
						// Spin anim
						UTIL_PlayWeaponAnimation( Player, gauss_spin )
						
						// Update state
						g_bInAttack[ Player ] = 2
					}
				}
				default: // End of attack
				{
					// During the charging process, eat one bit of ammo every once in a while
					if( flGameTime >= g_flNextAmmoBurn[ Player ] && g_flNextAmmoBurn[ Player ] != 

1000 )
					{
						// Decrease clip
						cs_set_weapon_ammo( iEnt, --iClip )
						
						// Next time when ammo should be decreased
						g_flNextAmmoBurn[ Player ] = flGameTime + 0.1
					}
					
					// Shit!We run out of ammo
					if( iClip <= 0 )
					{
						// Force gun to fire
						StartFire( Player )
						
						// Reset weapon state
						g_bInAttack[ Player ] = 0
						
						// Set next idle time
						g_flWeaponIdleTime[ Player ] = flGameTime + 1.0
					}
					
					// Gun is fully charged up
					if( flGameTime >= g_flAmmoStartCharge[ Player ] )
					{
						// Dont eat any more ammo!
						g_flNextAmmoBurn[ Player ] = 1000.0
					}
					
					// Calculate pitch
					static Float:flPitch
					flPitch = ( flGameTime - g_flStartCharge[ Player ] ) * ( 150 / 

GAUSS_CHARGETIME ) + 100
					
					// Pitch shouldnt be THAT big
					if ( flPitch > 250 )
					{
						flPitch = 250.0
					}
					
					// Spin sound
					emit_sound( Player, CHAN_WEAPON, g_szSoundGaussSpin, VOL_NORM, 

ATTN_NORM, ( g_iSoundState[ Player ] == SND_CHANGE_PITCH ) ? 1 : 0, floatround( flPitch ) )
					
					// Hack for going through level transitions
					g_iSoundState[ Player ] = SND_CHANGE_PITCH
					
					// We are charing way too long!
					if( g_flStartCharge[ Player ] < flGameTime - 10 )
					{
						// ZAP!
						emit_sound( Player, CHAN_WEAPON, g_szSoundElectro1, 

VOL_NORM, ATTN_NORM, 0, 80 + random_num( 0, 0x3f ) )
						emit_sound( Player, CHAN_VOICE, g_szSoundElectro3, VOL_NORM, 

ATTN_NORM, 0, 80 + random_num( 0, 0x3f ) )
						
						// Reset fire state
						g_bInAttack[ Player ] = 0
						
						// Next idle time
						g_flWeaponIdleTime[ Player ] = flGameTime + 1.0
						
						// Damage player
						ExecuteHamB( Ham_TakeDamage, Player, 0, Player, 50.0, 

DMG_SHOCK )
						
						// Make screen fade
						UTIL_ScreenFade( Player, UNIT_SECOND*2, UNIT_SECOND/2, 

FFADE_IN, 255, 128, 0, 128 )
						
						// Idle animation
						UTIL_PlayWeaponAnimation( Player, gauss_idle )
					}
				}
			}
			
			// Update
			g_flLastShotTime[ Player ] = flGameTime
		}
	}
	
	return FMRES_HANDLED
}

// Update client data post
public fw_UpdateClientData_Post ( Player, SendWeapons, CD_Handle )
{
	// Not alive / dont have gauss/ not m249
	if ( !g_bIsAlive [ Player ] || !g_iHasGauss [ Player ] || g_iCurrentWeapon [ Player ] != CSW_M249 )
		return FMRES_IGNORED
	
	// Block default sounds/animations
	set_cd ( CD_Handle, CD_flNextAttack, halflife_time ( ) + 0.001 )
	return FMRES_HANDLED
}

// Player pre think
public fw_PlayerPreThink( Player )
{
	// Not alive / dont have gauss/ not m249
	if ( !g_bIsAlive [ Player ] || !g_iHasGauss [ Player ] || g_iCurrentWeapon [ Player ] != CSW_M249 )
		return
	
	// Play aftershock discharge
	if( g_fflPlayAfterShock[ Player ] && g_fflPlayAfterShock[ Player ] < get_gametime( ) )
	{
		// Randomly play sound
		switch( random_num(0, 3 ) )
		{
			case 0: emit_sound( Player, CHAN_WEAPON, g_szSoundElectro1,random_float( 0.7, 0.8 ), 

ATTN_NORM, 0, PITCH_NORM )
				case 1: emit_sound( Player, CHAN_WEAPON, g_szSoundElectro2,random_float( 0.7, 0.8 ), 

ATTN_NORM, 0, PITCH_NORM )
				case 2: emit_sound( Player, CHAN_WEAPON, g_szSoundElectro3,random_float( 0.7, 0.8 ), 

ATTN_NORM, 0, PITCH_NORM )
				case 3: return // No sound
			}
		
		// Reset discharge
		g_fflPlayAfterShock[ Player ] = 0.0
	}
	
	// Check if we are in a middle of attack
	if( g_bInAttack[ Player ] != 0 )
	{
		// Check if have released attack2 button
		if( get_gametime( ) - g_flLastShotTime[ Player ] > 0.2 )
		{
			// Start to fire
			StartFire( Player )
			
			// Reset attack state
			g_bInAttack[ Player ] = 0
			
			// Next idle time
			g_flWeaponIdleTime[ Player ] = get_gametime( ) + 2.0 
		}
	}
	else
	{
		// Force to idle
		WeaponIdle( Player )
	}
}

// Player respawned
public fw_PlayerSpawn_Post( Player )
{
	// Not alive
	if( !is_user_alive( Player ) )
		return
	
	// Update
	g_bIsAlive[ Player ] = true
}

// Guass deploy
public fw_TCannonDeploy_Post( iEnt )
{
	// Get owner
	static Player
	Player = get_pdata_cbase( iEnt, m_pPlayer, 4 )
	
	// Does this player has gauss?
	if ( g_iHasGauss[ Player ] )
	{
		// Replace models
		set_pev( Player, pev_viewmodel2, g_szModelGaussV )
		set_pev( Player, pev_weaponmodel2, g_szModelGaussP )
		
		// Deploy animation
		UTIL_PlayWeaponAnimation( Player, gauss_draw )
		
		// Reset aftershock
		g_fflPlayAfterShock[ Player ] = 0.0
	}
}

// Gauss holster
public fw_TCannonHolster_Post( iEnt )
{
	// Get owner
	static Player
	Player = get_pdata_cbase( iEnt, m_pPlayer, 4 )
	
	// Does this player has gauss?
	if ( g_iHasGauss[ Player ] )
	{
		// Check if player is still attacking
		if( g_bInAttack[ Player ] )
		{
			// Bug!Bug!Stop spin sound
			emit_sound( Player, CHAN_WEAPON, g_szSoundGaussSpin, 0.0, 0.0, SND_STOP, 0 )
			
			// Attack
			StartFire( Player )
		}
		
		// Holster animation
		UTIL_PlayWeaponAnimation( Player, gauss_holster )
		
		// Reset attack status
		g_bInAttack[ Player ] = 0
	}
}

// Add Gauss to players inventory
public fw_TCannonAddToPlayer( iEnt, Player )
{
	// Prevent run-time errors
	if( is_valid_ent( iEnt ) && is_user_valid_connected( Player ) )
	{
		// Seems that player has picked up a gauss
		if( pev( iEnt, pev_weaponkey ) == GAUSS_WEAPONKEY )
		{
			// Update variable
			g_iHasGauss[ Player ] = true
			
			// Update bp ammo
			cs_set_user_bpammo( Player, CSW_M249, pev( iEnt, pev_bpammo ) )
			
			// Reset weapon options
			set_pev( iEnt, pev_weaponkey, 0 )
			set_pev( iEnt, pev_bpammo, 0 )
			
			return HAM_HANDLED
		}
	}
	return HAM_IGNORED
}

// Gauss post frame
public fw_TCannonPostFrame( iEnt )
{
	// Get owner
	static iOwner
	iOwner = get_pdata_cbase( iEnt, m_pPlayer, 4 )
	
	// Does this player has gauss?
	if ( g_iHasGauss[ iOwner ] )
	{
		// Reload offset
		static fInReload 
		fInReload = get_pdata_int ( iEnt, m_fInReload,4 )
		
		// Next attack time
		static Float:flNextAttack 
		flNextAttack = get_pdata_float (iOwner, m_flNextAttack, 5 )
		
		// Clip
		static iClip
		iClip = get_pdata_int ( iEnt, m_iClip, 4 )
		
		// Ammo type
		static iAmmoType 
		iAmmoType = m_rgAmmo_player_Slot0 + get_pdata_int ( iEnt, m_iPrimaryAmmoType, 4 )
		
		// BP ammo
		static iBpAmmo
		iBpAmmo = get_pdata_int ( iOwner, iAmmoType, 5 )	
		
		// Reloading
		if ( fInReload && flNextAttack <= 0.0 )
		{
			// Calculate the difference
			static j 
			j = min ( g_pClip - iClip, iBpAmmo )
			
			// Set new clip
			set_pdata_int ( iEnt, m_iClip, iClip + j, 4 )
			
			// Decrease 'x' bullets from backpack(depending on new clip)
			set_pdata_int( iOwner, iAmmoType, iBpAmmo-j, 5 )
			
			// Not reloding anymore
			set_pdata_int ( iEnt, m_fInReload, 0, 4 )
			fInReload = 0
		}
		
		// Get buttons
		static iButton ; iButton = pev ( iOwner, pev_button)
		
		// Attack/Attack2 buttons and next prim/sec attack time hasnt' come yet
		if( ( iButton & IN_ATTACK2 && get_pdata_float ( iEnt, m_flNextSecondaryAttack, 4 ) <= 0.0)
		|| ( iButton & IN_ATTACK && get_pdata_float ( iEnt, m_flNextPrimaryAttack, 4 ) <= 0.0) )
		{
			return
		}
	
		// Reload button / not reloading
		if( iButton & IN_RELOAD && !fInReload )
		{
			// Old clip is more/equal than/to new
			if( iClip >= g_pClip )
			{
				// Remove reload button
				set_pev ( iOwner, pev_button, iButton & ~IN_RELOAD )
				
				// Idle animation
				UTIL_PlayWeaponAnimation ( iOwner, gauss_idle )
				
				// Idle time
				g_flWeaponIdleTime[ iOwner ] = get_gametime( ) + 0.5
			}
			else
			{
				// Out of ammo
				if ( !iBpAmmo )
					return
					
				// Reload weapon
				UTIL_WeaponReload ( iOwner, iEnt )
			}
		}
	}
}

// Gauss reload post
public fw_TCannonReload_Post( iEnt )
{
	// Get owner
	static Player
	Player = get_pdata_cbase( iEnt, m_pPlayer, 4 )
	
	// Does this player has gauss and is he in a middle of reloading ?
	if ( g_iHasGauss[ Player ] && get_pdata_int( iEnt, m_fInReload, 4 ) )
	{
		// Reload
		UTIL_WeaponReload( Player, iEnt )
	}
}

// ------------------------------- Internal Functions ----------------------------------------

// Gauss start fire
public StartFire( Player )
{
	// This var holds damage
	static Float:flDamage
	
	// Make vectors
	UTIL_MakeVectors( Player )
	
	// Get gametime
	static Float:flGameTime
	flGameTime = get_gametime( )
	
	// This is maximal possible damage from secondary attack!
	if( flGameTime - g_flStartCharge[ Player ] > GAUSS_CHARGETIME )
	{
		flDamage = g_pDmgSec
	}
	else
	{
		// The longer you hold attack button - the bigger is damage
		flDamage = g_pDmgSec * ( ( flGameTime - g_flStartCharge[ Player ] ) / GAUSS_CHARGETIME )
	}
	
	// Primary attack do less damage
	if( g_bPrimaryFire[ Player ] )
	{
		flDamage = g_pDmgPrim
	}
	
	// Make sure that we are not ending attack
	if( g_bInAttack[ Player ] != 3 )
	{
		// Secondary attack can pop you up in the air.Not primary attack!
		if( !g_bPrimaryFire[ Player ] )
		{
			// Current players velocity
			static Float:flVel[ 3 ], Float:v_forward[ 3 ]
			pev( Player, pev_velocity, flVel )
			global_get( glb_v_forward, v_forward )
			
			// Try to affect only vertical velocity
			VectorMS( flVel, flDamage * 5.0, v_forward, flVel )
			
			// Jump!
			set_pev( Player, pev_velocity, flVel )
		}
	}
	
	// Recoil
	static Float:flRecoil[ 3 ]
	flRecoil[ 0 ] = GAUSS_RECOIL
	set_pev( Player, pev_punchangle, flRecoil )
	
	// Fire animation
	UTIL_PlayWeaponAnimation( Player, gauss_fire2 )
	
	// Fire sound
	static Float:flResult
	flResult = 0.5 + flDamage * ( 1.0 / 400.0 )
	
	if( flResult > 1.0 )
	{
		flResult = 1.0
	}
	
	emit_sound( Player, CHAN_WEAPON, g_szSoundGaussFire, flResult, ATTN_NORM, 0, 85 + random_num( 0, 0x1f ) )
	
	// Get players aimpoint position
	static Float:vecDest[ 3 ]
	global_get( glb_v_forward, vecDest )
	
	// Calculate start position
	static Float:vecSrc[ 3 ]
	UTIL_GetGunPosition( Player, vecSrc )
	
	// Time until aftershock 'static discharge' sound
	g_fflPlayAfterShock[ Player ] = flGameTime + random_float( 0.3, 0.8 )
	
	// Fire!
	Fire( Player, vecSrc, vecDest, flDamage )
}

// Fire!
Fire( Player, Float:vecOrigSrc[ ], Float:vecDir[ ], Float:flDamage )
{
	// Start position
	static Float:vecSrc[ 3 ]
	xs_vec_copy( vecOrigSrc, vecSrc )
	
	// Calculate end position
	static Float:vecDest[ 3 ]
	VectorMA( vecSrc, 8192.0, vecDir, vecDest )
	
	// Few trace handles
	static tr, beam_tr
	
	// Max fraction
	static Float:flMaxFrac
	flMaxFrac = 1.0
	
	// Total
	static nTotal
	nTotal = 0
	
	// Does this beam punched the wall ?
	static bool:fHasPunched
	fHasPunched = false
	
	// Does this is first beam
	static bool:fFirstBeam
	fFirstBeam = true
	
	// Max hits
	static nMaxHits
	nMaxHits = 10
	
	// Entity whoch should be ignored
	static pEntToIgnore
	
	// Make sure that beam will'be able to cause damage
	while( flDamage > 10 && nMaxHits > 0 )
	{
		// Decrease hit count
		nMaxHits--
		
		// Draw a trace line
		engfunc( EngFunc_TraceLine, vecSrc, vecDest, DONT_IGNORE_MONSTERS, pEntToIgnore, tr )
		
		// We'll never get outside!
		if( get_tr2( tr, TR_AllSolid ) )
			break
		
		// Get entity which was hit
		static pEntity
		pEntity = Instance( get_tr2( tr, TR_pHit ) )	
		
		// Get vector end position
		static Float:vecEnd[ 3 ]
		get_tr2( tr, TR_vecEndPos, vecEnd )
		
		// Its first beam	
		if( fFirstBeam )
		{
			// Add muzzleflash
			set_pev( Player, pev_effects, pev(Player, pev_effects) | EF_MUZZLEFLASH )
			
			// Its not first anymore
			fFirstBeam = false
			
			// Add
			nTotal += 26
			
			// Draw beam
			engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecSrc, 0 )
			//message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
			write_byte( TE_BEAMENTPOINT ) // Temp. entity ID
			write_short( Player | 0x1000 ) // Start entity
			engfunc( EngFunc_WriteCoord, vecEnd[ 0 ] ) // End position X
			engfunc( EngFunc_WriteCoord, vecEnd[ 1 ] ) // End position Y
			engfunc( EngFunc_WriteCoord, vecEnd[ 2 ] ) // End position Z
			write_short( g_iBeam ) // Sprite index
			write_byte( 0 ) // Start frame
			write_byte( 1 ) // Frame rate
			write_byte( 1 ) // Life
			write_byte( g_bPrimaryFire[ Player ] ? 16 : 25 ) // Line width
			write_byte( 0 ) // Noise amplitude
			write_byte( 255 )
			write_byte( 128 )
			write_byte( 0 )
			write_byte( 255 ) // Alpha
			write_byte( 0 ) // Scroll speed
			message_end( )
		}
		else
		{
			// Draw beam
			engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecSrc, 0 )
			write_byte( TE_BEAMPOINTS ) // Temp. entity ID
			engfunc( EngFunc_WriteCoord, vecSrc[ 0 ] ) // Start position X
			engfunc( EngFunc_WriteCoord, vecSrc[ 1 ] ) // Start position Y
			engfunc( EngFunc_WriteCoord, vecSrc[ 2 ] ) // Start position Z
			engfunc( EngFunc_WriteCoord, vecEnd[ 0 ] ) // End position X
			engfunc( EngFunc_WriteCoord, vecEnd[ 1 ] ) // End position Y
			engfunc( EngFunc_WriteCoord, vecEnd[ 2 ] ) // End position Z
			write_short( g_iBeam ) // Sprite index
			write_byte( 0 ) // Start frame
			write_byte( 1 ) // Frame rate
			write_byte( 1 ) // Life
			write_byte( g_bPrimaryFire[ Player ] ? 15 : 25 ) // Line width
			write_byte( 0 ) // Noise amplitude
			write_byte( 255 )
			write_byte( 128 )
			write_byte( 0 )
			write_byte( 255 )
			write_byte( 0 ) // Scroll speed
			message_end( )
		}
		
		// Check if this entity should take any damage
		if( pev( pEntity, pev_takedamage ) != DAMAGE_NO )
		{
			// Check if this is player and zombie
			if( is_user_valid_connected( pEntity ) && zp_get_user_zombie( pEntity ) )
			{
				// Retrieve health
				static iHealth
				iHealth = get_user_health( pEntity )
			
				// We should be alive
				if( iHealth - flDamage >= 1 )
				{
					// Cause some damage
					ExecuteHamB( Ham_TakeDamage, pEntity, 0, Player, flDamage, DMG_BULLET | 

DMG_ALWAYSGIB )
				}
				else
				{
					// Die
					g_bKilledByLaser[ pEntity ] = true
					ExecuteHamB( Ham_Killed, pEntity, Player, 2 )
					g_bKilledByLaser[ pEntity ] = false
				}
			}
		}
		
		// Check if this entity should reflect our beam
		if( ReflectGauss( pEntity ) )
		{
			static Float:n
			
			// Return normal vector in a spot we hit
			static Float:vecPlaneNormal[ 3 ]
			get_tr2( tr, TR_vecPlaneNormal, vecPlaneNormal )
			
			// Calculate dot product
			n = - xs_vec_dot( vecPlaneNormal, vecDir )
			
			// 60 degrees
			if ( 0 < n < 0.5 )
			{
				static Float:r[ 3 ]
				VectorMA( vecDir, 2.0 * n, vecPlaneNormal, r )
				
				// Get vector end position
				get_tr2( tr, TR_vecEndPos, vecEnd )
				
				// Get trace fraction
				static Float:trflFraction
				get_tr2( tr, TR_flFraction, trflFraction )
				
				// Calculate fraction
				flMaxFrac = flMaxFrac - trflFraction
				
				// Copy vectors
				xs_vec_copy( r, vecDir )
				
				// Make more vector calculations
				VectorMA( vecEnd, 8.0, vecDir, vecSrc )
				VectorMA( vecSrc, 8192.0, vecDir, vecDest )
			
				// Undone!Do radius damage
				
				// Increase
				nTotal += 34
				
				if( n == 0 )
				{
					// Lose energy
					n = 0.1
				}
				
				// Calculate new damage
				flDamage = flDamage * ( 1 - n )
			}
			else
			{
				// Add gun shot decal on the world
				FX_GunShotDecal( vecEnd, pEntity )
				
				// Add glowing sprite on the world
				FX_TempSprite( vecEnd, 6, floatround( flDamage / 255.0 ) )
				
				// Increase
				nTotal += 13
				
				// Limit it to one hole punch
				if( fHasPunched )
					break
				
				// Update	
				fHasPunched = true	
				
				// Try punching through wall if secondary attack (primary is incapable of 
				// breaking through)
				if( !g_bPrimaryFire[ Player ] )
				{
					// Retrieve vector end position
					get_tr2( tr, TR_vecEndPos, vecEnd )
					
					// Modify start origin
					static Float:vecStart[ 3 ]
					VectorMA( vecEnd, 8.0, vecDir, vecStart )
					
					// Draw another trace line
					engfunc( EngFunc_TraceLine, vecSrc, vecDest, DONT_IGNORE_MONSTERS, 

pEntToIgnore, beam_tr )
					
					// We'll never get outside
					if( !get_tr2( beam_tr, TR_AllSolid ) )
					{
						// Get end position
						static Float:vecBeamEndPos[ 3 ]
						get_tr2( beam_tr, TR_vecEndPos, vecBeamEndPos )
						
						// Trace backwards to find exit point
						engfunc( EngFunc_TraceLine, vecBeamEndPos, vecEnd, 

DONT_IGNORE_MONSTERS, pEntToIgnore, beam_tr )
						
						// Again get end position
						get_tr2( beam_tr, TR_vecEndPos, vecBeamEndPos )
						
						static Float:ns, Float:vecSub[ 3 ]
						
						// Subtract vectors
						xs_vec_sub( vecBeamEndPos, vecEnd, vecSub )
						
						// Get vector length
						ns = xs_vec_len( vecSub )
						
						if( ns < flDamage )
						{
							// Lose enery
							if( ns == 0 )
							{
								ns = 1.0
							}
							
							// Decrease damage
							flDamage -= ns
							
							// Subtract
							static Float:vecCalc[ 3 ]
							VectorSubtract( vecEnd, vecDir, vecCalc )
							
							// Absorbtion balls
							FX_SpriteTrail( vecEnd, vecCalc, BALL_AMOUNT, 15, 3, 25, 

25 )
							
							// Add gun shot decal on the world
							FX_GunShotDecal( vecBeamEndPos, pEntity )
							
							// And glowing sprite
							FX_TempSprite( vecBeamEndPos, 6, floatround( flDamage / 

255.0 ) )
							
							// Subtract
							VectorSubtract( vecBeamEndPos, vecDir, vecCalc )
							
							// Absorbtion balls
							FX_SpriteTrail( vecEnd, vecCalc, BALL_AMOUNT, 15, 3, 25, 

25 )
							
							// Increase shit
							nTotal += 21
							
							/*
							// Calculate radius damage
							static Float:flRadDmg
							flRadDmg = flDamage * 1.75
							
							// Undone.Do radius damage here!
							floatradius( flDamage, flRadDmg, vecBeamEndPos )
							*/
							
							// Increase
							nTotal += 53
							
							VectorMA( vecBeamEndPos, 8.0, vecDir, vecSub )
							
							// Add up vector
							xs_vec_add( vecBeamEndPos, vecDir, vecSrc )
						}
					}
					else
					{
						flDamage = 0.0
					}
				}
				else
				{
					// Primary attack
					if( g_bPrimaryFire [ Player ] )
					{
						// Slug doesn't punch through ever with primary 
						// fire, so leave a little glowy bit and make some balls
						FX_TempSprite( vecEnd, 6, floatround( flDamage / 255.0 ) )
						FX_SpriteTrail( vecEnd, vecDir, BALL_AMOUNT, 15, 3, 25, 25 )
					}
					
					flDamage = 0.0
				}
			}
		}
		else
		{
			// Add up vector
			xs_vec_add( vecEnd, vecDir, vecSrc )
			pEntToIgnore = pEntity
		}
	}
}				

// Register and cache CVARs
public Load_Cvars( )
{
	cvar_oneround = register_cvar( "zp_tcannon_oneround", "0" )
	cvar_dmgprim = register_cvar( "zp_tcannon_dmgprim", "200" )
	cvar_dmgsec = register_cvar( "zp_tcannon_dmgsec", "500" )
	cvar_clip = register_cvar( "zp_tcannon_clip", "100" )
	
	g_pOneRound = get_pcvar_num( cvar_oneround )
	g_pDmgPrim = get_pcvar_float( cvar_dmgprim )
	g_pDmgSec = get_pcvar_float( cvar_dmgsec )
	g_pClip = get_pcvar_num( cvar_clip )
}

// Gauss weapon idle
WeaponIdle( Player )
{
	// Get gametime
	static Float:flGameTime
	flGameTime = get_gametime( )
	
	if( g_flWeaponIdleTime[ Player ] > flGameTime )
		return
	
	// Animation sequence variable
	static iAnim
	
	// Animation randomizer
	static Float:flRand
	flRand = random_float( 0.1, 1.0 )
	
	if( flRand <= 0.5 )
	{
		iAnim = gauss_idle
		g_flWeaponIdleTime[ Player ] = flGameTime + random_float( 10.0, 15.0 )
	}
	else if( flRand <= 0.75 )
	{
		iAnim = gauss_idle2
		g_flWeaponIdleTime[ Player ] = flGameTime + random_float( 10.0, 15.0 )
	}
	else
	{
		iAnim = gauss_fidget
		g_flWeaponIdleTime[ Player ] = flGameTime + 3
	}
	
	// Idle
	UTIL_PlayWeaponAnimation( Player, iAnim )
}	

// Play weapon animation
UTIL_PlayWeaponAnimation( const Player, const Sequence )
{
	set_pev( Player, pev_weaponanim, Sequence )
	
	message_begin( MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player )
	write_byte( Sequence )
	write_byte( pev( Player, pev_body ) )
	message_end( )
}				

// Make ScreenFade
UTIL_ScreenFade( Player, Duration, HoldTime, Flags, iRed, iGreen, iBlue, iAlpha )
{
	message_begin( MSG_ONE, gmsgScreenFade, _, Player )
	write_short( Duration )
	write_short( HoldTime )
	write_short( Flags )
	write_byte( iRed )
	write_byte( iGreen )
	write_byte( iBlue )
	write_byte( iAlpha )
	message_end( )
}

// Reload gauss
UTIL_WeaponReload( Player, iEnt )
{
	// Modify time until next attack
	set_pdata_float( Player, m_flNextAttack, GAUSS_RELOADTIME+0.5, 5 )
	
	// Reload animation
	UTIL_PlayWeaponAnimation( Player, gauss_spin )
	
	// Enable reload offset
	set_pdata_int( iEnt, m_fInReload, 1, 4 )
	
	// Modify next idle time
	g_flWeaponIdleTime[ Player ] = get_gametime( ) + GAUSS_RELOADTIME + 1.0 
}

// Drop all primary weapons
UTIL_DropPrimary( Player )
{
	// Get user weapons
	static weapons[ 32 ], num, i, weaponid
	num = 0 // reset passed weapons count (bugfix)
	get_user_weapons( Player, weapons, num )
	
	// Loop through them and drop primaries
	for( i = 0; i < num; i++ )
	{
		// Prevent re-indexing the array
		weaponid = weapons[ i ]
		
		// We definetely are holding primary gun
		if(( (1<<weaponid) & PRIMARY_WEAPONS_BITSUM ) )		
		{
			// Get weapon entity
			static wname[32]
			get_weaponname(weaponid, wname, charsmax(wname))
			
			// Player drops the weapon and looses his bpammo
			engclient_cmd( Player, "drop", wname)
		}
	}
}

// Get gun position
UTIL_GetGunPosition( Player, Float:flOrigin[ ] )
{
	static Float:vf_Origin[ 3 ], Float:vf_ViewOfs[ 3 ]
	
	pev( Player, pev_origin, vf_Origin )
	pev( Player, pev_view_ofs, vf_ViewOfs )
	
	xs_vec_add( vf_Origin, vf_ViewOfs, flOrigin )
}

// Make vectors
UTIL_MakeVectors ( Player )
{
	static Float:flAngle[ 3 ], Float:flPunchAngle[ 3 ]

	pev( Player, pev_v_angle, flAngle )
	pev( Player, pev_punchangle, flPunchAngle )

	xs_vec_add( flAngle, flPunchAngle, flAngle )
	engfunc( EngFunc_MakeVectors, flAngle )
}

// From HL SDK.
VectorMA( Float:a[ ], Float:flScale, Float:b[ ], Float:c[ ] )
{
	c[ 0 ] = a[ 0 ] + flScale * b[ 0 ]
	c[ 1 ] = a[ 1 ] + flScale * b[ 1 ]
	c[ 2 ] = a[ 2 ] + flScale * b[ 2 ]
}

VectorMS( const Float:flSource[ ], const Float:flScale, const Float:flMult[ ], Float:flOutput[ ] )
{
        flOutput[ 0 ] = flSource[ 0 ] - flMult[ 0 ] * flScale
        flOutput[ 1 ] = flSource[ 1 ] - flMult[ 1 ] * flScale
        flOutput[ 2 ] = flSource[ 2 ] - flMult[ 2 ] * flScale
}

// Another stuff from HLSDK
Instance( iEnt )
{
	return iEnt == -1 ? 0 : iEnt
}

// Does this entity should refect gauss?
ReflectGauss( iEnt )
{
		return IsBSPModel( iEnt ) && pev( iEnt, pev_takedamage ) == DAMAGE_NO 
}

// Does this entity is BSP model?
IsBSPModel( iEnt )
{
	return pev( iEnt, pev_solid ) == SOLID_BSP || pev( iEnt, pev_movetype ) == MOVETYPE_PUSHSTEP 
}

// Add gun shot decal on world!
FX_GunShotDecal( Float:flPos[ ], pEntity )
{
	// Draw gunshot
	engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flPos, 0 )
	write_byte( TE_GUNSHOTDECAL ) // Temp.entity ID
	engfunc( EngFunc_WriteCoord, flPos[ 0 ] ) // Position X
	engfunc( EngFunc_WriteCoord, flPos[ 1 ] ) // Position Y
	engfunc( EngFunc_WriteCoord, flPos[ 2 ] ) // Position Z
	write_short( pEntity ) // Which entity to mark?
	write_byte( 43 ) // Decal number
	message_end( )
}

// Add glow sprite on world
FX_TempSprite( Float:flPos[ ], iScale, iSize )
{
	engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flPos, 0 )
	write_byte( TE_GLOWSPRITE ) // Temp.entity ID
	engfunc( EngFunc_WriteCoord, flPos[ 0 ] ) // Position X
	engfunc( EngFunc_WriteCoord, flPos[ 1 ] ) // Position Y
	engfunc( EngFunc_WriteCoord, flPos[ 2 ] ) // Position Z
	write_short( g_iBalls ) // Sprite index
	write_byte( iScale ) // Scale
	write_byte( iSize ) // Size
	write_byte( 255 ) // Brightness
	message_end( )
}

// Add sprite trail
FX_SpriteTrail( Float:vecStart[ ], Float:vecDest[ ], iCount, iLife, iScale, iVel, iRnd )
{
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
	write_byte( TE_SPRITETRAIL ) // Sprite trail
	engfunc( EngFunc_WriteCoord, vecStart[ 0 ] ) // Position X
	engfunc( EngFunc_WriteCoord, vecStart[ 1 ] ) // Position Y
	engfunc( EngFunc_WriteCoord, vecStart[ 2 ] ) // Position Z
	engfunc( EngFunc_WriteCoord, vecDest[ 0 ] ) // Position X
	engfunc( EngFunc_WriteCoord, vecDest[ 1 ] ) // Position Y
	engfunc( EngFunc_WriteCoord, vecDest[ 2 ] ) // Position Z
	write_short( g_iBalls ) // SPrite index
	write_byte( iCount ) // Amount
	write_byte( iLife ) // Life
	write_byte( iScale ) // Scale
	write_byte( iVel ) // Velocity along vector
	write_byte( iRnd ) // Randomness of velocity
	message_end( )
}
__________________


Forum: www.Adrenaline-Zone.info
Johnnynho123 is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 02-23-2012 , 02:20   Re: [HELP] Vip extra
#6

Look again
PHP Code:
#include < amxmodx >
#include < cstrike >
#include < csx >
#include < engine >
#include < fakemeta >
#include < hamsandwich >
#include < fun >
#include < xs >
#include < zombieplague >
#include < zmvip >


// Plugin information
#define Plugin    "[ZP] Extra Item: Tau Cannon"
#define Version    "1.2"
#define Author    "NiHiLaNTh"

// Maxplayers
const MaxPlayers 32

// Weapon models
new const g_szModelGaussP[ ] = "models/p_gauss.mdl"
new const g_szModelGaussV[ ] = "models/v_alt_gauss.mdl"
new const g_szModelGaussW[ ] = "models/w_gauss.mdl"

// Weapon sounds
new const g_szSoundGaussFire[ ] = "weapons/gauss2.wav"
new const g_szSoundGaussSpin[ ] = "ambience/pulsemachine.wav"
new const g_szSoundElectro1[ ] = "weapons/electro4.wav"
new const g_szSoundElectro2[ ] = "weapons/electro5.wav"
new const g_szSoundElectro3[ ] = "weapons/electro6.wav"

// Some gauss/beam stuff
#define GAUSS_REFIRERATE    0.2 // Primary attack
#define GAUSS_REFIRERATE2    0.1 // Secondary attack(you shouldnt change this!)
#define GAUSS_RECOIL        -2.0 // Only X axis!
#define GAUSS_CHARGETIME    4.0 // From HLSDK
#define GAUSS_RELOADTIME    2.0 // Reload time
#define BEAM_RED        255 // Red amount
#define BEAM_GREEN        128 // Green amount
#define BEAM_BLUE        0 // Blue amount
#define BEAM_ALPHA        255 // Brightness(Alpha)
#define BALL_AMOUNT        8 // How many balls should appear :p

// Ammo given when buy weapons    
new const BUYAMMO[] = { -113, -130, -18, -11230, -13050123030301230,
130308303030, -173030, -150 }

// Max. bp ammo amount
new const MAXBPAMMO[] = { -152, -1901321100901120100100909090100120,
    
5120200// This is gauss max bp ammo.Change it if you want!
3290120902359090, -1100 }

// Weapon ammo ID's
new const AMMOID[] = { -19, -121251464131076444610,
11035410211842, -1}

// Player variables
new g_iHasGaussMaxPlayers+// Whether player has gauss
new g_iSoundStateMaxPlayers+// Weapon sound state
new g_bInAttackMaxPlayers+// Current gauss attack state
new g_iCurrentWeaponMaxPlayers+// Current weapon player is holding
new Float:g_flLastShotTimeMaxPlayers+// Last shot time
new Float:g_fflPlayAfterShockMaxPlayers+// Play aftershock sound
new Float:g_flWeaponIdleTimeMaxPlayers+// Weapon idle time
new Float:g_flNextAmmoBurnMaxPlayers+// Next ammo burn time
new Float:g_flStartChargeMaxPlayers+// Weapon start charge
new Float:g_flAmmoStartChargeMaxPlayers+// Ammo start charge
new bool:g_bIsAliveMaxPlayers+// Whether player is alive
new bool:g_bIsConnectedMaxPlayers+// Whether player is connected
new bool:g_bPrimaryFireMaxPlayers+// Does this weapon is using primary attack ?
new bool:g_bKilledByLaserMaxPlayers+// Imma firin mah lazor O.o

// CVAR pointers
new cvar_oneround // Whether gun should be only for 1 round
new cvar_dmgprim // Primary attack damage
new cvar_dmgsec // Secondary attack damage
new cvar_clip // Clip amount

// Cached CVAR
new g_pOneRound
new Float:g_pDmgPrim
new Float:g_pDmgSec
new g_pClip

// Global varibles
new g_iMaxPlayers // Maxplayers
new bool:g_bGameRestart // Detect game restart
new g_iBeam // Beam sprite
new g_iBalls // Balls :p
new g_iGaussID // Item ID
new gmsgScreenFade // Screen fade
new gmsgAmmoPickup // Ammo pickup

// CS Offsets
const m_pPlayer 41
const m_flNextPrimaryAttack 46
const m_flNextSecondaryAttack 47
const m_flTimeWeaponIdle 48
const m_iPrimaryAmmoType 49
const m_iClip 51
const m_fInReload 54
const m_flNextAttack  83
const m_rgAmmo_player_Slot0 376

// Macro 
#define is_user_valid_connected(%1)        ( 1 <= %1 <= g_iMaxPlayers && g_bIsConnected [ %1 ] )
#define is_user_in_water(%1)            ( pev ( %1, pev_waterlevel ) == 3 )
#define VectorSubtract(%1,%2,%3)        ( %3[ 0 ] = %1[ 0 ] - %2[ 0 ], %3[ 1 ] = %1[ 1 ] - %2[ 1 ], %3[ 2 ] = %1[ 2 ] - %2[ 2 ] )
#define VectorAdd(%1,%2,%3)            ( %3[ 0 ] = %1[ 0 ] + %2[ 0 ], %3[ 1 ] = %1[ 1 ] + %2[ 2 ], %3[ 2 ] = %1[ 2 ] + %2[ 2 ] )
#define VectorScale(%1,%2,%3)            ( %3[ 0 ] = %2 * %1[ 0 ], %3[ 1 ] = %2 * %1[ 1 ], %3[ 2 ] = %2 * %1[ 2 ] )
#define VectorLength(%1)                 ( floatsqroot ( %1[ 0 ] * %1[ 0 ] + %1[ 1 ] * %1[ 1 ] + %1[ 2 ] * %1[ 2 ] ) )

// Hack!Custom fields
#define pev_weaponkey        pev_impulse
#define pev_bpammo        pev_iuser3

// Misc stuff
#define FCVAR_FLAGS        ( FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED )
#define GAUSS_WEAPONKEY    42856
#define NULLENT        -1
#define FFADE_IN        0x0000
#define UNIT_SECOND        (1<<12)

// Entity classnames
new const g_szClassPlayer[ ] = "player"
new const g_szClassM249[ ] = "weapon_m249"

// Primary weapon bitsum
const PRIMARY_WEAPONS_BITSUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)

// Animation sequnces
enum
{
    
gauss_idle,
    
gauss_idle2,
    
gauss_fidget,
    
gauss_spinup,
    
gauss_spin,
    
gauss_fire,
    
gauss_fire2,
    
gauss_holster,
    
gauss_draw
}

// Precache
public plugin_precache( )
{
    
// Weapon models
    
precache_modelg_szModelGaussP )
    
precache_modelg_szModelGaussV )
    
precache_modelg_szModelGaussW )
    
    
// Sounds
    
precache_soundg_szSoundGaussFire )
    
precache_soundg_szSoundGaussSpin )
    
precache_soundg_szSoundElectro1 )
    
precache_soundg_szSoundElectro2 )
    
precache_soundg_szSoundElectro3 )
    
precache_sound"items/9mmclip1.wav" )
    
    
// Sprites
    
g_iBeam precache_model"sprites/smoke.spr" )
    
g_iBalls precache_model"sprites/hotglow.spr" )
}

// Initialization
public plugin_init( )
{
    
// New plugin
    
register_pluginPluginVersionAuthor )
    
    
// For Game-Monitor support
    
register_cvar"zp_tcannon_version"VersionFCVAR_FLAGS )
    
    
// New extra item
    
g_iGaussID zv_register_extra_item"Tau Cannon","Strong Cannon"60ZV_TEAM_HUMAN )
    
    
// Client commands
    
register_clcmd"buyammo1""fn_BuyAmmo" )
    
register_clcmd"buyammo2""fn_BuyAmmo" )
    
    
// Events
    
register_event"CurWeapon""EV_CurWeapon""be""1=1" )
    
register_event"DeathMsg""EV_DeathMsg""a" )
    
register_event"HLTV""EV_RoundStart""a""1=0""2=0" )
    
register_event"TextMsg""EV_GameRestart""a""2=#Game_Commencing""2=#Game_will_restart_in" )
    
    
// FakeMeta forwards
    
register_forwardFM_SetModel"fw_SetModel" )
    
register_forwardFM_CmdStart"fw_CmdStart" )
    
register_forwardFM_UpdateClientData"fw_UpdateClientData_Post")
    
register_forwardFM_PlayerPreThink"fw_PlayerPreThink" )
    
    
// HamSandwich forwards
    
RegisterHamHam_Spawng_szClassPlayer"fw_PlayerSpawn_Post")
    
RegisterHamHam_Item_Deployg_szClassM249"fw_TCannonDeploy_Post")
    
RegisterHamHam_Item_Holsterg_szClassM249"fw_TCannonHolster_Post")
    
RegisterHamHam_Item_AddToPlayerg_szClassM249"fw_TCannonAddToPlayer" )
    
RegisterHamHam_Item_PostFrameg_szClassM249"fw_TCannonPostFrame" )
    
RegisterHamHam_Weapon_Reloadg_szClassM249"fw_TCannonReload_Post")
    
    
// CVARs are in Load_Cvars( ) function!
    
    // Messages
    
register_messageget_user_msgid"DeathMsg" ), "fn_DeathMsg" )
    
gmsgScreenFade get_user_msgid"ScreenFade" )
    
gmsgAmmoPickup get_user_msgid"AmmoPickup" )
    
    
// Store maxplayers in a global variable
    
g_iMaxPlayers get_maxplayers( )
}    

// Configuration
public plugin_cfg( )
{
    
// Cache CVARs
    
set_task1.5"Load_Cvars" )
}

// ------------------------------- Game Events ----------------------------------------

// Client connected
public client_connectPlayer )
{
    
// Make a lot of updates
    
g_iHasGaussPlayer ] = false
    g_bInAttack
Player ] = 0
    g_fflPlayAfterShock
Player ] = 0.0
    g_flWeaponIdleTime
Player ] = 0.0
    g_bPrimaryFire
Player ] = false
    g_bIsAlive
Player ] = false
    g_bIsConnected
Player ] = true
}

// Client disconnected
public client_disconnectPlayer )
{
    
// Only few important updates
    
g_bIsAlivePlayer ] = false
    g_bIsConnected
Player ] = false
}

// Someone selected our extra item
public zp_extra_item_selectedPlayerItem )
{
    
// Tau Cannon
    
if ( Item == g_iGaussID )
    {
        
// Drop all primary weapons
        
UTIL_DropPrimaryPlayer )
        
        
// Update
        
g_iHasGaussPlayer ] = true
        
        
// Give m249
        
give_itemPlayer"weapon_m249" )
        
        
// Find weapon entity
        
new iEnt find_ent_by_ownerNULLENTg_szClassM249Player )
        
        
// Apply new clip
        
cs_set_weapon_ammoiEntg_pClip )
        
        
// Back pack ammo
        
cs_set_user_bpammoPlayerCSW_M249MAXBPAMMO20 ] )
    }
}

// Player is trying to buy something
public fn_BuyAmmoPlayer )
{
    
// Not alive
    
if( !g_bIsAlivePlayer ] )
        return 
PLUGIN_HANDLED
    
    
// Dont have Tau Cannon
    
if( !g_iHasGaussPlayer ] )
        return 
PLUGIN_CONTINUE
    
    
// Retrieve ammo pack amount
    
static iAmmoPack
    iAmmoPack 
zp_get_user_ammo_packsPlayer )
    
    
// Out of ammo packs
    
if( iAmmoPack <= )
        return 
PLUGIN_HANDLED
    
    
// Get players weapons
    
static weapons32 ], numicurrentammoweaponidrefilled
    num 
// reset passed weapons count (bugfix)
    
refilled false
    get_user_weapons
Playerweaponsnum )
    
    
// Loop through them and give the right ammo type
    
for( 0numi++ )
    {
        
// Prevents re-indexing the array
        
weaponid weapons]
        
        
// Primary and secondary only
        
if( MAXBPAMMOweaponid ] > )
        {
            
// Get current ammo of the weapon
            
currentammo cs_get_user_bpammoPlayerweaponid)
            
            
// Check if we are close to the BP ammo limit
            
if (currentammo MAXBPAMMO[weaponid]-BUYAMMO[weaponid])
            {
                
// Flash ammo in hud
                
message_begin(MSG_ONE_UNRELIABLEgmsgAmmoPickup_Player )
                
write_byte(AMMOID[weaponid]) // ammo id
                
write_byte(BUYAMMO[weaponid]) // ammo amount
                
message_end()
                
                
// Increase BP ammo
                
cs_set_user_bpammo Playerweaponidcurrentammo BUYAMMO[weaponid])
                
                
refilled true
            
}
            else if (
currentammo MAXBPAMMO[weaponid])
            {
                
// Flash ammo in hud
                
message_begin(MSG_ONE_UNRELIABLEgmsgAmmoPickup_Player )
                
write_byte(AMMOID[weaponid]) // ammo id
                
write_byte(MAXBPAMMO[weaponid]-currentammo// ammo amount
                
message_end()
                
                
// Reached the limit
                
cs_set_user_bpammo PlayerweaponidMAXBPAMMO[weaponid])
                
                
refilled true
            
}
        }
    }
    
    
// Weapons already have full ammo
    
if (!refilled) return PLUGIN_HANDLED
    
    
// Deduce ammo packs, play clip purchase sound, and notify the player
    
zp_set_user_ammo_packsPlayer, --iAmmoPack )
    
engfunc(EngFunc_EmitSoundPlayerCHAN_ITEM"items/9mmclip1.wav"1.0ATTN_NORM0PITCH_NORM)
    
client_printPlayerprint_chat"[ZP] You purchased extra ammo for your guns." )
    
    return 
PLUGIN_HANDLED
}    

// Current weapon player is holding
public EV_CurWeaponPlayer )
{
    
// Not alive
    
if( !g_bIsAlivePlayer ] )
        return 
PLUGIN_CONTINUE
    
    
// Update
    
g_iCurrentWeaponPlayer ] = read_data)
    
    return 
PLUGIN_CONTINUE
}

// Someone died
public EV_DeathMsg( )
{
    
// Get victim
    
static iVictim
    iVictim 
read_data)
    
    
// Not connected
    
if( !is_user_valid_connectediVictim ) )
        return
    
    
// Update
    
g_bIsAliveiVictim ] = false
    
    
// Check if victim has gauss
    
if( g_iHasGaussiVictim ] && !is_user_botiVictim ) )
    {
        
// Force to drop
        
engclient_cmdiVictim"drop weapon_m249" )
    }
}

// Round started
public EV_RoundStart( )
{
    
// Restart/One round only
    
if( g_bGameRestart || g_pOneRound )
    {
        
// Reset array value
        
arraysetg_iHasGaussfalseMaxPlayers+)
    }
    
    
// Update
    
g_bGameRestart false
}

// Game restart
public EV_GameRestart( )
{
    
// Update
    
g_bGameRestart true
}

// Hook death message
public fn_DeathMsgPlayerDestiEntity )
{
    
// Get victim
    
static iVictimiKiller
    iKiller 
get_msg_arg_int)
    
iVictim get_msg_arg_int)
    
    
// Not connected
    
if( !is_user_valid_connectediVictim ) || iKiller == iVictim )
        return 
PLUGIN_CONTINUE
    
    
// We were killed by laser
    
if ( g_bKilledByLaseriVictim ] )
    {
        
// Replace name in console
        
set_msg_arg_string 4"tau cannon" )
    }
    return 
PLUGIN_CONTINUE
}

// ------------------------------- Forwards ----------------------------------------

// Replace world model
public fw_SetModel Entity, const Model [ ] )
{
    
// Prevent invalid entity messages
    
if( !pev_validEntity ) )
        return 
FMRES_IGNORED
    
    
// Not w_awp.mdl
    
if( !equalModel"models/w_m249.mdl" ) )
        return 
FMRES_IGNORED
    
    
// Get entity classname
    
static szClassname32 ]
    
pevEntitypev_classnameszClassnamecharsmaxszClassname ) )
    
    
// Not weaponbox
    
if( !equalszClassname"weaponbox" ) )
        return 
FMRES_IGNORED
    
    
// Get owner
    
static iOwner
    iOwner 
pevEntitypev_owner )
    
    
// Get awp ID
    
static iWeaponID
    iWeaponID 
find_ent_by_ownerNULLENTg_szClassM249Entity )
    
    
// Make sure that we have gauss
    
if( g_iHasGauss iOwner ] && is_valid_entiWeaponID ) )
    {
        
// Hack! Store weaponkey
        
set_peviWeaponIDpev_weaponkeyGAUSS_WEAPONKEY )
        
        
// Hack! Store bp ammo
        
set_peviWeaponIDpev_bpammocs_get_user_bpammoiOwnerCSW_M249 ) )
        
        
// Update
        
g_iHasGaussiOwner ] = false
        
        
// Replace models
        
engfuncEngFunc_SetModelEntityg_szModelGaussW )
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED
}

// Command start
public fw_CmdStartPlayerUC_HandleSeed )
{
    
// Not alive/dont have gauss/not m249
    
if( !g_bIsAlivePlayer ] || !g_iHasGaussPlayer ] || g_iCurrentWeaponPlayer ] != CSW_M249 )
        return 
FMRES_IGNORED
    
    
// Retrieve pressed button bitsum
    
static iButtons
    iButtons 
get_ucUC_HandleUC_Buttons )
    
    
// Retrieve game time
    
static Float:flGameTime
    flGameTime 
get_gametime( )
    
    
// Retrieve weapon entity
    
static iEnt
    iEnt 
find_ent_by_ownerNULLENTg_szClassM249Player )
    
    
// Retrieve clip amount
    
static iClip
    iClip 
cs_get_weapon_ammoiEnt )
    
    
// Primary attack
    
if( iButtons IN_ATTACK )
    {
        
// Remove attack buttons from their button mask
        
iButtons &= ~IN_ATTACK
        set_uc
UC_HandleUC_ButtonsiButtons )
        
        
// Prevent too fast shooting
        
if( flGameTime g_flLastShotTimePlayer ] < GAUSS_REFIRERATE )
            return 
FMRES_IGNORED
        
        
// Dont fire while reloading
        
if( get_pdata_intiEntm_fInReload) )
            return 
FMRES_IGNORED
        
        
// Not enough clip/under water
        
if( iClip || is_user_in_waterPlayer ) )
        {
            
// Emit empty sound
            
ExecuteHamBHam_Weapon_PlayEmptySoundiEnt )
            return 
FMRES_IGNORED
        
}
        
        
// Update
        
g_bPrimaryFirePlayer ] = true
        
        
// Start to fire
        
StartFirePlayer )
        
        
// Decrease clip
        
cs_set_weapon_ammoiEntiClip-)
        
        
// Reset weapon attack status
        
g_bInAttackPlayer ] = 0
        
        
// Set time when idle animation should be played
        
g_flWeaponIdleTimePlayer ] = flGameTime 1.0
        
        
// Remember last shot time
        
g_flLastShotTimePlayer ] = flGameTime
    
}
    
// Secondary attack
    
else if( iButtons IN_ATTACK2 )
    {
        
// Prevent too fast shooting
        
if( flGameTime g_flLastShotTimePlayer ] < GAUSS_REFIRERATE2 )
            return 
FMRES_IGNORED
        
        
// Dont fire while reloading
        
if( get_pdata_intiEntm_fInReload) )
            return 
FMRES_IGNORED
        
        
// Are we swimming ?
        
if( is_user_in_waterPlayer ) )
        {
            
// We are in a middle of attack
            
if( g_bInAttackPlayer ] != )
            {
                
// Stop attack
                
emit_soundPlayerCHAN_WEAPONg_szSoundElectro1VOL_NORMATTN_NORM080 random_num00x3f ) )
                
                
// Gun idle
                
UTIL_PlayWeaponAnimationPlayergauss_idle )
                return 
FMRES_IGNORED
            
}
            else
            {
                
// Empty sound
                
ExecuteHamBHam_Weapon_PlayEmptySoundiEnt )
                return 
FMRES_IGNORED
            
}
        }
        
        
// Get player oldbuttons
        
static iOldButtons
        iOldButtons 
pevPlayerpev_oldbuttons )
        
        
// Make sure that we are holding secondary attack button
        
if( iOldButtons IN_ATTACK2 )
        {
            
// Which attack state do we have
            
switch ( g_bInAttackPlayer ] )
            {
                case 
0// Attack start
                
{
                    
// Out of ammo
                    
if ( iClip <= )
                    {
                        
ExecuteHamBHam_Weapon_PlayEmptySoundiEnt )
                        return 
FMRES_IGNORED
                    
}
                    
                    
// We aren't using primary attack anymore
                    
g_bPrimaryFirePlayer ] = false
                    
                    
// Decrease clip
                    
cs_set_weapon_ammoiEnt, --iClip )
                    
                    
// Update
                    
g_flNextAmmoBurnPlayer ] = flGameTime
                    
                    
// Send spinup animation
                    
UTIL_PlayWeaponAnimationPlayergauss_spinup )
                    
                    
// Update attack state
                    
g_bInAttackPlayer ] = 1
                    
                    
// Next idle time
                    
g_flWeaponIdleTimePlayer ] = flGameTime 0.5
                    
                    
// Update
                    
g_flStartChargePlayer ] = flGameTime
                    g_flAmmoStartCharge
Player ] = flGameTime GAUSS_CHARGETIME
                    
                    
// Update sound state
                    
g_iSoundStatePlayer ] = 0
                    
                    
// Spin sound
                    
emit_soundPlayerCHAN_WEAPONg_szSoundGaussSpinVOL_NORMATTN_NORMg_iSoundState[Player ], 110 )
                    
                    
// Change sound state
                    
g_iSoundStatePlayer ] = SND_CHANGE_PITCH
                
}
                case 
1// In a middle of attack
                
{
                    if( 
g_flWeaponIdleTimePlayer ] < flGameTime )
                    {
                        
// Spin anim
                        
UTIL_PlayWeaponAnimationPlayergauss_spin )
                        
                        
// Update state
                        
g_bInAttackPlayer ] = 2
                    
}
                }
                default: 
// End of attack
                
{
                    
// During the charging process, eat one bit of ammo every once in a while
                    
if( flGameTime >= g_flNextAmmoBurnPlayer ] && g_flNextAmmoBurnPlayer ] != 1000 )
                    {
                        
// Decrease clip
                        
cs_set_weapon_ammoiEnt, --iClip )
                        
                        
// Next time when ammo should be decreased
                        
g_flNextAmmoBurnPlayer ] = flGameTime 0.1
                    
}
                    
                    
// Shit!We run out of ammo
                    
if( iClip <= )
                    {
                        
// Force gun to fire
                        
StartFirePlayer )
                        
                        
// Reset weapon state
                        
g_bInAttackPlayer ] = 0
                        
                        
// Set next idle time
                        
g_flWeaponIdleTimePlayer ] = flGameTime 1.0
                    
}
                    
                    
// Gun is fully charged up
                    
if( flGameTime >= g_flAmmoStartChargePlayer ] )
                    {
                        
// Dont eat any more ammo!
                        
g_flNextAmmoBurnPlayer ] = 1000.0
                    
}
                    
                    
// Calculate pitch
                    
static Float:flPitch
                    flPitch 
= ( flGameTime g_flStartChargePlayer ] ) * ( 150 GAUSS_CHARGETIME ) + 100
                    
                    
// Pitch shouldnt be THAT big
                    
if ( flPitch 250 )
                    {
                        
flPitch 250.0
                    
}
                    
                    
// Spin sound
                    
emit_soundPlayerCHAN_WEAPONg_szSoundGaussSpinVOL_NORMATTN_NORM, ( g_iSoundStatePlayer ] == SND_CHANGE_PITCH ) ? 0floatroundflPitch ) )
                    
                    
// Hack for going through level transitions
                    
g_iSoundStatePlayer ] = SND_CHANGE_PITCH
                    
                    
// We are charing way too long!
                    
if( g_flStartChargePlayer ] < flGameTime 10 )
                    {
                        
// ZAP!
                        
emit_soundPlayerCHAN_WEAPONg_szSoundElectro1VOL_NORMATTN_NORM080 random_num00x3f ) )
                        
emit_soundPlayerCHAN_VOICEg_szSoundElectro3VOL_NORMATTN_NORM080 random_num00x3f ) )
                        
                        
// Reset fire state
                        
g_bInAttackPlayer ] = 0
                        
                        
// Next idle time
                        
g_flWeaponIdleTimePlayer ] = flGameTime 1.0
                        
                        
// Damage player
                        
ExecuteHamBHam_TakeDamagePlayer0Player50.0DMG_SHOCK )
                        
                        
// Make screen fade
                        
UTIL_ScreenFadePlayerUNIT_SECOND*2UNIT_SECOND/2FFADE_IN2551280128 )
                        
                        
// Idle animation
                        
UTIL_PlayWeaponAnimationPlayergauss_idle )
                    }
                }
            }
            
            
// Update
            
g_flLastShotTimePlayer ] = flGameTime
        
}
    }
    
    return 
FMRES_HANDLED
}

// Update client data post
public fw_UpdateClientData_Post PlayerSendWeaponsCD_Handle )
{
    
// Not alive / dont have gauss/ not m249
    
if ( !g_bIsAlive Player ] || !g_iHasGauss Player ] || g_iCurrentWeapon Player ] != CSW_M249 )
        return 
FMRES_IGNORED
    
    
// Block default sounds/animations
    
set_cd CD_HandleCD_flNextAttackhalflife_time ( ) + 0.001 )
    return 
FMRES_HANDLED
}

// Player pre think
public fw_PlayerPreThinkPlayer )
{
    
// Not alive / dont have gauss/ not m249
    
if ( !g_bIsAlive Player ] || !g_iHasGauss Player ] || g_iCurrentWeapon Player ] != CSW_M249 )
        return
    
    
// Play aftershock discharge
    
if( g_fflPlayAfterShockPlayer ] && g_fflPlayAfterShockPlayer ] < get_gametime( ) )
    {
        
// Randomly play sound
        
switch( random_num(0) )
        {
            case 
0emit_soundPlayerCHAN_WEAPONg_szSoundElectro1,random_float0.70.8 ), ATTN_NORM0PITCH_NORM )
                case 
1emit_soundPlayerCHAN_WEAPONg_szSoundElectro2,random_float0.70.8 ), ATTN_NORM0PITCH_NORM )
                case 
2emit_soundPlayerCHAN_WEAPONg_szSoundElectro3,random_float0.70.8 ), ATTN_NORM0PITCH_NORM )
                case 
3: return // No sound
            
}
        
        
// Reset discharge
        
g_fflPlayAfterShockPlayer ] = 0.0
    
}
    
    
// Check if we are in a middle of attack
    
if( g_bInAttackPlayer ] != )
    {
        
// Check if have released attack2 button
        
if( get_gametime( ) - g_flLastShotTimePlayer ] > 0.2 )
        {
            
// Start to fire
            
StartFirePlayer )
            
            
// Reset attack state
            
g_bInAttackPlayer ] = 0
            
            
// Next idle time
            
g_flWeaponIdleTimePlayer ] = get_gametime( ) + 2.0 
        
}
    }
    else
    {
        
// Force to idle
        
WeaponIdlePlayer )
    }
}

// Player respawned
public fw_PlayerSpawn_PostPlayer )
{
    
// Not alive
    
if( !is_user_alivePlayer ) )
        return
    
    
// Update
    
g_bIsAlivePlayer ] = true
}

// Guass deploy
public fw_TCannonDeploy_PostiEnt )
{
    
// Get owner
    
static Player
    Player 
get_pdata_cbaseiEntm_pPlayer)
    
    
// Does this player has gauss?
    
if ( g_iHasGaussPlayer ] )
    {
        
// Replace models
        
set_pevPlayerpev_viewmodel2g_szModelGaussV )
        
set_pevPlayerpev_weaponmodel2g_szModelGaussP )
        
        
// Deploy animation
        
UTIL_PlayWeaponAnimationPlayergauss_draw )
        
        
// Reset aftershock
        
g_fflPlayAfterShockPlayer ] = 0.0
    
}
}

// Gauss holster
public fw_TCannonHolster_PostiEnt )
{
    
// Get owner
    
static Player
    Player 
get_pdata_cbaseiEntm_pPlayer)
    
    
// Does this player has gauss?
    
if ( g_iHasGaussPlayer ] )
    {
        
// Check if player is still attacking
        
if( g_bInAttackPlayer ] )
        {
            
// Bug!Bug!Stop spin sound
            
emit_soundPlayerCHAN_WEAPONg_szSoundGaussSpin0.00.0SND_STOP)
            
            
// Attack
            
StartFirePlayer )
        }
        
        
// Holster animation
        
UTIL_PlayWeaponAnimationPlayergauss_holster )
        
        
// Reset attack status
        
g_bInAttackPlayer ] = 0
    
}
}

// Add Gauss to players inventory
public fw_TCannonAddToPlayeriEntPlayer )
{
    
// Prevent run-time errors
    
if( is_valid_entiEnt ) && is_user_valid_connectedPlayer ) )
    {
        
// Seems that player has picked up a gauss
        
if( peviEntpev_weaponkey ) == GAUSS_WEAPONKEY )
        {
            
// Update variable
            
g_iHasGaussPlayer ] = true
            
            
// Update bp ammo
            
cs_set_user_bpammoPlayerCSW_M249peviEntpev_bpammo ) )
            
            
// Reset weapon options
            
set_peviEntpev_weaponkey)
            
set_peviEntpev_bpammo)
            
            return 
HAM_HANDLED
        
}
    }
    return 
HAM_IGNORED
}

// Gauss post frame
public fw_TCannonPostFrameiEnt )
{
    
// Get owner
    
static iOwner
    iOwner 
get_pdata_cbaseiEntm_pPlayer)
    
    
// Does this player has gauss?
    
if ( g_iHasGaussiOwner ] )
    {
        
// Reload offset
        
static fInReload 
        fInReload 
get_pdata_int iEntm_fInReload,)
        
        
// Next attack time
        
static Float:flNextAttack 
        flNextAttack 
get_pdata_float (iOwnerm_flNextAttack)
        
        
// Clip
        
static iClip
        iClip 
get_pdata_int iEntm_iClip)
        
        
// Ammo type
        
static iAmmoType 
        iAmmoType 
m_rgAmmo_player_Slot0 get_pdata_int iEntm_iPrimaryAmmoType)
        
        
// BP ammo
        
static iBpAmmo
        iBpAmmo 
get_pdata_int iOwneriAmmoType)    
        
        
// Reloading
        
if ( fInReload && flNextAttack <= 0.0 )
        {
            
// Calculate the difference
            
static 
            j 
min g_pClip iClipiBpAmmo )
            
            
// Set new clip
            
set_pdata_int iEntm_iClipiClip j)
            
            
// Decrease 'x' bullets from backpack(depending on new clip)
            
set_pdata_intiOwneriAmmoTypeiBpAmmo-j)
            
            
// Not reloding anymore
            
set_pdata_int iEntm_fInReload0)
            
fInReload 0
        
}
        
        
// Get buttons
        
static iButton iButton pev iOwnerpev_button)
        
        
// Attack/Attack2 buttons and next prim/sec attack time hasnt' come yet
        
if( ( iButton IN_ATTACK2 && get_pdata_float iEntm_flNextSecondaryAttack) <= 0.0)
        || ( 
iButton IN_ATTACK && get_pdata_float iEntm_flNextPrimaryAttack) <= 0.0) )
        {
            return
        }
    
        
// Reload button / not reloading
        
if( iButton IN_RELOAD && !fInReload )
        {
            
// Old clip is more/equal than/to new
            
if( iClip >= g_pClip )
            {
                
// Remove reload button
                
set_pev iOwnerpev_buttoniButton & ~IN_RELOAD )
                
                
// Idle animation
                
UTIL_PlayWeaponAnimation iOwnergauss_idle )
                
                
// Idle time
                
g_flWeaponIdleTimeiOwner ] = get_gametime( ) + 0.5
            
}
            else
            {
                
// Out of ammo
                
if ( !iBpAmmo )
                    return
                    
                
// Reload weapon
                
UTIL_WeaponReload iOwneriEnt )
            }
        }
    }
}

// Gauss reload post
public fw_TCannonReload_PostiEnt )
{
    
// Get owner
    
static Player
    Player 
get_pdata_cbaseiEntm_pPlayer)
    
    
// Does this player has gauss and is he in a middle of reloading ?
    
if ( g_iHasGaussPlayer ] && get_pdata_intiEntm_fInReload) )
    {
        
// Reload
        
UTIL_WeaponReloadPlayeriEnt )
    }
}

// ------------------------------- Internal Functions ----------------------------------------

// Gauss start fire
public StartFirePlayer )
{
    
// This var holds damage
    
static Float:flDamage
    
    
// Make vectors
    
UTIL_MakeVectorsPlayer )
    
    
// Get gametime
    
static Float:flGameTime
    flGameTime 
get_gametime( )
    
    
// This is maximal possible damage from secondary attack!
    
if( flGameTime g_flStartChargePlayer ] > GAUSS_CHARGETIME )
    {
        
flDamage g_pDmgSec
    
}
    else
    {
        
// The longer you hold attack button - the bigger is damage
        
flDamage g_pDmgSec * ( ( flGameTime g_flStartChargePlayer ] ) / GAUSS_CHARGETIME )
    }
    
    
// Primary attack do less damage
    
if( g_bPrimaryFirePlayer ] )
    {
        
flDamage g_pDmgPrim
    
}
    
    
// Make sure that we are not ending attack
    
if( g_bInAttackPlayer ] != )
    {
        
// Secondary attack can pop you up in the air.Not primary attack!
        
if( !g_bPrimaryFirePlayer ] )
        {
            
// Current players velocity
            
static Float:flVel], Float:v_forward]
            
pevPlayerpev_velocityflVel )
            
global_getglb_v_forwardv_forward )
            
            
// Try to affect only vertical velocity
            
VectorMSflVelflDamage 5.0v_forwardflVel )
            
            
// Jump!
            
set_pevPlayerpev_velocityflVel )
        }
    }
    
    
// Recoil
    
static Float:flRecoil]
    
flRecoil] = GAUSS_RECOIL
    set_pev
Playerpev_punchangleflRecoil )
    
    
// Fire animation
    
UTIL_PlayWeaponAnimationPlayergauss_fire2 )
    
    
// Fire sound
    
static Float:flResult
    flResult 
0.5 flDamage * ( 1.0 400.0 )
    
    if( 
flResult 1.0 )
    {
        
flResult 1.0
    
}
    
    
emit_soundPlayerCHAN_WEAPONg_szSoundGaussFireflResultATTN_NORM085 random_num00x1f ) )
    
    
// Get players aimpoint position
    
static Float:vecDest]
    
global_getglb_v_forwardvecDest )
    
    
// Calculate start position
    
static Float:vecSrc]
    
UTIL_GetGunPositionPlayervecSrc )
    
    
// Time until aftershock 'static discharge' sound
    
g_fflPlayAfterShockPlayer ] = flGameTime random_float0.30.8 )
    
    
// Fire!
    
FirePlayervecSrcvecDestflDamage )
}

// Fire!
FirePlayerFloat:vecOrigSrc[ ], Float:vecDir[ ], Float:flDamage )
{
    
// Start position
    
static Float:vecSrc]
    
xs_vec_copyvecOrigSrcvecSrc )
    
    
// Calculate end position
    
static Float:vecDest]
    
VectorMAvecSrc8192.0vecDirvecDest )
    
    
// Few trace handles
    
static trbeam_tr
    
    
// Max fraction
    
static Float:flMaxFrac
    flMaxFrac 
1.0
    
    
// Total
    
static nTotal
    nTotal 
0
    
    
// Does this beam punched the wall ?
    
static bool:fHasPunched
    fHasPunched 
false
    
    
// Does this is first beam
    
static bool:fFirstBeam
    fFirstBeam 
true
    
    
// Max hits
    
static nMaxHits
    nMaxHits 
10
    
    
// Entity whoch should be ignored
    
static pEntToIgnore
    
    
// Make sure that beam will'be able to cause damage
    
while( flDamage 10 && nMaxHits )
    {
        
// Decrease hit count
        
nMaxHits--
        
        
// Draw a trace line
        
engfuncEngFunc_TraceLinevecSrcvecDestDONT_IGNORE_MONSTERSpEntToIgnoretr )
        
        
// We'll never get outside!
        
if( get_tr2trTR_AllSolid ) )
            break
        
        
// Get entity which was hit
        
static pEntity
        pEntity 
Instanceget_tr2trTR_pHit ) )    
        
        
// Get vector end position
        
static Float:vecEnd]
        
get_tr2trTR_vecEndPosvecEnd )
        
        
// Its first beam    
        
if( fFirstBeam )
        {
            
// Add muzzleflash
            
set_pevPlayerpev_effectspev(Playerpev_effects) | EF_MUZZLEFLASH )
            
            
// Its not first anymore
            
fFirstBeam false
            
            
// Add
            
nTotal += 26
            
            
// Draw beam
            
engfuncEngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYvecSrc)
            
//message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
            
write_byteTE_BEAMENTPOINT // Temp. entity ID
            
write_shortPlayer 0x1000 // Start entity
            
engfuncEngFunc_WriteCoordvecEnd] ) // End position X
            
engfuncEngFunc_WriteCoordvecEnd] ) // End position Y
            
engfuncEngFunc_WriteCoordvecEnd] ) // End position Z
            
write_shortg_iBeam // Sprite index
            
write_byte// Start frame
            
write_byte// Frame rate
            
write_byte// Life
            
write_byteg_bPrimaryFirePlayer ] ? 16 25 // Line width
            
write_byte// Noise amplitude
            
write_byte255 )
            
write_byte128 )
            
write_byte)
            
write_byte255 // Alpha
            
write_byte// Scroll speed
            
message_end( )
        }
        else
        {
            
// Draw beam
            
engfuncEngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYvecSrc)
            
write_byteTE_BEAMPOINTS // Temp. entity ID
            
engfuncEngFunc_WriteCoordvecSrc] ) // Start position X
            
engfuncEngFunc_WriteCoordvecSrc] ) // Start position Y
            
engfuncEngFunc_WriteCoordvecSrc] ) // Start position Z
            
engfuncEngFunc_WriteCoordvecEnd] ) // End position X
            
engfuncEngFunc_WriteCoordvecEnd] ) // End position Y
            
engfuncEngFunc_WriteCoordvecEnd] ) // End position Z
            
write_shortg_iBeam // Sprite index
            
write_byte// Start frame
            
write_byte// Frame rate
            
write_byte// Life
            
write_byteg_bPrimaryFirePlayer ] ? 15 25 // Line width
            
write_byte// Noise amplitude
            
write_byte255 )
            
write_byte128 )
            
write_byte)
            
write_byte255 )
            
write_byte// Scroll speed
            
message_end( )
        }
        
        
// Check if this entity should take any damage
        
if( pevpEntitypev_takedamage ) != DAMAGE_NO )
        {
            
// Check if this is player and zombie
            
if( is_user_valid_connectedpEntity ) && zp_get_user_zombiepEntity ) )
            {
                
// Retrieve health
                
static iHealth
                iHealth 
get_user_healthpEntity )
            
                
// We should be alive
                
if( iHealth flDamage >= )
                {
                    
// Cause some damage
                    
ExecuteHamBHam_TakeDamagepEntity0PlayerflDamageDMG_BULLET DMG_ALWAYSGIB )
                }
                else
                {
                    
// Die
                    
g_bKilledByLaserpEntity ] = true
                    ExecuteHamB
Ham_KilledpEntityPlayer)
                    
g_bKilledByLaserpEntity ] = false
                
}
            }
        }
        
        
// Check if this entity should reflect our beam
        
if( ReflectGausspEntity ) )
        {
            static 
Float:n
            
            
// Return normal vector in a spot we hit
            
static Float:vecPlaneNormal]
            
get_tr2trTR_vecPlaneNormalvecPlaneNormal )
            
            
// Calculate dot product
            
= - xs_vec_dotvecPlaneNormalvecDir )
            
            
// 60 degrees
            
if ( 0.5 )
            {
                static 
Float:r]
                
VectorMAvecDir2.0 nvecPlaneNormal)
                
                
// Get vector end position
                
get_tr2trTR_vecEndPosvecEnd )
                
                
// Get trace fraction
                
static Float:trflFraction
                get_tr2
trTR_flFractiontrflFraction )
                
                
// Calculate fraction
                
flMaxFrac flMaxFrac trflFraction
                
                
// Copy vectors
                
xs_vec_copyrvecDir )
                
                
// Make more vector calculations
                
VectorMAvecEnd8.0vecDirvecSrc )
                
VectorMAvecSrc8192.0vecDirvecDest )
            
                
// Undone!Do radius damage
                
                // Increase
                
nTotal += 34
                
                
if( == )
                {
                    
// Lose energy
                    
0.1
                
}
                
                
// Calculate new damage
                
flDamage flDamage * ( )
            }
            else
            {
                
// Add gun shot decal on the world
                
FX_GunShotDecalvecEndpEntity )
                
                
// Add glowing sprite on the world
                
FX_TempSpritevecEnd6floatroundflDamage 255.0 ) )
                
                
// Increase
                
nTotal += 13
                
                
// Limit it to one hole punch
                
if( fHasPunched )
                    break
                
                
// Update    
                
fHasPunched true    
                
                
// Try punching through wall if secondary attack (primary is incapable of 
                // breaking through)
                
if( !g_bPrimaryFirePlayer ] )
                {
                    
// Retrieve vector end position
                    
get_tr2trTR_vecEndPosvecEnd )
                    
                    
// Modify start origin
                    
static Float:vecStart]
                    
VectorMAvecEnd8.0vecDirvecStart )
                    
                    
// Draw another trace line
                    
engfuncEngFunc_TraceLinevecSrcvecDestDONT_IGNORE_MONSTERSpEntToIgnorebeam_tr )
                    
                    
// We'll never get outside
                    
if( !get_tr2beam_trTR_AllSolid ) )
                    {
                        
// Get end position
                        
static Float:vecBeamEndPos]
                        
get_tr2beam_trTR_vecEndPosvecBeamEndPos )
                        
                        
// Trace backwards to find exit point
                        
engfuncEngFunc_TraceLinevecBeamEndPosvecEndDONT_IGNORE_MONSTERSpEntToIgnorebeam_tr )
                        
                        
// Again get end position
                        
get_tr2beam_trTR_vecEndPosvecBeamEndPos )
                        
                        static 
Float:nsFloat:vecSub]
                        
                        
// Subtract vectors
                        
xs_vec_subvecBeamEndPosvecEndvecSub )
                        
                        
// Get vector length
                        
ns xs_vec_lenvecSub )
                        
                        if( 
ns flDamage )
                        {
                            
// Lose enery
                            
if( ns == )
                            {
                                
ns 1.0
                            
}
                            
                            
// Decrease damage
                            
flDamage -= ns
                            
                            
// Subtract
                            
static Float:vecCalc]
                            
VectorSubtractvecEndvecDirvecCalc )
                            
                            
// Absorbtion balls
                            
FX_SpriteTrailvecEndvecCalcBALL_AMOUNT1532525 )
                            
                            
// Add gun shot decal on the world
                            
FX_GunShotDecalvecBeamEndPospEntity )
                            
                            
// And glowing sprite
                            
FX_TempSpritevecBeamEndPos6floatroundflDamage 255.0 ) )
                            
                            
// Subtract
                            
VectorSubtractvecBeamEndPosvecDirvecCalc )
                            
                            
// Absorbtion balls
                            
FX_SpriteTrailvecEndvecCalcBALL_AMOUNT1532525 )
                            
                            
// Increase shit
                            
nTotal += 21
                            
                            
/*
                            // Calculate radius damage
                            static Float:flRadDmg
                            flRadDmg = flDamage * 1.75
                            
                            // Undone.Do radius damage here!
                            floatradius( flDamage, flRadDmg, vecBeamEndPos )
                            */
                            
                            // Increase
                            
nTotal += 53
                            
                            VectorMA
vecBeamEndPos8.0vecDirvecSub )
                            
                            
// Add up vector
                            
xs_vec_addvecBeamEndPosvecDirvecSrc )
                        }
                    }
                    else
                    {
                        
flDamage 0.0
                    
}
                }
                else
                {
                    
// Primary attack
                    
if( g_bPrimaryFire Player ] )
                    {
                        
// Slug doesn't punch through ever with primary 
                        // fire, so leave a little glowy bit and make some balls
                        
FX_TempSpritevecEnd6floatroundflDamage 255.0 ) )
                        
FX_SpriteTrailvecEndvecDirBALL_AMOUNT1532525 )
                    }
                    
                    
flDamage 0.0
                
}
            }
        }
        else
        {
            
// Add up vector
            
xs_vec_addvecEndvecDirvecSrc )
            
pEntToIgnore pEntity
        
}
    }
}                

// Register and cache CVARs
public Load_Cvars( )
{
    
cvar_oneround register_cvar"zp_tcannon_oneround""0" )
    
cvar_dmgprim register_cvar"zp_tcannon_dmgprim""200" )
    
cvar_dmgsec register_cvar"zp_tcannon_dmgsec""500" )
    
cvar_clip register_cvar"zp_tcannon_clip""100" )
    
    
g_pOneRound get_pcvar_numcvar_oneround )
    
g_pDmgPrim get_pcvar_floatcvar_dmgprim )
    
g_pDmgSec get_pcvar_floatcvar_dmgsec )
    
g_pClip get_pcvar_numcvar_clip )
}

// Gauss weapon idle
WeaponIdlePlayer )
{
    
// Get gametime
    
static Float:flGameTime
    flGameTime 
get_gametime( )
    
    if( 
g_flWeaponIdleTimePlayer ] > flGameTime )
        return
    
    
// Animation sequence variable
    
static iAnim
    
    
// Animation randomizer
    
static Float:flRand
    flRand 
random_float0.11.0 )
    
    if( 
flRand <= 0.5 )
    {
        
iAnim gauss_idle
        g_flWeaponIdleTime
Player ] = flGameTime random_float10.015.0 )
    }
    else if( 
flRand <= 0.75 )
    {
        
iAnim gauss_idle2
        g_flWeaponIdleTime
Player ] = flGameTime random_float10.015.0 )
    }
    else
    {
        
iAnim gauss_fidget
        g_flWeaponIdleTime
Player ] = flGameTime 3
    
}
    
    
// Idle
    
UTIL_PlayWeaponAnimationPlayeriAnim )
}    

// Play weapon animation
UTIL_PlayWeaponAnimation( const Player, const Sequence )
{
    
set_pevPlayerpev_weaponanimSequence )
    
    
message_beginMSG_ONE_UNRELIABLESVC_WEAPONANIM, .player Player )
    
write_byteSequence )
    
write_bytepevPlayerpev_body ) )
    
message_end( )
}                

// Make ScreenFade
UTIL_ScreenFadePlayerDurationHoldTimeFlagsiRediGreeniBlueiAlpha )
{
    
message_beginMSG_ONEgmsgScreenFade_Player )
    
write_shortDuration )
    
write_shortHoldTime )
    
write_shortFlags )
    
write_byteiRed )
    
write_byteiGreen )
    
write_byteiBlue )
    
write_byteiAlpha )
    
message_end( )
}

// Reload gauss
UTIL_WeaponReloadPlayeriEnt )
{
    
// Modify time until next attack
    
set_pdata_floatPlayerm_flNextAttackGAUSS_RELOADTIME+0.5)
    
    
// Reload animation
    
UTIL_PlayWeaponAnimationPlayergauss_spin )
    
    
// Enable reload offset
    
set_pdata_intiEntm_fInReload1)
    
    
// Modify next idle time
    
g_flWeaponIdleTimePlayer ] = get_gametime( ) + GAUSS_RELOADTIME 1.0 
}

// Drop all primary weapons
UTIL_DropPrimaryPlayer )
{
    
// Get user weapons
    
static weapons32 ], numiweaponid
    num 
// reset passed weapons count (bugfix)
    
get_user_weaponsPlayerweaponsnum )
    
    
// Loop through them and drop primaries
    
for( 0numi++ )
    {
        
// Prevent re-indexing the array
        
weaponid weapons]
        
        
// We definetely are holding primary gun
        
if(( (1<<weaponid) & PRIMARY_WEAPONS_BITSUM ) )        
        {
            
// Get weapon entity
            
static wname[32]
            
get_weaponname(weaponidwnamecharsmax(wname))
            
            
// Player drops the weapon and looses his bpammo
            
engclient_cmdPlayer"drop"wname)
        }
    }
}

// Get gun position
UTIL_GetGunPositionPlayerFloat:flOrigin[ ] )
{
    static 
Float:vf_Origin], Float:vf_ViewOfs]
    
    
pevPlayerpev_originvf_Origin )
    
pevPlayerpev_view_ofsvf_ViewOfs )
    
    
xs_vec_addvf_Originvf_ViewOfsflOrigin )
}

// Make vectors
UTIL_MakeVectors Player )
{
    static 
Float:flAngle], Float:flPunchAngle]

    
pevPlayerpev_v_angleflAngle )
    
pevPlayerpev_punchangleflPunchAngle )

    
xs_vec_addflAngleflPunchAngleflAngle )
    
engfuncEngFunc_MakeVectorsflAngle )
}

// From HL SDK.
VectorMAFloat:a[ ], Float:flScaleFloat:b[ ], Float:c[ ] )
{
    
c] = a] + flScale b]
    
c] = a] + flScale b]
    
c] = a] + flScale b]
}

VectorMS( const Float:flSource[ ], const Float:flScale, const Float:flMult[ ], Float:flOutput[ ] )
{
        
flOutput] = flSource] - flMult] * flScale
        flOutput
] = flSource] - flMult] * flScale
        flOutput
] = flSource] - flMult] * flScale
}

// Another stuff from HLSDK
InstanceiEnt )
{
    return 
iEnt == -iEnt
}

// Does this entity should refect gauss?
ReflectGaussiEnt )
{
        return 
IsBSPModeliEnt ) && peviEntpev_takedamage ) == DAMAGE_NO 
}

// Does this entity is BSP model?
IsBSPModeliEnt )
{
    return 
peviEntpev_solid ) == SOLID_BSP || peviEntpev_movetype ) == MOVETYPE_PUSHSTEP 
}

// Add gun shot decal on world!
FX_GunShotDecalFloat:flPos[ ], pEntity )
{
    
// Draw gunshot
    
engfuncEngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYflPos)
    
write_byteTE_GUNSHOTDECAL // Temp.entity ID
    
engfuncEngFunc_WriteCoordflPos] ) // Position X
    
engfuncEngFunc_WriteCoordflPos] ) // Position Y
    
engfuncEngFunc_WriteCoordflPos] ) // Position Z
    
write_shortpEntity // Which entity to mark?
    
write_byte43 // Decal number
    
message_end( )
}

// Add glow sprite on world
FX_TempSpriteFloat:flPos[ ], iScaleiSize )
{
    
engfuncEngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYflPos)
    
write_byteTE_GLOWSPRITE // Temp.entity ID
    
engfuncEngFunc_WriteCoordflPos] ) // Position X
    
engfuncEngFunc_WriteCoordflPos] ) // Position Y
    
engfuncEngFunc_WriteCoordflPos] ) // Position Z
    
write_shortg_iBalls // Sprite index
    
write_byteiScale // Scale
    
write_byteiSize // Size
    
write_byte255 // Brightness
    
message_end( )
}

// Add sprite trail
FX_SpriteTrailFloat:vecStart[ ], Float:vecDest[ ], iCountiLifeiScaleiVeliRnd )
{
    
message_beginMSG_BROADCASTSVC_TEMPENTITY )
    
write_byteTE_SPRITETRAIL // Sprite trail
    
engfuncEngFunc_WriteCoordvecStart] ) // Position X
    
engfuncEngFunc_WriteCoordvecStart] ) // Position Y
    
engfuncEngFunc_WriteCoordvecStart] ) // Position Z
    
engfuncEngFunc_WriteCoordvecDest] ) // Position X
    
engfuncEngFunc_WriteCoordvecDest] ) // Position Y
    
engfuncEngFunc_WriteCoordvecDest] ) // Position Z
    
write_shortg_iBalls // SPrite index
    
write_byteiCount // Amount
    
write_byteiLife // Life
    
write_byteiScale // Scale
    
write_byteiVel // Velocity along vector
    
write_byteiRnd // Randomness of velocity
    
message_end( )

__________________
H.RED.ZONE is offline
PaunVictor
New Member
Join Date: Sep 2011
Old 02-23-2012 , 07:21   Re: [HELP] Vip extra
#7

Quote:
Originally Posted by Johnnynho123 View Post
and what is wrong here ?
Code:
/*
    [ZP] Extra Item: Tau Cannon
    Copyright (C) 2009-2010 by NiHiLaNTh

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    In addition, as a special exception, the author gives permission to
    link the code of this program with the Half-Life Game Engine ("HL
    Engine") and Modified Game Libraries ("MODs") developed by Valve,
    L.L.C ("Valve"). You must obey the GNU General Public License in all
    respects for all of the code used other than the HL Engine and MODs
    from Valve. If you modify this file, you may extend this exception
    to your version of the file, but you are not obligated to do so. If
    you do not wish to do so, delete this exception statement from your
    version.
    
    --- Introduction ---
    This plugin adds new weapon - Tau Cannon.Basically, this is almost
    the same weapon as in Half-Life.An experimental, highly unstable weapon. 
    One of the most important abilities is that it can shoot through walls, 
    making it so that you can't take cover against it. The gauss's primary 
    fire shoots out tiny spurts that are only effective in close to medium 
    range due to its erratic spread. You can charge up the gauss by holding 
    down alternate fire; the longer you charge it up, the stronger it gets. 
    The longer you charge it up is directly proportional to the thickness 
    of the wall you can shoot through. Lookout campers, retribution has come.
    
    ---CVARs---
    zp_tcannon_oneround - Should Tau Cannon be in players inventory only for 1 round?
    zp_tcannon_dmgprim - Primary attack damage
    zp_tcannon_dmgsec - Maximal secondary attack damage
    zp_tcannon_clip - Clip amount
    
    --- Credits ---
    Arkshine, HL SDK, meTaLiCroSS and more...
    
    --- Changelog ---
    1.0 - Initial release.
    1.1 - Added some statics
    1.2 - Fixed ammo buy bug
        - Fixed possible server crash
*/    
    
#include < amxmodx >
#include < cstrike >
#include < csx >
#include < engine >
#include < fakemeta >
#include < hamsandwich >
#include < fun >
#include < xs >
#include < zombieplague >
#include < zmvip >

// Plugin information
#define Plugin    "[ZP] Extra Item: Tau Cannon"
#define Version    "1.2"
#define Author    "NiHiLaNTh"

// Maxplayers
const MaxPlayers = 32

// Weapon models
new const g_szModelGaussP[ ] = "models/p_gauss.mdl"
new const g_szModelGaussV[ ] = "models/v_alt_gauss.mdl"
new const g_szModelGaussW[ ] = "models/w_gauss.mdl"

// Weapon sounds
new const g_szSoundGaussFire[ ] = "weapons/gauss2.wav"
new const g_szSoundGaussSpin[ ] = "ambience/pulsemachine.wav"
new const g_szSoundElectro1[ ] = "weapons/electro4.wav"
new const g_szSoundElectro2[ ] = "weapons/electro5.wav"
new const g_szSoundElectro3[ ] = "weapons/electro6.wav"

// Some gauss/beam stuff
#define GAUSS_REFIRERATE    0.2 // Primary attack
#define GAUSS_REFIRERATE2    0.1 // Secondary attack(you shouldnt change this!)
#define GAUSS_RECOIL        -2.0 // Only X axis!
#define GAUSS_CHARGETIME    4.0 // From HLSDK
#define GAUSS_RELOADTIME    2.0 // Reload time
#define BEAM_RED        255 // Red amount
#define BEAM_GREEN        128 // Green amount
#define BEAM_BLUE        0 // Blue amount
#define BEAM_ALPHA        255 // Brightness(Alpha)
#define BALL_AMOUNT        8 // How many balls should appear :p

// Ammo given when buy weapons    
new const BUYAMMO[] = { -1, 13, -1, 30, -1, 8, -1, 12, 30, -1, 30, 50, 12, 30, 30, 30, 12, 30,
1, 30, 30, 8, 30, 30, 30, -1, 7, 30, 30, -1, 50 }

// Max. bp ammo amount
new const MAXBPAMMO[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120,
    5, 120, 200, // This is gauss max bp ammo.Change it if you want!
32, 90, 120, 90, 2, 35, 90, 90, -1, 100 }

// Weapon ammo ID's
new const AMMOID[] = { -1, 9, -1, 2, 12, 5, 14, 6, 4, 13, 10, 7, 6, 4, 4, 4, 6, 10,
1, 10, 3, 5, 4, 10, 2, 11, 8, 4, 2, -1, 7 }

// Player variables
new g_iHasGauss[ MaxPlayers+1 ] // Whether player has gauss
new g_iSoundState[ MaxPlayers+1 ] // Weapon sound state
new g_bInAttack[ MaxPlayers+1 ] // Current gauss attack state
new g_iCurrentWeapon[ MaxPlayers+1 ] // Current weapon player is holding
new Float:g_flLastShotTime[ MaxPlayers+1 ] // Last shot time
new Float:g_fflPlayAfterShock[ MaxPlayers+1 ] // Play aftershock sound
new Float:g_flWeaponIdleTime[ MaxPlayers+1 ] // Weapon idle time
new Float:g_flNextAmmoBurn[ MaxPlayers+1 ] // Next ammo burn time
new Float:g_flStartCharge[ MaxPlayers+1 ] // Weapon start charge
new Float:g_flAmmoStartCharge[ MaxPlayers+1 ] // Ammo start charge
new bool:g_bIsAlive[ MaxPlayers+1 ] // Whether player is alive
new bool:g_bIsConnected[ MaxPlayers+1 ] // Whether player is connected
new bool:g_bPrimaryFire[ MaxPlayers+1 ] // Does this weapon is using primary attack ?
new bool:g_bKilledByLaser[ MaxPlayers+1 ] // Imma firin mah lazor O.o

// CVAR pointers
new cvar_oneround // Whether gun should be only for 1 round
new cvar_dmgprim // Primary attack damage
new cvar_dmgsec // Secondary attack damage
new cvar_clip // Clip amount

// Cached CVAR
new g_pOneRound
new Float:g_pDmgPrim
new Float:g_pDmgSec
new g_pClip

// Global varibles
new g_iMaxPlayers // Maxplayers
new bool:g_bGameRestart // Detect game restart
new g_iBeam // Beam sprite
new g_iBalls // Balls :p
new g_iGaussID // Item ID
new gmsgScreenFade // Screen fade
new gmsgAmmoPickup // Ammo pickup

// CS Offsets
const m_pPlayer = 41
const m_flNextPrimaryAttack = 46
const m_flNextSecondaryAttack = 47
const m_flTimeWeaponIdle = 48
const m_iPrimaryAmmoType = 49
const m_iClip = 51
const m_fInReload = 54
const m_flNextAttack  = 83
const m_rgAmmo_player_Slot0 = 376

// Macro 
#define is_user_valid_connected(%1)        ( 1 <= %1 <= g_iMaxPlayers && g_bIsConnected [ %1 ] )
#define is_user_in_water(%1)            ( pev ( %1, pev_waterlevel ) == 3 )
#define VectorSubtract(%1,%2,%3)        ( %3[ 0 ] = %1[ 0 ] - %2[ 0 ], %3[ 1 ] = %1[ 1 ] - %2[ 1 ], %3[ 2 ] = %1[ 2 ] - %2[ 2 

] )
#define VectorAdd(%1,%2,%3)            ( %3[ 0 ] = %1[ 0 ] + %2[ 0 ], %3[ 1 ] = %1[ 1 ] + %2[ 2 ], %3[ 2 ] = %1[ 

2 ] + %2[ 2 ] )
#define VectorScale(%1,%2,%3)            ( %3[ 0 ] = %2 * %1[ 0 ], %3[ 1 ] = %2 * %1[ 1 ], %3[ 2 ] = %2 * %1[ 2 ] )
#define VectorLength(%1)                 ( floatsqroot ( %1[ 0 ] * %1[ 0 ] + %1[ 1 ] * %1[ 1 ] + %1[ 2 ] * %1[ 2 ] ) )

// Hack!Custom fields
#define pev_weaponkey        pev_impulse
#define pev_bpammo        pev_iuser3

// Misc stuff
#define FCVAR_FLAGS        ( FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED )
#define GAUSS_WEAPONKEY    42856
#define NULLENT        -1
#define FFADE_IN        0x0000
#define UNIT_SECOND        (1<<12)

// Entity classnames
new const g_szClassPlayer[ ] = "player"
new const g_szClassM249[ ] = "weapon_m249"

// Primary weapon bitsum
const PRIMARY_WEAPONS_BITSUM = 

(1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GA

LIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TM

P)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)

// Animation sequnces
enum
{
    gauss_idle,
    gauss_idle2,
    gauss_fidget,
    gauss_spinup,
    gauss_spin,
    gauss_fire,
    gauss_fire2,
    gauss_holster,
    gauss_draw
}

// Precache
public plugin_precache( )
{
    // Weapon models
    precache_model( g_szModelGaussP )
    precache_model( g_szModelGaussV )
    precache_model( g_szModelGaussW )
    
    // Sounds
    precache_sound( g_szSoundGaussFire )
    precache_sound( g_szSoundGaussSpin )
    precache_sound( g_szSoundElectro1 )
    precache_sound( g_szSoundElectro2 )
    precache_sound( g_szSoundElectro3 )
    precache_sound( "items/9mmclip1.wav" )
    
    // Sprites
    g_iBeam = precache_model( "sprites/smoke.spr" )
    g_iBalls = precache_model( "sprites/hotglow.spr" )
}

// Initialization
public plugin_init( )
{
    // New plugin
    register_plugin( Plugin, Version, Author )
    
    // For Game-Monitor support
    register_cvar( "zp_tcannon_version", Version, FCVAR_FLAGS )
    
    // New extra item
    g_iGaussID = zv_register_extra_item( "Tau Cannon", 60, ZV_TEAM_HUMAN )
    
    // Client commands
    register_clcmd( "buyammo1", "fn_BuyAmmo" )
    register_clcmd( "buyammo2", "fn_BuyAmmo" )
    
    // Events
    register_event( "CurWeapon", "EV_CurWeapon", "be", "1=1" )
    register_event( "DeathMsg", "EV_DeathMsg", "a" )
    register_event( "HLTV", "EV_RoundStart", "a", "1=0", "2=0" )
    register_event( "TextMsg", "EV_GameRestart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in" )
    
    // FakeMeta forwards
    register_forward( FM_SetModel, "fw_SetModel" )
    register_forward( FM_CmdStart, "fw_CmdStart" )
    register_forward( FM_UpdateClientData, "fw_UpdateClientData_Post", 1 )
    register_forward( FM_PlayerPreThink, "fw_PlayerPreThink" )
    
    // HamSandwich forwards
    RegisterHam( Ham_Spawn, g_szClassPlayer, "fw_PlayerSpawn_Post", 1 )
    RegisterHam( Ham_Item_Deploy, g_szClassM249, "fw_TCannonDeploy_Post", 1 )
    RegisterHam( Ham_Item_Holster, g_szClassM249, "fw_TCannonHolster_Post", 1 )
    RegisterHam( Ham_Item_AddToPlayer, g_szClassM249, "fw_TCannonAddToPlayer" )
    RegisterHam( Ham_Item_PostFrame, g_szClassM249, "fw_TCannonPostFrame" )
    RegisterHam( Ham_Weapon_Reload, g_szClassM249, "fw_TCannonReload_Post", 1 )
    
    // CVARs are in Load_Cvars( ) function!
    
    // Messages
    register_message( get_user_msgid( "DeathMsg" ), "fn_DeathMsg" )
    gmsgScreenFade = get_user_msgid( "ScreenFade" )
    gmsgAmmoPickup = get_user_msgid( "AmmoPickup" )
    
    // Store maxplayers in a global variable
    g_iMaxPlayers = get_maxplayers( )
}    

// Configuration
public plugin_cfg( )
{
    // Cache CVARs
    set_task( 1.5, "Load_Cvars" )
}

// ------------------------------- Game Events ----------------------------------------

// Client connected
public client_connect( Player )
{
    // Make a lot of updates
    g_iHasGauss[ Player ] = false
    g_bInAttack[ Player ] = 0
    g_fflPlayAfterShock[ Player ] = 0.0
    g_flWeaponIdleTime[ Player ] = 0.0
    g_bPrimaryFire[ Player ] = false
    g_bIsAlive[ Player ] = false
    g_bIsConnected[ Player ] = true
}

// Client disconnected
public client_disconnect( Player )
{
    // Only few important updates
    g_bIsAlive[ Player ] = false
    g_bIsConnected[ Player ] = false
}

// Someone selected our extra item
public zv_extra_item_selected( Player, Item )
{
    // Tau Cannon
    if ( Item == g_iGaussID )
    {
        // Drop all primary weapons
        UTIL_DropPrimary( Player )
        
        // Update
        g_iHasGauss[ Player ] = true
        
        // Give m249
        give_item( Player, "weapon_m249" )
        
        // Find weapon entity
        new iEnt = find_ent_by_owner( NULLENT, g_szClassM249, Player )
        
        // Apply new clip
        cs_set_weapon_ammo( iEnt, g_pClip )
        
        // Back pack ammo
        cs_set_user_bpammo( Player, CSW_M249, MAXBPAMMO[ 20 ] )
    }
}

// Player is trying to buy something
public fn_BuyAmmo( Player )
{
    // Not alive
    if( !g_bIsAlive[ Player ] )
        return PLUGIN_HANDLED
    
    // Dont have Tau Cannon
    if( !g_iHasGauss[ Player ] )
        return PLUGIN_CONTINUE
    
    // Retrieve ammo pack amount
    static iAmmoPack
    iAmmoPack = zp_get_user_ammo_packs( Player )
    
    // Out of ammo packs
    if( iAmmoPack <= 0 )
        return PLUGIN_HANDLED
    
    // Get players weapons
    static weapons[ 32 ], num, i, currentammo, weaponid, refilled
    num = 0 // reset passed weapons count (bugfix)
    refilled = false
    get_user_weapons( Player, weapons, num )
    
    // Loop through them and give the right ammo type
    for( i = 0; i < num; i++ )
    {
        // Prevents re-indexing the array
        weaponid = weapons[ i ]
        
        // Primary and secondary only
        if( MAXBPAMMO[ weaponid ] > 2 )
        {
            // Get current ammo of the weapon
            currentammo = cs_get_user_bpammo( Player, weaponid)
            
            // Check if we are close to the BP ammo limit
            if (currentammo < MAXBPAMMO[weaponid]-BUYAMMO[weaponid])
            {
                // Flash ammo in hud
                message_begin(MSG_ONE_UNRELIABLE, gmsgAmmoPickup, _, Player )
                write_byte(AMMOID[weaponid]) // ammo id
                write_byte(BUYAMMO[weaponid]) // ammo amount
                message_end()
                
                // Increase BP ammo
                cs_set_user_bpammo ( Player, weaponid, currentammo + BUYAMMO[weaponid])
                
                refilled = true
            }
            else if (currentammo < MAXBPAMMO[weaponid])
            {
                // Flash ammo in hud
                message_begin(MSG_ONE_UNRELIABLE, gmsgAmmoPickup, _, Player )
                write_byte(AMMOID[weaponid]) // ammo id
                write_byte(MAXBPAMMO[weaponid]-currentammo) // ammo amount
                message_end()
                
                // Reached the limit
                cs_set_user_bpammo ( Player, weaponid, MAXBPAMMO[weaponid])
                
                refilled = true
            }
        }
    }
    
    // Weapons already have full ammo
    if (!refilled) return PLUGIN_HANDLED
    
    // Deduce ammo packs, play clip purchase sound, and notify the player
    zp_set_user_ammo_packs( Player, --iAmmoPack )
    engfunc(EngFunc_EmitSound, Player, CHAN_ITEM, "items/9mmclip1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    client_print( Player, print_chat, "[ZP] You purchased extra ammo for your guns." )
    
    return PLUGIN_HANDLED
}    

// Current weapon player is holding
public EV_CurWeapon( Player )
{
    // Not alive
    if( !g_bIsAlive[ Player ] )
        return PLUGIN_CONTINUE
    
    // Update
    g_iCurrentWeapon[ Player ] = read_data( 2 )
    
    return PLUGIN_CONTINUE
}

// Someone died
public EV_DeathMsg( )
{
    // Get victim
    static iVictim
    iVictim = read_data( 2 )
    
    // Not connected
    if( !is_user_valid_connected( iVictim ) )
        return
    
    // Update
    g_bIsAlive[ iVictim ] = false
    
    // Check if victim has gauss
    if( g_iHasGauss[ iVictim ] && !is_user_bot( iVictim ) )
    {
        // Force to drop
        engclient_cmd( iVictim, "drop weapon_m249" )
    }
}

// Round started
public EV_RoundStart( )
{
    // Restart/One round only
    if( g_bGameRestart || g_pOneRound )
    {
        // Reset array value
        arrayset( g_iHasGauss, false, MaxPlayers+1 )
    }
    
    // Update
    g_bGameRestart = false
}

// Game restart
public EV_GameRestart( )
{
    // Update
    g_bGameRestart = true
}

// Hook death message
public fn_DeathMsg( Player, Dest, iEntity )
{
    // Get victim
    static iVictim, iKiller
    iKiller = get_msg_arg_int( 1 )
    iVictim = get_msg_arg_int( 2 )
    
    // Not connected
    if( !is_user_valid_connected( iVictim ) || iKiller == iVictim )
        return PLUGIN_CONTINUE
    
    // We were killed by laser
    if ( g_bKilledByLaser[ iVictim ] )
    {
        // Replace name in console
        set_msg_arg_string ( 4, "tau cannon" )
    }
    return PLUGIN_CONTINUE
}

// ------------------------------- Forwards ----------------------------------------

// Replace world model
public fw_SetModel ( Entity, const Model [ ] )
{
    // Prevent invalid entity messages
    if( !pev_valid( Entity ) )
        return FMRES_IGNORED
    
    // Not w_awp.mdl
    if( !equal( Model, "models/w_m249.mdl" ) )
        return FMRES_IGNORED
    
    // Get entity classname
    static szClassname[ 32 ]
    pev( Entity, pev_classname, szClassname, charsmax( szClassname ) )
    
    // Not weaponbox
    if( !equal( szClassname, "weaponbox" ) )
        return FMRES_IGNORED
    
    // Get owner
    static iOwner
    iOwner = pev( Entity, pev_owner )
    
    // Get awp ID
    static iWeaponID
    iWeaponID = find_ent_by_owner( NULLENT, g_szClassM249, Entity )
    
    // Make sure that we have gauss
    if( g_iHasGauss [ iOwner ] && is_valid_ent( iWeaponID ) )
    {
        // Hack! Store weaponkey
        set_pev( iWeaponID, pev_weaponkey, GAUSS_WEAPONKEY )
        
        // Hack! Store bp ammo
        set_pev( iWeaponID, pev_bpammo, cs_get_user_bpammo( iOwner, CSW_M249 ) )
        
        // Update
        g_iHasGauss[ iOwner ] = false
        
        // Replace models
        engfunc( EngFunc_SetModel, Entity, g_szModelGaussW )
        return FMRES_SUPERCEDE
    }
    return FMRES_IGNORED
}

// Command start
public fw_CmdStart( Player, UC_Handle, Seed )
{
    // Not alive/dont have gauss/not m249
    if( !g_bIsAlive[ Player ] || !g_iHasGauss[ Player ] || g_iCurrentWeapon[ Player ] != CSW_M249 )
        return FMRES_IGNORED
    
    // Retrieve pressed button bitsum
    static iButtons
    iButtons = get_uc( UC_Handle, UC_Buttons )
    
    // Retrieve game time
    static Float:flGameTime
    flGameTime = get_gametime( )
    
    // Retrieve weapon entity
    static iEnt
    iEnt = find_ent_by_owner( NULLENT, g_szClassM249, Player )
    
    // Retrieve clip amount
    static iClip
    iClip = cs_get_weapon_ammo( iEnt )
    
    // Primary attack
    if( iButtons & IN_ATTACK )
    {
        // Remove attack buttons from their button mask
        iButtons &= ~IN_ATTACK
        set_uc( UC_Handle, UC_Buttons, iButtons )
        
        // Prevent too fast shooting
        if( flGameTime - g_flLastShotTime[ Player ] < GAUSS_REFIRERATE )
            return FMRES_IGNORED
        
        // Dont fire while reloading
        if( get_pdata_int( iEnt, m_fInReload, 4 ) )
            return FMRES_IGNORED
        
        // Not enough clip/under water
        if( iClip < 2 || is_user_in_water( Player ) )
        {
            // Emit empty sound
            ExecuteHamB( Ham_Weapon_PlayEmptySound, iEnt )
            return FMRES_IGNORED
        }
        
        // Update
        g_bPrimaryFire[ Player ] = true
        
        // Start to fire
        StartFire( Player )
        
        // Decrease clip
        cs_set_weapon_ammo( iEnt, iClip-2 )
        
        // Reset weapon attack status
        g_bInAttack[ Player ] = 0
        
        // Set time when idle animation should be played
        g_flWeaponIdleTime[ Player ] = flGameTime + 1.0
        
        // Remember last shot time
        g_flLastShotTime[ Player ] = flGameTime
    }
    // Secondary attack
    else if( iButtons & IN_ATTACK2 )
    {
        // Prevent too fast shooting
        if( flGameTime - g_flLastShotTime[ Player ] < GAUSS_REFIRERATE2 )
            return FMRES_IGNORED
        
        // Dont fire while reloading
        if( get_pdata_int( iEnt, m_fInReload, 4 ) )
            return FMRES_IGNORED
        
        // Are we swimming ?
        if( is_user_in_water( Player ) )
        {
            // We are in a middle of attack
            if( g_bInAttack[ Player ] != 0 )
            {
                // Stop attack
                emit_sound( Player, CHAN_WEAPON, g_szSoundElectro1, VOL_NORM, ATTN_NORM, 0, 

80 + random_num( 0, 0x3f ) )
                
                // Gun idle
                UTIL_PlayWeaponAnimation( Player, gauss_idle )
                return FMRES_IGNORED
            }
            else
            {
                // Empty sound
                ExecuteHamB( Ham_Weapon_PlayEmptySound, iEnt )
                return FMRES_IGNORED
            }
        }
        
        // Get player oldbuttons
        static iOldButtons
        iOldButtons = pev( Player, pev_oldbuttons )
        
        // Make sure that we are holding secondary attack button
        if( iOldButtons & IN_ATTACK2 )
        {
            // Which attack state do we have
            switch ( g_bInAttack[ Player ] )
            {
                case 0: // Attack start
                {
                    // Out of ammo
                    if ( iClip <= 0 )
                    {
                        ExecuteHamB( Ham_Weapon_PlayEmptySound, iEnt )
                        return FMRES_IGNORED
                    }
                    
                    // We aren't using primary attack anymore
                    g_bPrimaryFire[ Player ] = false
                    
                    // Decrease clip
                    cs_set_weapon_ammo( iEnt, --iClip )
                    
                    // Update
                    g_flNextAmmoBurn[ Player ] = flGameTime
                    
                    // Send spinup animation
                    UTIL_PlayWeaponAnimation( Player, gauss_spinup )
                    
                    // Update attack state
                    g_bInAttack[ Player ] = 1
                    
                    // Next idle time
                    g_flWeaponIdleTime[ Player ] = flGameTime + 0.5
                    
                    // Update
                    g_flStartCharge[ Player ] = flGameTime
                    g_flAmmoStartCharge[ Player ] = flGameTime + GAUSS_CHARGETIME
                    
                    // Update sound state
                    g_iSoundState[ Player ] = 0
                    
                    // Spin sound
                    emit_sound( Player, CHAN_WEAPON, g_szSoundGaussSpin, VOL_NORM, 

ATTN_NORM, g_iSoundState[Player ], 110 )
                    
                    // Change sound state
                    g_iSoundState[ Player ] = SND_CHANGE_PITCH
                }
                case 1: // In a middle of attack
                {
                    if( g_flWeaponIdleTime[ Player ] < flGameTime )
                    {
                        // Spin anim
                        UTIL_PlayWeaponAnimation( Player, gauss_spin )
                        
                        // Update state
                        g_bInAttack[ Player ] = 2
                    }
                }
                default: // End of attack
                {
                    // During the charging process, eat one bit of ammo every once in a while
                    if( flGameTime >= g_flNextAmmoBurn[ Player ] && g_flNextAmmoBurn[ Player ] != 

1000 )
                    {
                        // Decrease clip
                        cs_set_weapon_ammo( iEnt, --iClip )
                        
                        // Next time when ammo should be decreased
                        g_flNextAmmoBurn[ Player ] = flGameTime + 0.1
                    }
                    
                    // Shit!We run out of ammo
                    if( iClip <= 0 )
                    {
                        // Force gun to fire
                        StartFire( Player )
                        
                        // Reset weapon state
                        g_bInAttack[ Player ] = 0
                        
                        // Set next idle time
                        g_flWeaponIdleTime[ Player ] = flGameTime + 1.0
                    }
                    
                    // Gun is fully charged up
                    if( flGameTime >= g_flAmmoStartCharge[ Player ] )
                    {
                        // Dont eat any more ammo!
                        g_flNextAmmoBurn[ Player ] = 1000.0
                    }
                    
                    // Calculate pitch
                    static Float:flPitch
                    flPitch = ( flGameTime - g_flStartCharge[ Player ] ) * ( 150 / 

GAUSS_CHARGETIME ) + 100
                    
                    // Pitch shouldnt be THAT big
                    if ( flPitch > 250 )
                    {
                        flPitch = 250.0
                    }
                    
                    // Spin sound
                    emit_sound( Player, CHAN_WEAPON, g_szSoundGaussSpin, VOL_NORM, 

ATTN_NORM, ( g_iSoundState[ Player ] == SND_CHANGE_PITCH ) ? 1 : 0, floatround( flPitch ) )
                    
                    // Hack for going through level transitions
                    g_iSoundState[ Player ] = SND_CHANGE_PITCH
                    
                    // We are charing way too long!
                    if( g_flStartCharge[ Player ] < flGameTime - 10 )
                    {
                        // ZAP!
                        emit_sound( Player, CHAN_WEAPON, g_szSoundElectro1, 

VOL_NORM, ATTN_NORM, 0, 80 + random_num( 0, 0x3f ) )
                        emit_sound( Player, CHAN_VOICE, g_szSoundElectro3, VOL_NORM, 

ATTN_NORM, 0, 80 + random_num( 0, 0x3f ) )
                        
                        // Reset fire state
                        g_bInAttack[ Player ] = 0
                        
                        // Next idle time
                        g_flWeaponIdleTime[ Player ] = flGameTime + 1.0
                        
                        // Damage player
                        ExecuteHamB( Ham_TakeDamage, Player, 0, Player, 50.0, 

DMG_SHOCK )
                        
                        // Make screen fade
                        UTIL_ScreenFade( Player, UNIT_SECOND*2, UNIT_SECOND/2, 

FFADE_IN, 255, 128, 0, 128 )
                        
                        // Idle animation
                        UTIL_PlayWeaponAnimation( Player, gauss_idle )
                    }
                }
            }
            
            // Update
            g_flLastShotTime[ Player ] = flGameTime
        }
    }
    
    return FMRES_HANDLED
}

// Update client data post
public fw_UpdateClientData_Post ( Player, SendWeapons, CD_Handle )
{
    // Not alive / dont have gauss/ not m249
    if ( !g_bIsAlive [ Player ] || !g_iHasGauss [ Player ] || g_iCurrentWeapon [ Player ] != CSW_M249 )
        return FMRES_IGNORED
    
    // Block default sounds/animations
    set_cd ( CD_Handle, CD_flNextAttack, halflife_time ( ) + 0.001 )
    return FMRES_HANDLED
}

// Player pre think
public fw_PlayerPreThink( Player )
{
    // Not alive / dont have gauss/ not m249
    if ( !g_bIsAlive [ Player ] || !g_iHasGauss [ Player ] || g_iCurrentWeapon [ Player ] != CSW_M249 )
        return
    
    // Play aftershock discharge
    if( g_fflPlayAfterShock[ Player ] && g_fflPlayAfterShock[ Player ] < get_gametime( ) )
    {
        // Randomly play sound
        switch( random_num(0, 3 ) )
        {
            case 0: emit_sound( Player, CHAN_WEAPON, g_szSoundElectro1,random_float( 0.7, 0.8 ), 

ATTN_NORM, 0, PITCH_NORM )
                case 1: emit_sound( Player, CHAN_WEAPON, g_szSoundElectro2,random_float( 0.7, 0.8 ), 

ATTN_NORM, 0, PITCH_NORM )
                case 2: emit_sound( Player, CHAN_WEAPON, g_szSoundElectro3,random_float( 0.7, 0.8 ), 

ATTN_NORM, 0, PITCH_NORM )
                case 3: return // No sound
            }
        
        // Reset discharge
        g_fflPlayAfterShock[ Player ] = 0.0
    }
    
    // Check if we are in a middle of attack
    if( g_bInAttack[ Player ] != 0 )
    {
        // Check if have released attack2 button
        if( get_gametime( ) - g_flLastShotTime[ Player ] > 0.2 )
        {
            // Start to fire
            StartFire( Player )
            
            // Reset attack state
            g_bInAttack[ Player ] = 0
            
            // Next idle time
            g_flWeaponIdleTime[ Player ] = get_gametime( ) + 2.0 
        }
    }
    else
    {
        // Force to idle
        WeaponIdle( Player )
    }
}

// Player respawned
public fw_PlayerSpawn_Post( Player )
{
    // Not alive
    if( !is_user_alive( Player ) )
        return
    
    // Update
    g_bIsAlive[ Player ] = true
}

// Guass deploy
public fw_TCannonDeploy_Post( iEnt )
{
    // Get owner
    static Player
    Player = get_pdata_cbase( iEnt, m_pPlayer, 4 )
    
    // Does this player has gauss?
    if ( g_iHasGauss[ Player ] )
    {
        // Replace models
        set_pev( Player, pev_viewmodel2, g_szModelGaussV )
        set_pev( Player, pev_weaponmodel2, g_szModelGaussP )
        
        // Deploy animation
        UTIL_PlayWeaponAnimation( Player, gauss_draw )
        
        // Reset aftershock
        g_fflPlayAfterShock[ Player ] = 0.0
    }
}

// Gauss holster
public fw_TCannonHolster_Post( iEnt )
{
    // Get owner
    static Player
    Player = get_pdata_cbase( iEnt, m_pPlayer, 4 )
    
    // Does this player has gauss?
    if ( g_iHasGauss[ Player ] )
    {
        // Check if player is still attacking
        if( g_bInAttack[ Player ] )
        {
            // Bug!Bug!Stop spin sound
            emit_sound( Player, CHAN_WEAPON, g_szSoundGaussSpin, 0.0, 0.0, SND_STOP, 0 )
            
            // Attack
            StartFire( Player )
        }
        
        // Holster animation
        UTIL_PlayWeaponAnimation( Player, gauss_holster )
        
        // Reset attack status
        g_bInAttack[ Player ] = 0
    }
}

// Add Gauss to players inventory
public fw_TCannonAddToPlayer( iEnt, Player )
{
    // Prevent run-time errors
    if( is_valid_ent( iEnt ) && is_user_valid_connected( Player ) )
    {
        // Seems that player has picked up a gauss
        if( pev( iEnt, pev_weaponkey ) == GAUSS_WEAPONKEY )
        {
            // Update variable
            g_iHasGauss[ Player ] = true
            
            // Update bp ammo
            cs_set_user_bpammo( Player, CSW_M249, pev( iEnt, pev_bpammo ) )
            
            // Reset weapon options
            set_pev( iEnt, pev_weaponkey, 0 )
            set_pev( iEnt, pev_bpammo, 0 )
            
            return HAM_HANDLED
        }
    }
    return HAM_IGNORED
}

// Gauss post frame
public fw_TCannonPostFrame( iEnt )
{
    // Get owner
    static iOwner
    iOwner = get_pdata_cbase( iEnt, m_pPlayer, 4 )
    
    // Does this player has gauss?
    if ( g_iHasGauss[ iOwner ] )
    {
        // Reload offset
        static fInReload 
        fInReload = get_pdata_int ( iEnt, m_fInReload,4 )
        
        // Next attack time
        static Float:flNextAttack 
        flNextAttack = get_pdata_float (iOwner, m_flNextAttack, 5 )
        
        // Clip
        static iClip
        iClip = get_pdata_int ( iEnt, m_iClip, 4 )
        
        // Ammo type
        static iAmmoType 
        iAmmoType = m_rgAmmo_player_Slot0 + get_pdata_int ( iEnt, m_iPrimaryAmmoType, 4 )
        
        // BP ammo
        static iBpAmmo
        iBpAmmo = get_pdata_int ( iOwner, iAmmoType, 5 )    
        
        // Reloading
        if ( fInReload && flNextAttack <= 0.0 )
        {
            // Calculate the difference
            static j 
            j = min ( g_pClip - iClip, iBpAmmo )
            
            // Set new clip
            set_pdata_int ( iEnt, m_iClip, iClip + j, 4 )
            
            // Decrease 'x' bullets from backpack(depending on new clip)
            set_pdata_int( iOwner, iAmmoType, iBpAmmo-j, 5 )
            
            // Not reloding anymore
            set_pdata_int ( iEnt, m_fInReload, 0, 4 )
            fInReload = 0
        }
        
        // Get buttons
        static iButton ; iButton = pev ( iOwner, pev_button)
        
        // Attack/Attack2 buttons and next prim/sec attack time hasnt' come yet
        if( ( iButton & IN_ATTACK2 && get_pdata_float ( iEnt, m_flNextSecondaryAttack, 4 ) <= 0.0)
        || ( iButton & IN_ATTACK && get_pdata_float ( iEnt, m_flNextPrimaryAttack, 4 ) <= 0.0) )
        {
            return
        }
    
        // Reload button / not reloading
        if( iButton & IN_RELOAD && !fInReload )
        {
            // Old clip is more/equal than/to new
            if( iClip >= g_pClip )
            {
                // Remove reload button
                set_pev ( iOwner, pev_button, iButton & ~IN_RELOAD )
                
                // Idle animation
                UTIL_PlayWeaponAnimation ( iOwner, gauss_idle )
                
                // Idle time
                g_flWeaponIdleTime[ iOwner ] = get_gametime( ) + 0.5
            }
            else
            {
                // Out of ammo
                if ( !iBpAmmo )
                    return
                    
                // Reload weapon
                UTIL_WeaponReload ( iOwner, iEnt )
            }
        }
    }
}

// Gauss reload post
public fw_TCannonReload_Post( iEnt )
{
    // Get owner
    static Player
    Player = get_pdata_cbase( iEnt, m_pPlayer, 4 )
    
    // Does this player has gauss and is he in a middle of reloading ?
    if ( g_iHasGauss[ Player ] && get_pdata_int( iEnt, m_fInReload, 4 ) )
    {
        // Reload
        UTIL_WeaponReload( Player, iEnt )
    }
}

// ------------------------------- Internal Functions ----------------------------------------

// Gauss start fire
public StartFire( Player )
{
    // This var holds damage
    static Float:flDamage
    
    // Make vectors
    UTIL_MakeVectors( Player )
    
    // Get gametime
    static Float:flGameTime
    flGameTime = get_gametime( )
    
    // This is maximal possible damage from secondary attack!
    if( flGameTime - g_flStartCharge[ Player ] > GAUSS_CHARGETIME )
    {
        flDamage = g_pDmgSec
    }
    else
    {
        // The longer you hold attack button - the bigger is damage
        flDamage = g_pDmgSec * ( ( flGameTime - g_flStartCharge[ Player ] ) / GAUSS_CHARGETIME )
    }
    
    // Primary attack do less damage
    if( g_bPrimaryFire[ Player ] )
    {
        flDamage = g_pDmgPrim
    }
    
    // Make sure that we are not ending attack
    if( g_bInAttack[ Player ] != 3 )
    {
        // Secondary attack can pop you up in the air.Not primary attack!
        if( !g_bPrimaryFire[ Player ] )
        {
            // Current players velocity
            static Float:flVel[ 3 ], Float:v_forward[ 3 ]
            pev( Player, pev_velocity, flVel )
            global_get( glb_v_forward, v_forward )
            
            // Try to affect only vertical velocity
            VectorMS( flVel, flDamage * 5.0, v_forward, flVel )
            
            // Jump!
            set_pev( Player, pev_velocity, flVel )
        }
    }
    
    // Recoil
    static Float:flRecoil[ 3 ]
    flRecoil[ 0 ] = GAUSS_RECOIL
    set_pev( Player, pev_punchangle, flRecoil )
    
    // Fire animation
    UTIL_PlayWeaponAnimation( Player, gauss_fire2 )
    
    // Fire sound
    static Float:flResult
    flResult = 0.5 + flDamage * ( 1.0 / 400.0 )
    
    if( flResult > 1.0 )
    {
        flResult = 1.0
    }
    
    emit_sound( Player, CHAN_WEAPON, g_szSoundGaussFire, flResult, ATTN_NORM, 0, 85 + random_num( 0, 0x1f ) )
    
    // Get players aimpoint position
    static Float:vecDest[ 3 ]
    global_get( glb_v_forward, vecDest )
    
    // Calculate start position
    static Float:vecSrc[ 3 ]
    UTIL_GetGunPosition( Player, vecSrc )
    
    // Time until aftershock 'static discharge' sound
    g_fflPlayAfterShock[ Player ] = flGameTime + random_float( 0.3, 0.8 )
    
    // Fire!
    Fire( Player, vecSrc, vecDest, flDamage )
}

// Fire!
Fire( Player, Float:vecOrigSrc[ ], Float:vecDir[ ], Float:flDamage )
{
    // Start position
    static Float:vecSrc[ 3 ]
    xs_vec_copy( vecOrigSrc, vecSrc )
    
    // Calculate end position
    static Float:vecDest[ 3 ]
    VectorMA( vecSrc, 8192.0, vecDir, vecDest )
    
    // Few trace handles
    static tr, beam_tr
    
    // Max fraction
    static Float:flMaxFrac
    flMaxFrac = 1.0
    
    // Total
    static nTotal
    nTotal = 0
    
    // Does this beam punched the wall ?
    static bool:fHasPunched
    fHasPunched = false
    
    // Does this is first beam
    static bool:fFirstBeam
    fFirstBeam = true
    
    // Max hits
    static nMaxHits
    nMaxHits = 10
    
    // Entity whoch should be ignored
    static pEntToIgnore
    
    // Make sure that beam will'be able to cause damage
    while( flDamage > 10 && nMaxHits > 0 )
    {
        // Decrease hit count
        nMaxHits--
        
        // Draw a trace line
        engfunc( EngFunc_TraceLine, vecSrc, vecDest, DONT_IGNORE_MONSTERS, pEntToIgnore, tr )
        
        // We'll never get outside!
        if( get_tr2( tr, TR_AllSolid ) )
            break
        
        // Get entity which was hit
        static pEntity
        pEntity = Instance( get_tr2( tr, TR_pHit ) )    
        
        // Get vector end position
        static Float:vecEnd[ 3 ]
        get_tr2( tr, TR_vecEndPos, vecEnd )
        
        // Its first beam    
        if( fFirstBeam )
        {
            // Add muzzleflash
            set_pev( Player, pev_effects, pev(Player, pev_effects) | EF_MUZZLEFLASH )
            
            // Its not first anymore
            fFirstBeam = false
            
            // Add
            nTotal += 26
            
            // Draw beam
            engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecSrc, 0 )
            //message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
            write_byte( TE_BEAMENTPOINT ) // Temp. entity ID
            write_short( Player | 0x1000 ) // Start entity
            engfunc( EngFunc_WriteCoord, vecEnd[ 0 ] ) // End position X
            engfunc( EngFunc_WriteCoord, vecEnd[ 1 ] ) // End position Y
            engfunc( EngFunc_WriteCoord, vecEnd[ 2 ] ) // End position Z
            write_short( g_iBeam ) // Sprite index
            write_byte( 0 ) // Start frame
            write_byte( 1 ) // Frame rate
            write_byte( 1 ) // Life
            write_byte( g_bPrimaryFire[ Player ] ? 16 : 25 ) // Line width
            write_byte( 0 ) // Noise amplitude
            write_byte( 255 )
            write_byte( 128 )
            write_byte( 0 )
            write_byte( 255 ) // Alpha
            write_byte( 0 ) // Scroll speed
            message_end( )
        }
        else
        {
            // Draw beam
            engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecSrc, 0 )
            write_byte( TE_BEAMPOINTS ) // Temp. entity ID
            engfunc( EngFunc_WriteCoord, vecSrc[ 0 ] ) // Start position X
            engfunc( EngFunc_WriteCoord, vecSrc[ 1 ] ) // Start position Y
            engfunc( EngFunc_WriteCoord, vecSrc[ 2 ] ) // Start position Z
            engfunc( EngFunc_WriteCoord, vecEnd[ 0 ] ) // End position X
            engfunc( EngFunc_WriteCoord, vecEnd[ 1 ] ) // End position Y
            engfunc( EngFunc_WriteCoord, vecEnd[ 2 ] ) // End position Z
            write_short( g_iBeam ) // Sprite index
            write_byte( 0 ) // Start frame
            write_byte( 1 ) // Frame rate
            write_byte( 1 ) // Life
            write_byte( g_bPrimaryFire[ Player ] ? 15 : 25 ) // Line width
            write_byte( 0 ) // Noise amplitude
            write_byte( 255 )
            write_byte( 128 )
            write_byte( 0 )
            write_byte( 255 )
            write_byte( 0 ) // Scroll speed
            message_end( )
        }
        
        // Check if this entity should take any damage
        if( pev( pEntity, pev_takedamage ) != DAMAGE_NO )
        {
            // Check if this is player and zombie
            if( is_user_valid_connected( pEntity ) && zp_get_user_zombie( pEntity ) )
            {
                // Retrieve health
                static iHealth
                iHealth = get_user_health( pEntity )
            
                // We should be alive
                if( iHealth - flDamage >= 1 )
                {
                    // Cause some damage
                    ExecuteHamB( Ham_TakeDamage, pEntity, 0, Player, flDamage, DMG_BULLET | 

DMG_ALWAYSGIB )
                }
                else
                {
                    // Die
                    g_bKilledByLaser[ pEntity ] = true
                    ExecuteHamB( Ham_Killed, pEntity, Player, 2 )
                    g_bKilledByLaser[ pEntity ] = false
                }
            }
        }
        
        // Check if this entity should reflect our beam
        if( ReflectGauss( pEntity ) )
        {
            static Float:n
            
            // Return normal vector in a spot we hit
            static Float:vecPlaneNormal[ 3 ]
            get_tr2( tr, TR_vecPlaneNormal, vecPlaneNormal )
            
            // Calculate dot product
            n = - xs_vec_dot( vecPlaneNormal, vecDir )
            
            // 60 degrees
            if ( 0 < n < 0.5 )
            {
                static Float:r[ 3 ]
                VectorMA( vecDir, 2.0 * n, vecPlaneNormal, r )
                
                // Get vector end position
                get_tr2( tr, TR_vecEndPos, vecEnd )
                
                // Get trace fraction
                static Float:trflFraction
                get_tr2( tr, TR_flFraction, trflFraction )
                
                // Calculate fraction
                flMaxFrac = flMaxFrac - trflFraction
                
                // Copy vectors
                xs_vec_copy( r, vecDir )
                
                // Make more vector calculations
                VectorMA( vecEnd, 8.0, vecDir, vecSrc )
                VectorMA( vecSrc, 8192.0, vecDir, vecDest )
            
                // Undone!Do radius damage
                
                // Increase
                nTotal += 34
                
                if( n == 0 )
                {
                    // Lose energy
                    n = 0.1
                }
                
                // Calculate new damage
                flDamage = flDamage * ( 1 - n )
            }
            else
            {
                // Add gun shot decal on the world
                FX_GunShotDecal( vecEnd, pEntity )
                
                // Add glowing sprite on the world
                FX_TempSprite( vecEnd, 6, floatround( flDamage / 255.0 ) )
                
                // Increase
                nTotal += 13
                
                // Limit it to one hole punch
                if( fHasPunched )
                    break
                
                // Update    
                fHasPunched = true    
                
                // Try punching through wall if secondary attack (primary is incapable of 
                // breaking through)
                if( !g_bPrimaryFire[ Player ] )
                {
                    // Retrieve vector end position
                    get_tr2( tr, TR_vecEndPos, vecEnd )
                    
                    // Modify start origin
                    static Float:vecStart[ 3 ]
                    VectorMA( vecEnd, 8.0, vecDir, vecStart )
                    
                    // Draw another trace line
                    engfunc( EngFunc_TraceLine, vecSrc, vecDest, DONT_IGNORE_MONSTERS, 

pEntToIgnore, beam_tr )
                    
                    // We'll never get outside
                    if( !get_tr2( beam_tr, TR_AllSolid ) )
                    {
                        // Get end position
                        static Float:vecBeamEndPos[ 3 ]
                        get_tr2( beam_tr, TR_vecEndPos, vecBeamEndPos )
                        
                        // Trace backwards to find exit point
                        engfunc( EngFunc_TraceLine, vecBeamEndPos, vecEnd, 

DONT_IGNORE_MONSTERS, pEntToIgnore, beam_tr )
                        
                        // Again get end position
                        get_tr2( beam_tr, TR_vecEndPos, vecBeamEndPos )
                        
                        static Float:ns, Float:vecSub[ 3 ]
                        
                        // Subtract vectors
                        xs_vec_sub( vecBeamEndPos, vecEnd, vecSub )
                        
                        // Get vector length
                        ns = xs_vec_len( vecSub )
                        
                        if( ns < flDamage )
                        {
                            // Lose enery
                            if( ns == 0 )
                            {
                                ns = 1.0
                            }
                            
                            // Decrease damage
                            flDamage -= ns
                            
                            // Subtract
                            static Float:vecCalc[ 3 ]
                            VectorSubtract( vecEnd, vecDir, vecCalc )
                            
                            // Absorbtion balls
                            FX_SpriteTrail( vecEnd, vecCalc, BALL_AMOUNT, 15, 3, 25, 

25 )
                            
                            // Add gun shot decal on the world
                            FX_GunShotDecal( vecBeamEndPos, pEntity )
                            
                            // And glowing sprite
                            FX_TempSprite( vecBeamEndPos, 6, floatround( flDamage / 

255.0 ) )
                            
                            // Subtract
                            VectorSubtract( vecBeamEndPos, vecDir, vecCalc )
                            
                            // Absorbtion balls
                            FX_SpriteTrail( vecEnd, vecCalc, BALL_AMOUNT, 15, 3, 25, 

25 )
                            
                            // Increase shit
                            nTotal += 21
                            
                            /*
                            // Calculate radius damage
                            static Float:flRadDmg
                            flRadDmg = flDamage * 1.75
                            
                            // Undone.Do radius damage here!
                            floatradius( flDamage, flRadDmg, vecBeamEndPos )
                            */
                            
                            // Increase
                            nTotal += 53
                            
                            VectorMA( vecBeamEndPos, 8.0, vecDir, vecSub )
                            
                            // Add up vector
                            xs_vec_add( vecBeamEndPos, vecDir, vecSrc )
                        }
                    }
                    else
                    {
                        flDamage = 0.0
                    }
                }
                else
                {
                    // Primary attack
                    if( g_bPrimaryFire [ Player ] )
                    {
                        // Slug doesn't punch through ever with primary 
                        // fire, so leave a little glowy bit and make some balls
                        FX_TempSprite( vecEnd, 6, floatround( flDamage / 255.0 ) )
                        FX_SpriteTrail( vecEnd, vecDir, BALL_AMOUNT, 15, 3, 25, 25 )
                    }
                    
                    flDamage = 0.0
                }
            }
        }
        else
        {
            // Add up vector
            xs_vec_add( vecEnd, vecDir, vecSrc )
            pEntToIgnore = pEntity
        }
    }
}                

// Register and cache CVARs
public Load_Cvars( )
{
    cvar_oneround = register_cvar( "zp_tcannon_oneround", "0" )
    cvar_dmgprim = register_cvar( "zp_tcannon_dmgprim", "200" )
    cvar_dmgsec = register_cvar( "zp_tcannon_dmgsec", "500" )
    cvar_clip = register_cvar( "zp_tcannon_clip", "100" )
    
    g_pOneRound = get_pcvar_num( cvar_oneround )
    g_pDmgPrim = get_pcvar_float( cvar_dmgprim )
    g_pDmgSec = get_pcvar_float( cvar_dmgsec )
    g_pClip = get_pcvar_num( cvar_clip )
}

// Gauss weapon idle
WeaponIdle( Player )
{
    // Get gametime
    static Float:flGameTime
    flGameTime = get_gametime( )
    
    if( g_flWeaponIdleTime[ Player ] > flGameTime )
        return
    
    // Animation sequence variable
    static iAnim
    
    // Animation randomizer
    static Float:flRand
    flRand = random_float( 0.1, 1.0 )
    
    if( flRand <= 0.5 )
    {
        iAnim = gauss_idle
        g_flWeaponIdleTime[ Player ] = flGameTime + random_float( 10.0, 15.0 )
    }
    else if( flRand <= 0.75 )
    {
        iAnim = gauss_idle2
        g_flWeaponIdleTime[ Player ] = flGameTime + random_float( 10.0, 15.0 )
    }
    else
    {
        iAnim = gauss_fidget
        g_flWeaponIdleTime[ Player ] = flGameTime + 3
    }
    
    // Idle
    UTIL_PlayWeaponAnimation( Player, iAnim )
}    

// Play weapon animation
UTIL_PlayWeaponAnimation( const Player, const Sequence )
{
    set_pev( Player, pev_weaponanim, Sequence )
    
    message_begin( MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player )
    write_byte( Sequence )
    write_byte( pev( Player, pev_body ) )
    message_end( )
}                

// Make ScreenFade
UTIL_ScreenFade( Player, Duration, HoldTime, Flags, iRed, iGreen, iBlue, iAlpha )
{
    message_begin( MSG_ONE, gmsgScreenFade, _, Player )
    write_short( Duration )
    write_short( HoldTime )
    write_short( Flags )
    write_byte( iRed )
    write_byte( iGreen )
    write_byte( iBlue )
    write_byte( iAlpha )
    message_end( )
}

// Reload gauss
UTIL_WeaponReload( Player, iEnt )
{
    // Modify time until next attack
    set_pdata_float( Player, m_flNextAttack, GAUSS_RELOADTIME+0.5, 5 )
    
    // Reload animation
    UTIL_PlayWeaponAnimation( Player, gauss_spin )
    
    // Enable reload offset
    set_pdata_int( iEnt, m_fInReload, 1, 4 )
    
    // Modify next idle time
    g_flWeaponIdleTime[ Player ] = get_gametime( ) + GAUSS_RELOADTIME + 1.0 
}

// Drop all primary weapons
UTIL_DropPrimary( Player )
{
    // Get user weapons
    static weapons[ 32 ], num, i, weaponid
    num = 0 // reset passed weapons count (bugfix)
    get_user_weapons( Player, weapons, num )
    
    // Loop through them and drop primaries
    for( i = 0; i < num; i++ )
    {
        // Prevent re-indexing the array
        weaponid = weapons[ i ]
        
        // We definetely are holding primary gun
        if(( (1<<weaponid) & PRIMARY_WEAPONS_BITSUM ) )        
        {
            // Get weapon entity
            static wname[32]
            get_weaponname(weaponid, wname, charsmax(wname))
            
            // Player drops the weapon and looses his bpammo
            engclient_cmd( Player, "drop", wname)
        }
    }
}

// Get gun position
UTIL_GetGunPosition( Player, Float:flOrigin[ ] )
{
    static Float:vf_Origin[ 3 ], Float:vf_ViewOfs[ 3 ]
    
    pev( Player, pev_origin, vf_Origin )
    pev( Player, pev_view_ofs, vf_ViewOfs )
    
    xs_vec_add( vf_Origin, vf_ViewOfs, flOrigin )
}

// Make vectors
UTIL_MakeVectors ( Player )
{
    static Float:flAngle[ 3 ], Float:flPunchAngle[ 3 ]

    pev( Player, pev_v_angle, flAngle )
    pev( Player, pev_punchangle, flPunchAngle )

    xs_vec_add( flAngle, flPunchAngle, flAngle )
    engfunc( EngFunc_MakeVectors, flAngle )
}

// From HL SDK.
VectorMA( Float:a[ ], Float:flScale, Float:b[ ], Float:c[ ] )
{
    c[ 0 ] = a[ 0 ] + flScale * b[ 0 ]
    c[ 1 ] = a[ 1 ] + flScale * b[ 1 ]
    c[ 2 ] = a[ 2 ] + flScale * b[ 2 ]
}

VectorMS( const Float:flSource[ ], const Float:flScale, const Float:flMult[ ], Float:flOutput[ ] )
{
        flOutput[ 0 ] = flSource[ 0 ] - flMult[ 0 ] * flScale
        flOutput[ 1 ] = flSource[ 1 ] - flMult[ 1 ] * flScale
        flOutput[ 2 ] = flSource[ 2 ] - flMult[ 2 ] * flScale
}

// Another stuff from HLSDK
Instance( iEnt )
{
    return iEnt == -1 ? 0 : iEnt
}

// Does this entity should refect gauss?
ReflectGauss( iEnt )
{
        return IsBSPModel( iEnt ) && pev( iEnt, pev_takedamage ) == DAMAGE_NO 
}

// Does this entity is BSP model?
IsBSPModel( iEnt )
{
    return pev( iEnt, pev_solid ) == SOLID_BSP || pev( iEnt, pev_movetype ) == MOVETYPE_PUSHSTEP 
}

// Add gun shot decal on world!
FX_GunShotDecal( Float:flPos[ ], pEntity )
{
    // Draw gunshot
    engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flPos, 0 )
    write_byte( TE_GUNSHOTDECAL ) // Temp.entity ID
    engfunc( EngFunc_WriteCoord, flPos[ 0 ] ) // Position X
    engfunc( EngFunc_WriteCoord, flPos[ 1 ] ) // Position Y
    engfunc( EngFunc_WriteCoord, flPos[ 2 ] ) // Position Z
    write_short( pEntity ) // Which entity to mark?
    write_byte( 43 ) // Decal number
    message_end( )
}

// Add glow sprite on world
FX_TempSprite( Float:flPos[ ], iScale, iSize )
{
    engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flPos, 0 )
    write_byte( TE_GLOWSPRITE ) // Temp.entity ID
    engfunc( EngFunc_WriteCoord, flPos[ 0 ] ) // Position X
    engfunc( EngFunc_WriteCoord, flPos[ 1 ] ) // Position Y
    engfunc( EngFunc_WriteCoord, flPos[ 2 ] ) // Position Z
    write_short( g_iBalls ) // Sprite index
    write_byte( iScale ) // Scale
    write_byte( iSize ) // Size
    write_byte( 255 ) // Brightness
    message_end( )
}

// Add sprite trail
FX_SpriteTrail( Float:vecStart[ ], Float:vecDest[ ], iCount, iLife, iScale, iVel, iRnd )
{
    message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
    write_byte( TE_SPRITETRAIL ) // Sprite trail
    engfunc( EngFunc_WriteCoord, vecStart[ 0 ] ) // Position X
    engfunc( EngFunc_WriteCoord, vecStart[ 1 ] ) // Position Y
    engfunc( EngFunc_WriteCoord, vecStart[ 2 ] ) // Position Z
    engfunc( EngFunc_WriteCoord, vecDest[ 0 ] ) // Position X
    engfunc( EngFunc_WriteCoord, vecDest[ 1 ] ) // Position Y
    engfunc( EngFunc_WriteCoord, vecDest[ 2 ] ) // Position Z
    write_short( g_iBalls ) // SPrite index
    write_byte( iCount ) // Amount
    write_byte( iLife ) // Life
    write_byte( iScale ) // Scale
    write_byte( iVel ) // Velocity along vector
    write_byte( iRnd ) // Randomness of velocity
    message_end( )
}
Done
__________________

PaunVictor is offline
Send a message via Yahoo to PaunVictor Send a message via Skype™ to PaunVictor
Johnnynho123
Member
Join Date: Dec 2011
Location: Gradiska, Republic of Sr
Old 02-29-2012 , 07:55   Re: [HELP] Vip extra
#8

Yeah i found it !!
__________________


Forum: www.Adrenaline-Zone.info
Johnnynho123 is offline
Excalibur.007
Veteran Member
Join Date: Sep 2009
Location: Singapore
Old 03-03-2012 , 07:47   Re: [HELP] Vip extra
#9

Assumed solved. Closed for wrong section, not because it's solved.
Excalibur.007 is offline
Closed Thread



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 04:44.


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