Raised This Month: $ Target: $400
 0% 

[HELP] edit plugin Medkit Drop


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 06-18-2020 , 10:05   [HELP] edit plugin Medkit Drop
Reply With Quote #1

I want this plugin to give the player the ak47 and ammo instead of health

Code:
give health - To - give ak47+ammo
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>
#include <fakemeta>
#include <xs>
#include <cs_player_models_api>

#define PLUGIN "Medkit Drop"
#define VERSION "1.0"
#define AUTHOR "nobody"

new const g_medkit_name[] = "Medkit";

new 
g_medkitsHamHook:FW_TRACEATTACK_FUNC_HC_POSTHamHook:FW_KILLED_FUNC_HC_POSTmedkit_gibs_mdl_index;

new 
MEDKIT_BREAK_SND[64] = "debris/metal5.wav"MEDKIT_W_MDL[64] = "models/w_medkit.mdl"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /seet""drop_medkit")
}

public 
plugin_precache()
{
    
precache_model(MEDKIT_W_MDL)
    
precache_sound(MEDKIT_BREAK_SND)
    
precache_sound("items/medshot4.wav")
    
precache_sound("items/medshotno1.wav")
    
precache_sound("items/medcharge4.wav")
}

public 
drop_medkit(id)
{
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"func_healthcharger"));
    
    if(!
ent) return;
    
    new 
Float:fOrigin[3], Float:fOrigin2[3], Float:fVelocity[3];
    
velocity_by_aim(id250fVelocity)
    
pev(idpev_originfOrigin)
    
pev(idpev_view_ofsfOrigin2)
    
xs_vec_add(fOriginfOrigin2fOrigin)
    
    
engfunc(EngFunc_SetOriginentfOrigin);
    
engfunc(EngFunc_SetModelentMEDKIT_W_MDL);
    
//set_pev(ent, pev_spawnflags, SF_NORESPAWN);
    
dllfunc(DLLFunc_Spawnent);
    
engfunc(EngFunc_SetSizeentFloat:{-5.0,-5.0,-5.0}, Float:{5.0,5.0,5.0});
    
set_pev(entpev_velocityfVelocity);
    
fVelocity[0] = 0.0fVelocity[2] = 0.0fVelocity[1] = !random(1) ? -360.0:360.0;
    
set_pev(entpev_avelocityfVelocity);
    
set_pev(entpev_friction1.4);
    
set_pev(entpev_globalnameg_medkit_name);
    
set_pev(entpev_ownerid);
    
set_pev(entpev_takedamageDAMAGE_YES);
    
set_pev(entpev_health100.0);
    
set_pev(entpev_dmg_take25.0)
    
set_pev(entpev_solidSOLID_BBOX);
    
set_pev(entpev_movetypeMOVETYPE_BOUNCE);
    
    if(
g_medkits == 1)
    {
        if(!
FW_TRACEATTACK_FUNC_HC_POST)
        {
            
DisableHamForward(FW_TRACEATTACK_FUNC_HC_POST RegisterHam(Ham_TraceAttack"func_healthcharger""fw_tattack_func_hc_post"1));
            
DisableHamForward(FW_KILLED_FUNC_HC_POST RegisterHam(Ham_Killed"func_healthcharger""fw_killed_func_hg_pre"));
        }
        
        
EnableHamForward(FW_TRACEATTACK_FUNC_HC_POST);
        
EnableHamForward(FW_KILLED_FUNC_HC_POST);
    }
    
    
set_task(1.2"reset_velocity"ent);
}

public 
fw_killed_func_hg_pre(victimattackershouldgib)
{
    new 
sTargetname[16];
    
pev(victimpev_globalnamesTargetnamecharsmax(sTargetname))
    
    if(!
equal(sTargetnameg_medkit_name)) return HAM_IGNORED;
    
    new 
Float:fOrigin[3];
    
pev(victimpev_originfOrigin)
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(TE_BREAKMODEL);
    
engfunc(EngFunc_WriteCoordfOrigin[0]);
    
engfunc(EngFunc_WriteCoordfOrigin[1]);
    
engfunc(EngFunc_WriteCoordfOrigin[2] + 25.0);
    
write_coord(16); // size x 
    
write_coord(16); // size y 
    
write_coord(16); // size z 
    
write_coord(random_num(-50,50)); // velocity x 
    
write_coord(random_num(-50,50)); // velocity y 
    
write_coord(25); // velocity z 
    
write_byte(10); // random velocity 
    
write_short(medkit_gibs_mdl_index); // model index that you want to break 
    
write_byte(10); // count 
    
write_byte(25); // life 
    
write_byte(0x02); // flags
    
message_end();
    
    
emit_sound(victimCHAN_BODYMEDKIT_BREAK_SNDVOL_NORMATTN_NORM0PITCH_HIGH);

    
set_pev(victimpev_flagsFL_KILLME);
    
dllfunc(DLLFunc_Thinkvictim);
    
    return 
HAM_IGNORED;
}

public 
fw_tattack_func_hc_post(entattackerFloat:damageFloat:direction[3], traceresultdamagebits)
{
    static 
sTargetname[16];
    
pev(entpev_globalnamesTargetnamecharsmax(sTargetname))
    
    if(!
equal(sTargetnameg_medkit_name)) return HAM_IGNORED;
    
    if(
pev(entpev_takedamage) == DAMAGE_YES)
    {
        static 
Float:fEnd[3];
        
get_tr2(traceresultTR_vecEndPosfEnd)
        
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
        
write_byte(TE_GUNSHOT);
        
engfunc(EngFunc_WriteCoordfEnd[0]);
        
engfunc(EngFunc_WriteCoordfEnd[1]);
        
engfunc(EngFunc_WriteCoordfEnd[2]);
        
message_end();
        
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
        
write_byte(TE_SPARKS);
        
engfunc(EngFunc_WriteCoordfEnd[0]);
        
engfunc(EngFunc_WriteCoordfEnd[1]);
        
engfunc(EngFunc_WriteCoordfEnd[2]);
        
message_end();
    }
    
    return 
HAM_IGNORED;
}

public 
reset_velocity(ent)
{
    if(
pev_valid(ent))
    {
        
set_pev(entpev_velocityFloat:{0.0,0.0,0.0});
        
set_pev(entpev_avelocityFloat:{0.0,0.0,0.0});
        
set_pev(entpev_owner33);
    }


Last edited by alferd; 06-18-2020 at 15:59.
alferd is offline
 



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


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