AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] edit plugin Medkit Drop (https://forums.alliedmods.net/showthread.php?t=325355)

alferd 06-18-2020 10:05

[HELP] edit plugin Medkit Drop
 
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);
    }



OciXCrom 06-18-2020 14:37

Re: [HELP] edit plugin Medkit Drop
 
Code:
#define AUTHOR "AlferD"

If you're able to write the entire thing as the plugin's author name says, you're able to do a simple thing like giving a weapon to a player.

alferd 06-18-2020 15:58

Re: [HELP] edit plugin Medkit Drop
 
Quote:

Originally Posted by OciXCrom (Post 2706336)
Code:
#define AUTHOR "AlferD"

If you're able to write the entire thing as the plugin's author name says, you're able to do a simple thing like giving a weapon to a player.

:D I just collected the codes

-----------------
Code:
func_healthcharger
I am not familiar with all the codes :/

Natsheh 06-19-2020 05:52

Re: [HELP] edit plugin Medkit Drop
 
oh my familiar piece of code.

:3 author nobody like i never wrote anything.

alferd 06-20-2020 02:37

Re: [HELP] edit plugin Medkit Drop
 
I don't think I can get help from you anymore:grrr:

@Natsheh
Forgive me for my mistake:oops:

Natsheh 06-20-2020 04:27

Re: [HELP] edit plugin Medkit Drop
 
That's not the point what you have literally asked for has nothing to do with the piece of code that you provided.

CrazY. 06-21-2020 08:56

Re: [HELP] edit plugin Medkit Drop
 
Just hook func_healthcharger touch (Ham_Touch), give the ak47 and ammo (give_item , cs_set_user_bpammo) and block the call (return HAM_SUPERCEDE).


All times are GMT -4. The time now is 17:10.

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