Junior Member
|
12-18-2022
, 23:56
Re: Med-Shot or Healthshot
|
#3
|
Quote:
Originally Posted by administratora
Hi, I think no but I will give you an example:
PHP Code:
#include <amxmodx> #include <cstrike> #include <fun>
new g_killCount[33]; // Array to store the kill count for each player
public plugin_init() { register_plugin("Syringe After Three Kills", "1.0", "Your Name");
// Register the "death" event to track player kills register_event("death", "Death", "a"); }
public Death(id) { // Increment the player's kill count g_killCount[id]++;
// Check if the player has made three kills if (g_killCount[id] == 3) { // Give the player a syringe give_item(id, "item_kevlar");
// Reset the player's kill count g_killCount[id] = 0; } }
You can modify the number of kills (from the code) required to earn a syringe, as well as the item that is given to the player (in this example, it is a Kevlar vest, which can be used as a makeshift syringe)
|
PHP Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> #include <fun>
#pragma semicolon 1
//Настройки #define HEAL 25.0 // Amount of health to be restored #define MAXHEALTH 100.0 //Health threshold #define VIP_AMMO 2 //Number of syringes for VIP #define PLR_AMMO 1 //Number of syringes for a normal player #define FLAG ADMIN_LEVEL_H // VIP flag
#define ANIM_USE 0 #define OLD_KN_DRAW 3 #define TIME_ANIM_HEAL 2.0 #define TIME_DRAW_KNF 1.1
#define TASK_HEAL 25071973
#define is_valid_player(%0) (1 <= %0 <= g_maxplayers) const m_flNextAttack = 83;
new const v_injectorX[] = "models/v_injectorX.mdl"; // v_ syringe model new const p_injectorX[] = "models/p_injectorX.mdl"; // p_ syringe model
new const v_old_knife[] = "models/v_knife.mdl"; // v_ knife model that is returned after use new const p_old_knife[] = "models/p_knife.mdl"; // p_ knife model that is returned after use // If there are several knife models, then return the model through the native!
new const heal_sound[] = { "items/medshot4.wav" }; // Heal sound
new shpr_ammo[33]; new g_maxplayers; public plugin_init() { register_plugin("Injector X & Syringe After Three kills", "1.0", "Alliedmods"); register_clcmd("drop", "use_inj"); RegisterHam(Ham_Spawn, "player", "ham_spawn_post", 1); RegisterHam(Ham_Item_Holster, "weapon_knife", "fw_Knife_Holstered", 1);
g_maxplayers = get_maxplayers(); }
public plugin_precache() { precache_model(v_injectorX); precache_model(p_injectorX); precache_model(v_old_knife); precache_model(p_old_knife); precache_sound(heal_sound);
}
public ham_spawn_post(id) { if(get_user_flags(id) & FLAG) shpr_ammo[id] = VIP_AMMO; else shpr_ammo[id] = PLR_AMMO; }
public use_inj(id) { if(!is_user_alive(id)) return;
if(get_user_weapon(id) != CSW_KNIFE || !shpr_ammo[id]) return; remove_task(id+TASK_HEAL); set_pdata_float(id, m_flNextAttack, TIME_ANIM_HEAL+0.1, 5);
set_pev(id, pev_viewmodel2, v_injectorX); set_pev(id, pev_weaponmodel2, p_injectorX);
play_weapon_animation(id, ANIM_USE); set_task(TIME_ANIM_HEAL, "use_inj2", id+TASK_HEAL); }
public use_inj2(id) { id -= TASK_HEAL;
if(is_user_alive(id)) { shpr_ammo[id]--; set_pev(id, pev_viewmodel2, v_old_knife); set_pev(id, pev_weaponmodel2, p_old_knife); set_pdata_float(id, m_flNextAttack, TIME_DRAW_KNF, 5); play_weapon_animation(id, OLD_KN_DRAW); set_hp(id); } }
public fw_Knife_Holstered(weapon) { new id = get_pdata_cbase(weapon, 41, 4); if(!pev_valid(weapon)) return HAM_IGNORED;
if(is_valid_player(id)) remove_task(id+TASK_HEAL); return HAM_IGNORED;
}
stock set_hp(plr) { new hp = pev(plr, pev_health);
if(hp < MAXHEALTH) { if(hp + HEAL > MAXHEALTH) set_pev(plr, pev_health, MAXHEALTH); else set_pev(plr, pev_health, hp + HEAL); emit_sound(plr, CHAN_BODY, heal_sound, 1.0, ATTN_NORM, 0, PITCH_NORM); } }
stock play_weapon_animation(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(); }
there is such a plugin how to change and add your code, and hud message (you got a syringe for three kills
to use take a knife and press G ) after three kills you got a syringe
Last edited by Ismaylwo; 12-19-2022 at 00:47.
|
|