Raised This Month: $ Target: $400
 0% 

Subplugin Submission [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 04-09-2012 , 09:50   [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)
Reply With Quote #1

PLEASE USE NEW VERSION http://forums.alliedmods.net/showthread.php?p=1818660
Attached Files
File Type: zip dragon_cannon.zip (859.1 KB, 3042 views)

Last edited by dias; 03-30-2013 at 08:02.
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 04-10-2012 , 10:33   Re: [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)
Reply With Quote #2

Code:
L 04/10/2012 - 22:28:02: [FAKEMETA] Invalid entity
L 04/10/2012 - 22:28:02: [AMXX] Displaying debug trace (plugin "zp_extra_cannon.amxx")
L 04/10/2012 - 22:28:02: [AMXX] Run time error 10: native error (native "pev")
L 04/10/2012 - 22:28:02: [AMXX]    [0] zp_extra_cannon.sma::fw_touch (line 434)
L 04/10/2012 - 22:28:24: [FAKEMETA] Invalid entity
L 04/10/2012 - 22:28:24: [AMXX] Displaying debug trace (plugin "zp_extra_cannon.amxx")
L 04/10/2012 - 22:28:24: [AMXX] Run time error 10: native error (native "pev")
L 04/10/2012 - 22:28:24: [AMXX]    [0] zp_extra_cannon.sma::fw_touch (line 434)
L 04/10/2012 - 22:28:29: [FAKEMETA] Invalid entity
L 04/10/2012 - 22:28:29: [AMXX] Displaying debug trace (plugin "zp_extra_cannon.amxx")
L 04/10/2012 - 22:28:29: [AMXX] Run time error 10: native error (native "pev")
L 04/10/2012 - 22:28:29: [AMXX]    [0] zp_extra_cannon.sma::fw_touch (line 434)
L 04/10/2012 - 22:28:35: [FAKEMETA] Invalid entity
L 04/10/2012 - 22:28:35: [AMXX] Displaying debug trace (plugin "zp_extra_cannon.amxx")
L 04/10/2012 - 22:28:35: [AMXX] Run time error 10: native error (native "pev")
L 04/10/2012 - 22:28:35: [AMXX]    [0] zp_extra_cannon.sma::fw_touch (line 434)
error?
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 04-10-2012 , 10:41   Re: [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)
Reply With Quote #3

Here
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#include <xs>
#include <zombieplague>

#define PLUGIN "[ZP] Extra Item: Cannon"
#define VERSION "1.0"
#define AUTHOR "Dias"

#define CSW_CANNON CSW_M249
#define CANNONFIRE_CLASSNAME "cannon_fire"

new const v_model[] = "models/zombie_plague/v_cannon.mdl"
new const p_model[] = "models/zombie_plague/p_cannon.mdl"
new const w_model[] = "models/zombie_plague/w_cannon.mdl"
new const cannon_sound[2][] = {
    
"weapons/cannon-1.wav"// Fire Sound
    
"weapons/cannon_draw.wav" // Draw Sound
}
new const 
fire_sprite[] = "sprites/fire_cannon.spr"
new g_had_cannon[33], Float:g_last_fire[33], g_reloading[33], g_fired[500][33]
new 
g_item_cannon

new cvar_ammocvar_firedelaycvar_dmgrandom_startcvar_dmgrandom_end

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("CurWeapon""event_curweapon""be""1=1")
    
    
register_forward(FM_UpdateClientData"fw_UpdateClientData_Post"1)
    
register_forward(FM_CmdStart"fw_CmdStart")
    
register_think(CANNONFIRE_CLASSNAME"fw_think")
    
register_forward(FM_Touch"fw_touch")
    
register_forward(FM_SetModel"fw_SetModel")
    
    
RegisterHam(Ham_Item_Deploy"weapon_m249""fw_deploy_post"1)
    
RegisterHam(Ham_Weapon_Reload"weapon_m249""fw_reload")
    
RegisterHam(Ham_Item_AddToPlayer"weapon_m249""fw_item_addtoplayer"1)
    
    
cvar_ammo register_cvar("zp_dcannon_ammo""20")
    
cvar_firedelay register_cvar("zp_firedelay""3.5")
    
cvar_dmgrandom_start register_cvar("zp_dmgrandom_start""300.0")
    
cvar_dmgrandom_end register_cvar("zp_dmgrandom_end""500.0")
    
    
g_item_cannon zp_register_extra_item("Dragon Cannon"30ZP_TEAM_HUMAN)
    
register_clcmd("lastinv""lastinv_cannon")
}

public 
plugin_precache()
{
    
precache_model(v_model)
    
precache_model(p_model)
    
precache_model(w_model)
    
precache_model(fire_sprite)
    
    for(new 
0sizeof(cannon_sound); i++)
        
precache_sound(cannon_sound[i])
}

public 
zp_extra_item_selected(iditemid)
{
    if(
itemid != g_item_cannon)
        return 
PLUGIN_HANDLED
        
    g_had_cannon
[id] = 1
    g_reloading
[id] = 0
    
    give_item
(id"weapon_m249")
    
    static 
ent
    ent 
find_ent_by_owner(-1"weapon_m249"id)    
    
    
cs_set_weapon_ammo(ent0)
    
cs_set_user_bpammo(idCSW_CANNONget_pcvar_num(cvar_ammo))
    
    
play_weapon_anim(id3)
    
    return 
PLUGIN_CONTINUE
}

public 
lastinv_cannon(id)
{
    
set_task(0.01"check_lastinv"id)
}

public 
check_lastinv(id)
{
    if(
is_user_alive(id) && !zp_get_user_zombie(id) && get_user_weapon(id) == CSW_CANNON && g_had_cannon[id])
    {
        
play_weapon_anim(id3)
    }    
}

public 
event_curweapon(id)
{
    if(!
is_user_alive(id) || !is_user_connected(id) || zp_get_user_zombie(id))
        return 
PLUGIN_HANDLED
    
if(get_user_weapon(id) != CSW_CANNON || !g_had_cannon[id])
        return 
PLUGIN_HANDLED
    
    set_pev
(idpev_viewmodel2v_model)
    
set_pev(idpev_weaponmodel2p_model)
    
    return 
PLUGIN_CONTINUE
}

public 
zp_user_infected_post(id)
{
    
g_had_cannon[id] = 0
    g_reloading
[id] = 0    
}

public 
fw_UpdateClientData_Post(idsendweaponscd_handle)
{
    if(!
is_user_alive(id) || !is_user_connected(id) || zp_get_user_zombie(id))
        return 
FMRES_IGNORED
    
    
if(get_user_weapon(id) != CSW_CANNON || !g_had_cannon[id])
        return 
FMRES_IGNORED
    
    set_cd
(cd_handleCD_flNextAttackhalflife_time() + 0.001)  
    
    return 
FMRES_HANDLED
}

public 
fw_CmdStart(iduc_handleseed)
{
    if(!
is_user_alive(id) || !is_user_connected(id) || zp_get_user_zombie(id))
        return 
FMRES_IGNORED
    
    
if(get_user_weapon(id) != CSW_CANNON || !g_had_cannon[id])
        return 
FMRES_IGNORED
    
    
static Button
    Button 
get_uc(uc_handleUC_Buttons)
    
    if(
Button IN_ATTACK)
    {
        if(
cs_get_user_bpammo(idCSW_CANNON) <= 0)
        {            
            return 
FMRES_IGNORED
        
}
        
        static 
Float:CurTime
        CurTime 
get_gametime()
        
        if(
CurTime get_pcvar_float(cvar_firedelay) > g_last_fire[id])
        {
            
play_weapon_anim(idrandom_num(12))
            
emit_sound(idCHAN_WEAPONcannon_sound[0], 1.0ATTN_NORM0PITCH_NORM)
            
            
cs_set_user_bpammo(idCSW_CANNONcs_get_user_bpammo(idCSW_CANNON) - 1)
            
prepare_makefire(id)
            
            
g_last_fire[id] = CurTime
        
}
    }
    
    
// Remove the button
    
Button &= ~IN_ATTACK
    set_uc
(uc_handleUC_ButtonsButton)
    
    
Button &= ~IN_RELOAD
    set_uc
(uc_handleUC_ButtonsButton)
    
    return 
FMRES_HANDLED
}

public 
fw_SetModel(entitymodel[])
{
    if(!
is_valid_ent(entity))
        return 
FMRES_IGNORED;
    
    static 
szClassName[33]
    
entity_get_string(entityEV_SZ_classnameszClassNamecharsmax(szClassName))
    
    if(!
equal(szClassName"weaponbox"))
        return 
FMRES_IGNORED;
    
    static 
iOwner
    iOwner 
entity_get_edict(entityEV_ENT_owner)
    
    if(
equal(model"models/w_m249.mdl"))
    {
        static 
ent
        ent 
find_ent_by_owner(-1"weapon_m249"entity)
        
        if(!
is_valid_ent(ent))
            return 
FMRES_IGNORED;
        
        if(
g_had_cannon[iOwner])
        {
            
entity_set_int(entEV_INT_impulse1028)
            
g_had_cannon[iOwner] = false
            set_pev
(entpev_iuser3cs_get_user_bpammo(iOwnerCSW_CANNON))
            
entity_set_model(entityw_model)
            
            return 
FMRES_SUPERCEDE;
        }
    }
    
    return 
FMRES_IGNORED;
}

public 
fw_item_addtoplayer(entid)
{
    if(!
is_valid_ent(ent))
        return 
HAM_IGNORED
        
    
if(zp_get_user_zombie(id))
        return 
HAM_IGNORED
            
    
if(entity_get_int(entEV_INT_impulse) == 1028)
    {
        
g_had_cannon[id] = true
        cs_set_user_bpammo
(idCSW_CANNONpev(entpev_iuser3))
        
cs_set_weapon_ammo(ent0)
        
        
entity_set_int(idEV_INT_impulse0)
        
        
ExecuteHam(Ham_Item_Deployent)

        return 
HAM_HANDLED
    
}        

    return 
HAM_HANDLED
}

public 
prepare_makefire(id)
{
    static 
Float:VicOrigin[10][3], Float:TempOrigin[3], Float:Angles[3]
    
    
pev(idpev_anglesAngles)
    
fm_get_aim_origin(idTempOrigin)
    
    if((
Angles[1] < 45.0 && Angles[1] > -45.0) || (Angles[1] < -125.0 && Angles[1] < 0) || (Angles[1] > -179.0 && Angles[1] > 100.0))
    {
        
VicOrigin[0][0] = TempOrigin[0]
        
VicOrigin[0][1] = TempOrigin[1]
        
VicOrigin[0][2] = TempOrigin[2]
    
        
VicOrigin[1][0] = TempOrigin[0]
        
VicOrigin[1][1] = TempOrigin[1] + 50.0
        VicOrigin
[1][2] = TempOrigin[2]
    
        
VicOrigin[2][0] = TempOrigin[0]
        
VicOrigin[2][1] = TempOrigin[1] - 50.0
        VicOrigin
[2][2] = TempOrigin[2]    
        
        
VicOrigin[3][0] = TempOrigin[0]
        
VicOrigin[3][1] = TempOrigin[1] + 100.0
        VicOrigin
[3][2] = TempOrigin[2]
    
        
VicOrigin[4][0] = TempOrigin[0]
        
VicOrigin[4][1] = TempOrigin[1] - 100.0
        VicOrigin
[4][2] = TempOrigin[2]        
    
        
VicOrigin[5][0] = TempOrigin[0]
        
VicOrigin[5][1] = TempOrigin[1] + 150.0
        VicOrigin
[5][2] = TempOrigin[2]
    
        
VicOrigin[6][0] = TempOrigin[0]
        
VicOrigin[6][1] = TempOrigin[1] - 150.0
        VicOrigin
[6][2] = TempOrigin[2]    
        
        
VicOrigin[7][0] = TempOrigin[0]
        
VicOrigin[7][1] = TempOrigin[1] + 200.0
        VicOrigin
[7][2] = TempOrigin[2]
    
        
VicOrigin[8][0] = TempOrigin[0]
        
VicOrigin[8][1] = TempOrigin[1] - 250.0
        VicOrigin
[8][2] = TempOrigin[2]        
        
        
VicOrigin[9][0] = TempOrigin[0]
        
VicOrigin[9][1] = TempOrigin[1] - 250.0
        VicOrigin
[9][2] = TempOrigin[2]            
    } else {
        
VicOrigin[0][0] = TempOrigin[0]
        
VicOrigin[0][1] = TempOrigin[1]
        
VicOrigin[0][2] = TempOrigin[2]
    
        
VicOrigin[1][0] = TempOrigin[0] + 50.0
        VicOrigin
[1][1] = TempOrigin[1]
        
VicOrigin[1][2] = TempOrigin[2]
    
        
VicOrigin[2][0] = TempOrigin[0] - 50.0
        VicOrigin
[2][1] = TempOrigin[1]
        
VicOrigin[2][2] = TempOrigin[2]    
        
        
VicOrigin[3][0] = TempOrigin[0] + 100.0
        VicOrigin
[3][1] = TempOrigin[1
        
VicOrigin[3][2] = TempOrigin[2]
    
        
VicOrigin[4][0] = TempOrigin[0] - 100.0
        VicOrigin
[4][1] = TempOrigin[1]
        
VicOrigin[4][2] = TempOrigin[2]        
    
        
VicOrigin[5][0] = TempOrigin[0] + 150.0
        VicOrigin
[5][1] = TempOrigin[1]
        
VicOrigin[5][2] = TempOrigin[2]
    
        
VicOrigin[6][0] = TempOrigin[0] - 150.0
        VicOrigin
[6][1] = TempOrigin[1]
        
VicOrigin[6][2] = TempOrigin[2]    
        
        
VicOrigin[7][0] = TempOrigin[0] + 200.0
        VicOrigin
[7][1] = TempOrigin[1]
        
VicOrigin[7][2] = TempOrigin[2]
    
        
VicOrigin[8][0] = TempOrigin[0] - 250.0
        VicOrigin
[8][1] = TempOrigin[1
        
VicOrigin[8][2] = TempOrigin[2]        
        
        
VicOrigin[9][0] = TempOrigin[0] - 250.0
        VicOrigin
[9][1] = TempOrigin[1]
        
VicOrigin[9][2] = TempOrigin[2]                
    }
    
    for(new 
0sizeof(VicOrigin); i++)
    {
        
make_fire(idVicOrigin[i])
    }
}

public 
make_fire(idFloat:VicOrigin[3])
{
    new 
iEnt create_entity("env_sprite")
    static 
Float:vfVelocity[3], Float:vfAttack[3], Float:vfAngle[3]
    
    
get_weapon_attachment(idvfAttack30.0)
    
pev(idpev_anglesvfAngle)
    
    
// random angle
    
vfAngle[2] = float(random(18) * 20)

    
get_speed_vector(vfAttackVicOrigin1000.0vfVelocity)
    
    
// set info for ent
    
set_pev(iEntpev_movetypeMOVETYPE_FLY)
    
set_pev(iEntpev_rendermodekRenderTransAdd)
    
set_pev(iEntpev_renderamt250.0)
    
set_pev(iEntpev_fuser1get_gametime() + 1.0)    // time remove
    
set_pev(iEntpev_scale2.0)
    
set_pev(iEntpev_nextthinkhalflife_time() + 0.05)
    
    
entity_set_string(iEntEV_SZ_classnameCANNONFIRE_CLASSNAME)
    
engfunc(EngFunc_SetModeliEntfire_sprite)
    
set_pev(iEntpev_minsFloat:{-10.0, -10.0, -5.0})
    
set_pev(iEntpev_maxsFloat:{10.010.010.0})
    
set_pev(iEntpev_originvfAttack)
    
set_pev(iEntpev_gravity0.01)
    
set_pev(iEntpev_velocityvfVelocity)
    
set_pev(iEntpev_anglesvfAngle)
    
set_pev(iEntpev_solid1)
    
set_pev(iEntpev_ownerid)
    
    for(new 
1get_maxplayers(); i++)
    {
        if(
is_user_alive(i))
            
g_fired[iEnt][i] = 0
    
}
}

public 
fw_think(iEnt)
{
    if(!
pev_valid(iEnt)) 
        return
    
    new 
Float:fFrameFloat:fNextThink
    pev
(iEntpev_framefFrame)
    
    
// effect exp
    
new iMoveType pev(iEntpev_movetype)
    if (
iMoveType == MOVETYPE_NONE)
    {
        
fNextThink 0.0015
        fFrame 
+= 1.0
        
        
if (fFrame 21.0)
        {
            
engfunc(EngFunc_RemoveEntityiEnt)
            return
        }
    }
    
    
// effect normal
    
else
    {
        
fNextThink 0.045
        fFrame 
+= 1.0
        fFrame 
floatmin(21.0fFrame)
    }
    
    
set_pev(iEntpev_framefFrame)
    
set_pev(iEntpev_nextthinkhalflife_time() + fNextThink)
    
    
// time remove
    
new Float:fTimeRemove
    pev
(iEntpev_fuser1fTimeRemove)
    if (
get_gametime() >= fTimeRemove)
    {
        
engfunc(EngFunc_RemoveEntityiEnt)
        return;
    }
}

public 
fw_touch(entid)
{
    if(!
pev_valid(ent))
        return 
FMRES_IGNORED
    
if ( pev_valid (ent))
    {
    static 
classname[32], classname2[32]
    
    
pev(entpev_classnameclassnamesizeof(classname))
    
pev(idpev_classnameclassname2sizeof(classname2))
    
    if(!
equal(classnameCANNONFIRE_CLASSNAME) || equal(classname2CANNONFIRE_CLASSNAME) || pev(entpev_owner) == id)
        return 
FMRES_IGNORED
    
    set_pev
(entpev_movetypeMOVETYPE_NONE)
    
set_pev(entpev_solidSOLID_NOT)    
    
    if(!
is_valid_ent(id))
        return 
FMRES_IGNORED
    
    
if(!is_user_alive(id) || !is_user_connected(id))
        return 
FMRES_IGNORED
        
    
if(!zp_get_user_zombie(id))
        return 
FMRES_IGNORED
    
    
if(g_fired[ent][id] == 0)
    {
        
g_fired[ent][id] = 1
        
        
static attacker
        attacker 
pev(entpev_owner)
        
        
ExecuteHam(Ham_TakeDamageid0attackerrandom_float(get_pcvar_float(cvar_dmgrandom_start), get_pcvar_float(cvar_dmgrandom_end)), DMG_BULLET)        
    }
    }
    return 
FMRES_HANDLED
}

public 
fw_reload(ent)
{
    static 
id
    id 
pev(entpev_owner)
    
    if(
is_user_alive(id) && !zp_get_user_zombie(id) && get_user_weapon(id) == CSW_CANNON && g_had_cannon[id])
        return 
HAM_SUPERCEDE
    
    
return HAM_HANDLED
}

public 
fw_deploy_post(ent)
{
    static 
id
    id 
pev(entpev_owner)
    
    
check_lastinv(id)
}

stock play_weapon_anim(playeranim)
{
    
set_pev(playerpev_weaponanimanim)
    
    
message_begin(MSG_ONESVC_WEAPONANIM, {000}, player)
    
write_byte(anim)
    
write_byte(pev(playerpev_body))
    
message_end()
}

stock get_weapon_attachment(idFloat:output[3], Float:fDis 40.0)

    new 
Float:vfEnd[3], viEnd[3
    
get_user_origin(idviEnd3)  
    
IVecFVec(viEndvfEnd
    
    new 
Float:fOrigin[3], Float:fAngle[3]
    
    
pev(idpev_originfOrigin
    
pev(idpev_view_ofsfAngle)
    
    
xs_vec_add(fOriginfAnglefOrigin
    
    new 
Float:fAttack[3]
    
    
xs_vec_sub(vfEndfOriginfAttack)
    
xs_vec_sub(vfEndfOriginfAttack
    
    new 
Float:fRate
    
    fRate 
fDis vector_length(fAttack)
    
xs_vec_mul_scalar(fAttackfRatefAttack)
    
    
xs_vec_add(fOriginfAttackoutput)
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speedFloat:new_velocity[3])
{
    
new_velocity[0] = origin2[0] - origin1[0]
    
new_velocity[1] = origin2[1] - origin1[1]
    
new_velocity[2] = origin2[2] - origin1[2]
    new 
Float:num floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    
new_velocity[0] *= num
    new_velocity
[1] *= num
    new_velocity
[2] *= num
    
    
return 1;
}

//from fakemeta_util.inc
stock fm_get_aim_origin(indexFloat:origin[3])
{
    static 
Float:start[3], Float:view_ofs[3]
    
pev(indexpev_originstart)
    
pev(indexpev_view_ofsview_ofs)
    
xs_vec_add(startview_ofsstart)
    
    static 
Float:dest[3]
    
pev(indexpev_v_angledest)
    
engfunc(EngFunc_MakeVectorsdest)
    
global_get(glb_v_forwarddest)
    
xs_vec_mul_scalar(dest9999.0dest)
    
xs_vec_add(startdestdest)
    
    
engfunc(EngFunc_TraceLinestartdest0index0)
    
get_tr2(0TR_vecEndPosorigin)
    
    return 
1

__________________
H.RED.ZONE is offline
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 04-27-2012 , 21:17   Re: [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)
Reply With Quote #4

Quote:
Originally Posted by H.RED.ZONE View Post
Here
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#include <xs>
#include <zombieplague>

#define PLUGIN "[ZP] Extra Item: Cannon"
#define VERSION "1.0"
#define AUTHOR "Dias"

#define CSW_CANNON CSW_M249
#define CANNONFIRE_CLASSNAME "cannon_fire"

new const v_model[] = "models/zombie_plague/v_cannon.mdl"
new const p_model[] = "models/zombie_plague/p_cannon.mdl"
new const w_model[] = "models/zombie_plague/w_cannon.mdl"
new const cannon_sound[2][] = {
    
"weapons/cannon-1.wav"// Fire Sound
    
"weapons/cannon_draw.wav" // Draw Sound
}
new const 
fire_sprite[] = "sprites/fire_cannon.spr"
new g_had_cannon[33], Float:g_last_fire[33], g_reloading[33], g_fired[500][33]
new 
g_item_cannon

new cvar_ammocvar_firedelaycvar_dmgrandom_startcvar_dmgrandom_end

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("CurWeapon""event_curweapon""be""1=1")
    
    
register_forward(FM_UpdateClientData"fw_UpdateClientData_Post"1)
    
register_forward(FM_CmdStart"fw_CmdStart")
    
register_think(CANNONFIRE_CLASSNAME"fw_think")
    
register_forward(FM_Touch"fw_touch")
    
register_forward(FM_SetModel"fw_SetModel")
    
    
RegisterHam(Ham_Item_Deploy"weapon_m249""fw_deploy_post"1)
    
RegisterHam(Ham_Weapon_Reload"weapon_m249""fw_reload")
    
RegisterHam(Ham_Item_AddToPlayer"weapon_m249""fw_item_addtoplayer"1)
    
    
cvar_ammo register_cvar("zp_dcannon_ammo""20")
    
cvar_firedelay register_cvar("zp_firedelay""3.5")
    
cvar_dmgrandom_start register_cvar("zp_dmgrandom_start""300.0")
    
cvar_dmgrandom_end register_cvar("zp_dmgrandom_end""500.0")
    
    
g_item_cannon zp_register_extra_item("Dragon Cannon"30ZP_TEAM_HUMAN)
    
register_clcmd("lastinv""lastinv_cannon")
}

public 
plugin_precache()
{
    
precache_model(v_model)
    
precache_model(p_model)
    
precache_model(w_model)
    
precache_model(fire_sprite)
    
    for(new 
0sizeof(cannon_sound); i++)
        
precache_sound(cannon_sound[i])
}

public 
zp_extra_item_selected(iditemid)
{
    if(
itemid != g_item_cannon)
        return 
PLUGIN_HANDLED
        
    g_had_cannon
[id] = 1
    g_reloading
[id] = 0
    
    give_item
(id"weapon_m249")
    
    static 
ent
    ent 
find_ent_by_owner(-1"weapon_m249"id)    
    
    
cs_set_weapon_ammo(ent0)
    
cs_set_user_bpammo(idCSW_CANNONget_pcvar_num(cvar_ammo))
    
    
play_weapon_anim(id3)
    
    return 
PLUGIN_CONTINUE
}

public 
lastinv_cannon(id)
{
    
set_task(0.01"check_lastinv"id)
}

public 
check_lastinv(id)
{
    if(
is_user_alive(id) && !zp_get_user_zombie(id) && get_user_weapon(id) == CSW_CANNON && g_had_cannon[id])
    {
        
play_weapon_anim(id3)
    }    
}

public 
event_curweapon(id)
{
    if(!
is_user_alive(id) || !is_user_connected(id) || zp_get_user_zombie(id))
        return 
PLUGIN_HANDLED
    
if(get_user_weapon(id) != CSW_CANNON || !g_had_cannon[id])
        return 
PLUGIN_HANDLED
    
    set_pev
(idpev_viewmodel2v_model)
    
set_pev(idpev_weaponmodel2p_model)
    
    return 
PLUGIN_CONTINUE
}

public 
zp_user_infected_post(id)
{
    
g_had_cannon[id] = 0
    g_reloading
[id] = 0    
}

public 
fw_UpdateClientData_Post(idsendweaponscd_handle)
{
    if(!
is_user_alive(id) || !is_user_connected(id) || zp_get_user_zombie(id))
        return 
FMRES_IGNORED
    
    
if(get_user_weapon(id) != CSW_CANNON || !g_had_cannon[id])
        return 
FMRES_IGNORED
    
    set_cd
(cd_handleCD_flNextAttackhalflife_time() + 0.001)  
    
    return 
FMRES_HANDLED
}

public 
fw_CmdStart(iduc_handleseed)
{
    if(!
is_user_alive(id) || !is_user_connected(id) || zp_get_user_zombie(id))
        return 
FMRES_IGNORED
    
    
if(get_user_weapon(id) != CSW_CANNON || !g_had_cannon[id])
        return 
FMRES_IGNORED
    
    
static Button
    Button 
get_uc(uc_handleUC_Buttons)
    
    if(
Button IN_ATTACK)
    {
        if(
cs_get_user_bpammo(idCSW_CANNON) <= 0)
        {            
            return 
FMRES_IGNORED
        
}
        
        static 
Float:CurTime
        CurTime 
get_gametime()
        
        if(
CurTime get_pcvar_float(cvar_firedelay) > g_last_fire[id])
        {
            
play_weapon_anim(idrandom_num(12))
            
emit_sound(idCHAN_WEAPONcannon_sound[0], 1.0ATTN_NORM0PITCH_NORM)
            
            
cs_set_user_bpammo(idCSW_CANNONcs_get_user_bpammo(idCSW_CANNON) - 1)
            
prepare_makefire(id)
            
            
g_last_fire[id] = CurTime
        
}
    }
    
    
// Remove the button
    
Button &= ~IN_ATTACK
    set_uc
(uc_handleUC_ButtonsButton)
    
    
Button &= ~IN_RELOAD
    set_uc
(uc_handleUC_ButtonsButton)
    
    return 
FMRES_HANDLED
}

public 
fw_SetModel(entitymodel[])
{
    if(!
is_valid_ent(entity))
        return 
FMRES_IGNORED;
    
    static 
szClassName[33]
    
entity_get_string(entityEV_SZ_classnameszClassNamecharsmax(szClassName))
    
    if(!
equal(szClassName"weaponbox"))
        return 
FMRES_IGNORED;
    
    static 
iOwner
    iOwner 
entity_get_edict(entityEV_ENT_owner)
    
    if(
equal(model"models/w_m249.mdl"))
    {
        static 
ent
        ent 
find_ent_by_owner(-1"weapon_m249"entity)
        
        if(!
is_valid_ent(ent))
            return 
FMRES_IGNORED;
        
        if(
g_had_cannon[iOwner])
        {
            
entity_set_int(entEV_INT_impulse1028)
            
g_had_cannon[iOwner] = false
            set_pev
(entpev_iuser3cs_get_user_bpammo(iOwnerCSW_CANNON))
            
entity_set_model(entityw_model)
            
            return 
FMRES_SUPERCEDE;
        }
    }
    
    return 
FMRES_IGNORED;
}

public 
fw_item_addtoplayer(entid)
{
    if(!
is_valid_ent(ent))
        return 
HAM_IGNORED
        
    
if(zp_get_user_zombie(id))
        return 
HAM_IGNORED
            
    
if(entity_get_int(entEV_INT_impulse) == 1028)
    {
        
g_had_cannon[id] = true
        cs_set_user_bpammo
(idCSW_CANNONpev(entpev_iuser3))
        
cs_set_weapon_ammo(ent0)
        
        
entity_set_int(idEV_INT_impulse0)
        
        
ExecuteHam(Ham_Item_Deployent)

        return 
HAM_HANDLED
    
}        

    return 
HAM_HANDLED
}

public 
prepare_makefire(id)
{
    static 
Float:VicOrigin[10][3], Float:TempOrigin[3], Float:Angles[3]
    
    
pev(idpev_anglesAngles)
    
fm_get_aim_origin(idTempOrigin)
    
    if((
Angles[1] < 45.0 && Angles[1] > -45.0) || (Angles[1] < -125.0 && Angles[1] < 0) || (Angles[1] > -179.0 && Angles[1] > 100.0))
    {
        
VicOrigin[0][0] = TempOrigin[0]
        
VicOrigin[0][1] = TempOrigin[1]
        
VicOrigin[0][2] = TempOrigin[2]
    
        
VicOrigin[1][0] = TempOrigin[0]
        
VicOrigin[1][1] = TempOrigin[1] + 50.0
        VicOrigin
[1][2] = TempOrigin[2]
    
        
VicOrigin[2][0] = TempOrigin[0]
        
VicOrigin[2][1] = TempOrigin[1] - 50.0
        VicOrigin
[2][2] = TempOrigin[2]    
        
        
VicOrigin[3][0] = TempOrigin[0]
        
VicOrigin[3][1] = TempOrigin[1] + 100.0
        VicOrigin
[3][2] = TempOrigin[2]
    
        
VicOrigin[4][0] = TempOrigin[0]
        
VicOrigin[4][1] = TempOrigin[1] - 100.0
        VicOrigin
[4][2] = TempOrigin[2]        
    
        
VicOrigin[5][0] = TempOrigin[0]
        
VicOrigin[5][1] = TempOrigin[1] + 150.0
        VicOrigin
[5][2] = TempOrigin[2]
    
        
VicOrigin[6][0] = TempOrigin[0]
        
VicOrigin[6][1] = TempOrigin[1] - 150.0
        VicOrigin
[6][2] = TempOrigin[2]    
        
        
VicOrigin[7][0] = TempOrigin[0]
        
VicOrigin[7][1] = TempOrigin[1] + 200.0
        VicOrigin
[7][2] = TempOrigin[2]
    
        
VicOrigin[8][0] = TempOrigin[0]
        
VicOrigin[8][1] = TempOrigin[1] - 250.0
        VicOrigin
[8][2] = TempOrigin[2]        
        
        
VicOrigin[9][0] = TempOrigin[0]
        
VicOrigin[9][1] = TempOrigin[1] - 250.0
        VicOrigin
[9][2] = TempOrigin[2]            
    } else {
        
VicOrigin[0][0] = TempOrigin[0]
        
VicOrigin[0][1] = TempOrigin[1]
        
VicOrigin[0][2] = TempOrigin[2]
    
        
VicOrigin[1][0] = TempOrigin[0] + 50.0
        VicOrigin
[1][1] = TempOrigin[1]
        
VicOrigin[1][2] = TempOrigin[2]
    
        
VicOrigin[2][0] = TempOrigin[0] - 50.0
        VicOrigin
[2][1] = TempOrigin[1]
        
VicOrigin[2][2] = TempOrigin[2]    
        
        
VicOrigin[3][0] = TempOrigin[0] + 100.0
        VicOrigin
[3][1] = TempOrigin[1
        
VicOrigin[3][2] = TempOrigin[2]
    
        
VicOrigin[4][0] = TempOrigin[0] - 100.0
        VicOrigin
[4][1] = TempOrigin[1]
        
VicOrigin[4][2] = TempOrigin[2]        
    
        
VicOrigin[5][0] = TempOrigin[0] + 150.0
        VicOrigin
[5][1] = TempOrigin[1]
        
VicOrigin[5][2] = TempOrigin[2]
    
        
VicOrigin[6][0] = TempOrigin[0] - 150.0
        VicOrigin
[6][1] = TempOrigin[1]
        
VicOrigin[6][2] = TempOrigin[2]    
        
        
VicOrigin[7][0] = TempOrigin[0] + 200.0
        VicOrigin
[7][1] = TempOrigin[1]
        
VicOrigin[7][2] = TempOrigin[2]
    
        
VicOrigin[8][0] = TempOrigin[0] - 250.0
        VicOrigin
[8][1] = TempOrigin[1
        
VicOrigin[8][2] = TempOrigin[2]        
        
        
VicOrigin[9][0] = TempOrigin[0] - 250.0
        VicOrigin
[9][1] = TempOrigin[1]
        
VicOrigin[9][2] = TempOrigin[2]                
    }
    
    for(new 
0sizeof(VicOrigin); i++)
    {
        
make_fire(idVicOrigin[i])
    }
}

public 
make_fire(idFloat:VicOrigin[3])
{
    new 
iEnt create_entity("env_sprite")
    static 
Float:vfVelocity[3], Float:vfAttack[3], Float:vfAngle[3]
    
    
get_weapon_attachment(idvfAttack30.0)
    
pev(idpev_anglesvfAngle)
    
    
// random angle
    
vfAngle[2] = float(random(18) * 20)

    
get_speed_vector(vfAttackVicOrigin1000.0vfVelocity)
    
    
// set info for ent
    
set_pev(iEntpev_movetypeMOVETYPE_FLY)
    
set_pev(iEntpev_rendermodekRenderTransAdd)
    
set_pev(iEntpev_renderamt250.0)
    
set_pev(iEntpev_fuser1get_gametime() + 1.0)    // time remove
    
set_pev(iEntpev_scale2.0)
    
set_pev(iEntpev_nextthinkhalflife_time() + 0.05)
    
    
entity_set_string(iEntEV_SZ_classnameCANNONFIRE_CLASSNAME)
    
engfunc(EngFunc_SetModeliEntfire_sprite)
    
set_pev(iEntpev_minsFloat:{-10.0, -10.0, -5.0})
    
set_pev(iEntpev_maxsFloat:{10.010.010.0})
    
set_pev(iEntpev_originvfAttack)
    
set_pev(iEntpev_gravity0.01)
    
set_pev(iEntpev_velocityvfVelocity)
    
set_pev(iEntpev_anglesvfAngle)
    
set_pev(iEntpev_solid1)
    
set_pev(iEntpev_ownerid)
    
    for(new 
1get_maxplayers(); i++)
    {
        if(
is_user_alive(i))
            
g_fired[iEnt][i] = 0
    
}
}

public 
fw_think(iEnt)
{
    if(!
pev_valid(iEnt)) 
        return
    
    new 
Float:fFrameFloat:fNextThink
    pev
(iEntpev_framefFrame)
    
    
// effect exp
    
new iMoveType pev(iEntpev_movetype)
    if (
iMoveType == MOVETYPE_NONE)
    {
        
fNextThink 0.0015
        fFrame 
+= 1.0
        
        
if (fFrame 21.0)
        {
            
engfunc(EngFunc_RemoveEntityiEnt)
            return
        }
    }
    
    
// effect normal
    
else
    {
        
fNextThink 0.045
        fFrame 
+= 1.0
        fFrame 
floatmin(21.0fFrame)
    }
    
    
set_pev(iEntpev_framefFrame)
    
set_pev(iEntpev_nextthinkhalflife_time() + fNextThink)
    
    
// time remove
    
new Float:fTimeRemove
    pev
(iEntpev_fuser1fTimeRemove)
    if (
get_gametime() >= fTimeRemove)
    {
        
engfunc(EngFunc_RemoveEntityiEnt)
        return;
    }
}

public 
fw_touch(entid)
{
    if(!
pev_valid(ent))
        return 
FMRES_IGNORED
    
if ( pev_valid (ent))
    {
    static 
classname[32], classname2[32]
    
    
pev(entpev_classnameclassnamesizeof(classname))
    
pev(idpev_classnameclassname2sizeof(classname2))
    
    if(!
equal(classnameCANNONFIRE_CLASSNAME) || equal(classname2CANNONFIRE_CLASSNAME) || pev(entpev_owner) == id)
        return 
FMRES_IGNORED
    
    set_pev
(entpev_movetypeMOVETYPE_NONE)
    
set_pev(entpev_solidSOLID_NOT)    
    
    if(!
is_valid_ent(id))
        return 
FMRES_IGNORED
    
    
if(!is_user_alive(id) || !is_user_connected(id))
        return 
FMRES_IGNORED
        
    
if(!zp_get_user_zombie(id))
        return 
FMRES_IGNORED
    
    
if(g_fired[ent][id] == 0)
    {
        
g_fired[ent][id] = 1
        
        
static attacker
        attacker 
pev(entpev_owner)
        
        
ExecuteHam(Ham_TakeDamageid0attackerrandom_float(get_pcvar_float(cvar_dmgrandom_start), get_pcvar_float(cvar_dmgrandom_end)), DMG_BULLET)        
    }
    }
    return 
FMRES_HANDLED
}

public 
fw_reload(ent)
{
    static 
id
    id 
pev(entpev_owner)
    
    if(
is_user_alive(id) && !zp_get_user_zombie(id) && get_user_weapon(id) == CSW_CANNON && g_had_cannon[id])
        return 
HAM_SUPERCEDE
    
    
return HAM_HANDLED
}

public 
fw_deploy_post(ent)
{
    static 
id
    id 
pev(entpev_owner)
    
    
check_lastinv(id)
}

stock play_weapon_anim(playeranim)
{
    
set_pev(playerpev_weaponanimanim)
    
    
message_begin(MSG_ONESVC_WEAPONANIM, {000}, player)
    
write_byte(anim)
    
write_byte(pev(playerpev_body))
    
message_end()
}

stock get_weapon_attachment(idFloat:output[3], Float:fDis 40.0)

    new 
Float:vfEnd[3], viEnd[3
    
get_user_origin(idviEnd3)  
    
IVecFVec(viEndvfEnd
    
    new 
Float:fOrigin[3], Float:fAngle[3]
    
    
pev(idpev_originfOrigin
    
pev(idpev_view_ofsfAngle)
    
    
xs_vec_add(fOriginfAnglefOrigin
    
    new 
Float:fAttack[3]
    
    
xs_vec_sub(vfEndfOriginfAttack)
    
xs_vec_sub(vfEndfOriginfAttack
    
    new 
Float:fRate
    
    fRate 
fDis vector_length(fAttack)
    
xs_vec_mul_scalar(fAttackfRatefAttack)
    
    
xs_vec_add(fOriginfAttackoutput)
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speedFloat:new_velocity[3])
{
    
new_velocity[0] = origin2[0] - origin1[0]
    
new_velocity[1] = origin2[1] - origin1[1]
    
new_velocity[2] = origin2[2] - origin1[2]
    new 
Float:num floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    
new_velocity[0] *= num
    new_velocity
[1] *= num
    new_velocity
[2] *= num
    
    
return 1;
}

//from fakemeta_util.inc
stock fm_get_aim_origin(indexFloat:origin[3])
{
    static 
Float:start[3], Float:view_ofs[3]
    
pev(indexpev_originstart)
    
pev(indexpev_view_ofsview_ofs)
    
xs_vec_add(startview_ofsstart)
    
    static 
Float:dest[3]
    
pev(indexpev_v_angledest)
    
engfunc(EngFunc_MakeVectorsdest)
    
global_get(glb_v_forwarddest)
    
xs_vec_mul_scalar(dest9999.0dest)
    
xs_vec_add(startdestdest)
    
    
engfunc(EngFunc_TraceLinestartdest0index0)
    
get_tr2(0TR_vecEndPosorigin)
    
    return 
1

Sorry for reviving.
But can I know what is the problem that you fix?
Thanks. * Got this error on other plugin -.- *
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 04-11-2012 , 06:04   Re: [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)
Reply With Quote #5

Thank for fix. I update your post to first post
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 04-11-2012 , 06:52   Re: [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)
Reply With Quote #6

Hello dias leon,
I've taken some code from this plugin and take the clip code. At the first I use the code for SG550 which I've changed it to 60 clip, it's going well but after I reload it will become as the default clip. Could you help me please?
*sorry run off from the topic*
** I will show you the code if you want**
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
tei1995
Senior Member
Join Date: Feb 2011
Location: VietNam
Old 04-11-2012 , 08:59   Re: [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)
Reply With Quote #7

Use ham_item_postframe to edit clip after reload.
__________________

Hatsune Miku~
tei1995 is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 04-11-2012 , 17:10   Re: [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)
Reply With Quote #8

What's the point to check:
PHP Code:
if(!is_user_alive(id) || !is_user_connected(id)) 
together?

Just use 1 native "is_user_alive(index)" is enough. It already check client is connected.

In touch forward you already check entity is valid, so why need to recheck again?

Use bit is faster than calling the same natives.

I would not recommended to use this plugin on HLDS. Code are horrible, your idea is good but you need to learn to optimize your code first.
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
tei1995
Senior Member
Join Date: Feb 2011
Location: VietNam
Old 04-11-2012 , 21:08   Re: [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)
Reply With Quote #9

Is that right?
__________________

Hatsune Miku~
tei1995 is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 04-11-2012 , 22:08   Re: [ZP] Extra Item: Dragon Cannon (11/2/2012 | Author: Dias)
Reply With Quote #10

Quote:
Originally Posted by tei1995 View Post
Is that right?
He just double checked everything.
Code should be changed a bit.
__________________
H.RED.ZONE is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:57.


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