Knife Menu

Unpaid Requests, Public Plugins
Post Reply
Mystic Viper
Member
Member
Romania
Posts: 87
Joined: 9 Months Ago
Has thanked: 1 time
Been thanked: 3 times
Contact:

Knife Menu

#1

Post by Mystic Viper » 8 Months Ago

Can someone put this knife in Knife menu? viewtopic.php?f=14&t=3396

Knife Menu: viewtopic.php?f=15&t=88

User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 576
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 47 times
Age: 19
Contact:

#2

Post by Jack GamePlay » 6 Months Ago

Knife menu:

Code: Select all

#include <zombie_escape>

native ze_get_tactical(id)
native ze_remove_tactical(id)
 
// Models
new const Compat_Models[][] =
{
	"models/zombie_escape/v_combat_knife.mdl",
	"models/zombie_escape/p_combat_knife.mdl"
}

new const Strong_Models[][] =
{
	"models/zombie_escape/v_strong_knife.mdl",
	"models/zombie_escape/p_strong_knife.mdl"
}

new const Katana_Models[][] =
{
	"models/zombie_escape/v_katana_knife.mdl",
	"models/zombie_escape/p_katana_knife.mdl"
}

new const Hammer_Models[][] =
{
	"models/zombie_escape/v_hammer_knife.mdl",
	"models/zombie_escape/p_hammer_knife.mdl" 
}

// Sounds
new const g_sound_knife[] = "items/gunpickup2.wav"

new const combat_sounds[][] =
{
	"zombie_escape/knife_menu/combat_deploy.wav",
	"zombie_escape/knife_menu/combat_hit.wav",
	"zombie_escape/knife_menu/combat_hit.wav",
	"zombie_escape/knife_menu/combat_hit.wav",
	"zombie_escape/knife_menu/combat_hit.wav",
	"zombie_escape/knife_menu/combat_hitwall.wav",
	"zombie_escape/knife_menu/combat_slash.wav",
	"zombie_escape/knife_menu/combat_slash.wav",
	"zombie_escape/knife_menu/combat_stab.wav"
}

new const strong_sounds[][] =
{
	"zombie_escape/knife_menu/strong_deploy.wav",
	"zombie_escape/knife_menu/strong_hit.wav",
	"zombie_escape/knife_menu/strong_hit.wav",
	"zombie_escape/knife_menu/strong_hit.wav",
	"zombie_escape/knife_menu/strong_hit.wav",
	"zombie_escape/knife_menu/strong_hitwall.wav",
	"zombie_escape/knife_menu/strong_slash.wav",
	"zombie_escape/knife_menu/strong_slash.wav",
	"zombie_escape/knife_menu/strong_stab.wav"
}

new const katana_sounds[][] =
{
	"zombie_escape/knife_menu/katana_deploy.wav",
	"zombie_escape/knife_menu/katana_hit.wav",
	"zombie_escape/knife_menu/katana_hit.wav",
	"zombie_escape/knife_menu/katana_hit.wav",
	"zombie_escape/knife_menu/katana_hit.wav",
	"zombie_escape/knife_menu/katana_hitwall.wav",
	"zombie_escape/knife_menu/katana_slash.wav",
	"zombie_escape/knife_menu/katana_slash.wav",
	"zombie_escape/knife_menu/katana_stab.wav"
}

new const hammer_sounds[][] =
{
	"zombie_escape/knife_menu/hammer_deploy.wav",
	"zombie_escape/knife_menu/hammer_hit.wav",
	"zombie_escape/knife_menu/hammer_hit.wav",
	"zombie_escape/knife_menu/hammer_hit.wav",
	"zombie_escape/knife_menu/hammer_hit.wav",
	"zombie_escape/knife_menu/hammer_hitwall.wav",
	"zombie_escape/knife_menu/hammer_slash.wav",
	"zombie_escape/knife_menu/hammer_slash.wav",
	"zombie_escape/knife_menu/hammer_stab.wav"
}

new const oldknife_sounds[][] =
{
	"weapons/knife_deploy1.wav",
	"weapons/knife_hit1.wav",
	"weapons/knife_hit2.wav",
	"weapons/knife_hit3.wav",
	"weapons/knife_hit4.wav",
	"weapons/knife_hitwall1.wav",
	"weapons/knife_slash1.wav",
	"weapons/knife_slash2.wav",
	"weapons/knife_stab.wav"
}
 
new bool:g_bCompat[33], bool:g_bStrong[33], bool:g_bKatana[33], bool:g_bHammer[33],
g_iUsedTimes[33], g_pCvarUseTimes

public plugin_precache()
{
	new i

	for (i = 0; i <= charsmax(Compat_Models); i++)
		precache_model(Compat_Models[i])

	for (i = 0; i <= charsmax(Hammer_Models); i++)
		precache_model(Hammer_Models[i])

	for (i = 0; i <= charsmax(Katana_Models); i++)
		precache_model(Katana_Models[i])

	for (i = 0; i <= charsmax(Strong_Models); i++)
		precache_model(Strong_Models[i])

	for (i = 0; i <= charsmax(combat_sounds); i++)
		precache_sound(combat_sounds[i])

	for (i = 0; i <= charsmax(strong_sounds); i++)
		precache_sound(strong_sounds[i])

	for (i = 0; i <= charsmax(katana_sounds); i++)
		precache_sound(katana_sounds[i])

	for (i = 0; i <= charsmax(hammer_sounds); i++)
		precache_sound(hammer_sounds[i])

	precache_sound(g_sound_knife)
}
 
public plugin_natives()
{
	register_native("ze_open_knife_menu", "native_ze_open_knife_menu", 1)
}
 
public plugin_init()
{
	register_plugin("[ZE] Addon: Knife Menu", "1.2", "Jack GamePlay")

	register_forward(FM_EmitSound, "fw_EmitSound")

	register_event("CurWeapon", "CurrentWeapon", "be", "1=1")

	g_pCvarUseTimes = register_cvar("ze_knife_menu_use_times", "1")

	register_message(get_user_msgid("DeathMsg"), "DeathMsg")

	register_clcmd("say /k", "Show_Knife_Menu")
}
 
public ze_user_humanized(id)
{
	g_iUsedTimes[id] = 0
}

public ze_user_infected(Victim)
{
	g_bCompat[Victim] = false
	g_bStrong[Victim] = false
	g_bKatana[Victim] = false
	g_bHammer[Victim] = false
	g_iUsedTimes[Victim] = 0
}

public client_putinserver(id)
{
	g_bCompat[id] = false
	g_bStrong[id] = false
	g_bKatana[id] = false
	g_bHammer[id] = false
	g_iUsedTimes[id] = 0
}

public client_disconnected(id)
{
	g_bCompat[id] = false
	g_bStrong[id] = false
	g_bKatana[id] = false
	g_bHammer[id] = false
	g_iUsedTimes[id] = 0
}

public Show_Knife_Menu(id)
{
	if (!is_user_connected(id))
		return PLUGIN_CONTINUE

	if (ze_is_user_zombie(id))
	{
		ze_colored_print(id, "!tZombies can't open knife menu!y.")
		return PLUGIN_HANDLED
	}

	if (g_iUsedTimes[id] >= get_pcvar_num(g_pCvarUseTimes))
	{
		ze_colored_print(id, "!tMaximum have been reached !y[!g%d!y]!", get_pcvar_num(g_pCvarUseTimes))
		return PLUGIN_HANDLED
	}

	if (!is_user_alive(id))
	{
		ze_colored_print(id, "!tDead can't open knife menu!y.")
		return PLUGIN_HANDLED
	}

	Knife_Menu(id)
	return PLUGIN_CONTINUE
}
 
public Knife_Menu(id)
{
	new iMenu = menu_create("\rChoose Your Knife\w:", "Menu_Handler")
	menu_additem(iMenu, "\yCombat", "", 0)
	menu_additem(iMenu, "\yStrong", "", 0)
	menu_additem(iMenu, "\yKatana", "", 0)
	menu_additem(iMenu, "\yHammer", "", 0)
	menu_additem(iMenu, "Tactical", "", 0)
	menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL)
	menu_display(id, iMenu, 0)
}
 
public Menu_Handler(id, iMenu, iKey)
{
	if(!is_user_alive(id) || ze_is_user_zombie(id))
		return PLUGIN_HANDLED
		
	switch(iKey)
	{
		case 0: // Compat
		{
			g_bCompat[id] = true
			g_bStrong[id] = false
			g_bKatana[id] = false
			g_bHammer[id] = false
			ze_remove_tactical(id)
			g_iUsedTimes[id]++
			/*rg_remove_item(id, "weapon_knife")
			rg_give_item(id, "weapon_knife", GT_APPEND)
			engclient_cmd(id, "weapon_knife")
			emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
		}
		case 1: // Strong
		{
			g_bCompat[id] = false
			g_bStrong[id] = true
			g_bKatana[id] = false
			g_bHammer[id] = false
			ze_remove_tactical(id)
			g_iUsedTimes[id]++
			/*rg_remove_item(id, "weapon_knife")
			rg_give_item(id, "weapon_knife", GT_APPEND)
			engclient_cmd(id, "weapon_knife")
			emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
		}
		case 2: // Katana
		{
			g_bCompat[id] = false
			g_bStrong[id] = false
			g_bKatana[id] = true
			g_bHammer[id] = false
			ze_remove_tactical(id)
			/*rg_remove_item(id, "weapon_knife")
			rg_give_item(id, "weapon_knife", GT_APPEND)
			engclient_cmd(id, "weapon_knife")
			emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
		}
		case 3: // Hammer
		{
			g_bCompat[id] = false
			g_bStrong[id] = false
			g_bKatana[id] = false
			g_bHammer[id] = true
			g_iUsedTimes[id]++
			ze_remove_tactical(id)
			/*rg_remove_item(id, "weapon_knife")
			rg_give_item(id, "weapon_knife", GT_APPEND)
			engclient_cmd(id, "weapon_knife")
			g_iUsedTimes[id]++
			emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
		}
		case 4:
		{
			ze_get_tactical(id)
			g_bCompat[id] = false
			g_bStrong[id] = false
			g_bKatana[id] = false
			g_bHammer[id] = true
			g_iUsedTimes[id]++
		}
	}

	rg_remove_item(id, "weapon_knife")
	rg_give_item(id, "weapon_knife", GT_APPEND)
	engclient_cmd(id, "weapon_knife")
	g_iUsedTimes[id]++
	emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}
 
public fw_EmitSound(id, channel, const sound[])
{
    if(!is_user_alive(id) || ze_is_user_zombie(id))
        return FMRES_IGNORED
       
    new i
    for (i = 0; i <= charsmax(combat_sounds); i++)
    for (i = 0; i <= charsmax(strong_sounds); i++)
    for (i = 0; i <= charsmax(katana_sounds); i++)
    for (i = 0; i <= charsmax(hammer_sounds); i++)
    {
        if(equal(sound, oldknife_sounds[i]))
        {
            if (g_bCompat[id])
            {
                emit_sound(id, channel, combat_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if (g_bStrong[id])
            {
                emit_sound(id, channel, strong_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if (g_bKatana[id])
            {
                emit_sound(id, channel, katana_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if (g_bHammer[id])
            {
                emit_sound(id, channel, hammer_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if (!g_bCompat[id] || !g_bStrong[id] || !g_bKatana[id] || !g_bHammer[id])
            {
                emit_sound(id, channel, oldknife_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
        }
    }
    return FMRES_IGNORED
}

public CurrentWeapon(id)
{
    if(!is_user_alive(id) || ze_is_user_zombie(id))
        return
       
    if(get_user_weapon(id) & CSW_KNIFE)
    {
        if(g_bCompat[id])
        {
            cs_set_player_view_model(id, CSW_KNIFE, Compat_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Compat_Models[1])
        }
        else if(g_bStrong[id])
        {
            cs_set_player_view_model(id, CSW_KNIFE, Strong_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Strong_Models[1])
        }
        else if(g_bKatana[id])
        {
            cs_set_player_view_model(id, CSW_KNIFE, Katana_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Katana_Models[1])
        }
        else if(g_bHammer[id])
        {
            cs_set_player_view_model(id, CSW_KNIFE, Hammer_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Hammer_Models[1])
        }
		else
		{
			cs_reset_player_view_model(id, CSW_KNIFE)
			cs_reset_player_weap_model(id, CSW_KNIFE)
		}
    }
}

public DeathMsg(msg_id, msg_dest, id)
{
    static szTruncatedWeapon[33], iAttacker
    get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
    iAttacker = get_msg_arg_int(1)
   
    if(!is_user_alive(iAttacker) || iAttacker == get_msg_arg_int(2) || !is_user_alive(get_msg_arg_int(2))) // get_msg_arg_int(2) = iVictim
        return
   
    if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iAttacker) & CSW_KNIFE)
    {
        if(g_bCompat[id])
        {
            set_msg_arg_string(4, "Combat knife")
        }
        else if(g_bStrong[id])
        {
            set_msg_arg_string(4, "Strong knife")
        }
        else if(g_bKatana[id])
        {
            set_msg_arg_string(4, "Katana knife")
        }
        else if(g_bHammer[id])
        {
            set_msg_arg_string(4, "Ice knife")
        }
    }
}

public native_ze_open_knife_menu(id)
{
	Show_Knife_Menu(id)
}
Tactical:

Code: Select all

#include <zombie_escape>
#include <engine>
#include <fakemeta_util>
#include <cstrike>
#include <fun>
 
#define PLUGIN "ze_Tactical Knife"
#define VERSION "1.1"
#define AUTHOR "m4m3ts/Mark"
 
#define CSW_TACT CSW_P228
#define weapon_tact "weapon_p228"
#define old_event "events/p228.sc"
#define old_w_model "models/w_p228.mdl"
#define WEAPON_SECRETCODE 4234234
 
 
#define RELOAD_TIME 0.435
#define STAB_TIME 1.1
#define ATTACK_TIME 1.0
#define SYSTEM_CLASSNAME "tact_knife"
#define SYSTEM_CLASSNAME2 "tact_knife2"
#define WEAPON_ANIMEXT "grenade"
 
const PDATA_SAFE = 2
const OFFSET_LINUX_WEAPONS = 4
const OFFSET_WEAPONOWNER = 41
 
new const v_model[] = "models/v_tknifeex2.mdl"
new const p_model[] = "models/p_tknifeex2.mdl"
new const w_model[] = "models/w_tknifeex2.mdl"
new const ARROW_MODEL[] = "models/tknifeb.mdl"
new const tact_wall[][] = {"weapons/tknife_stone1.wav", "weapons/tknife_stone2.wav"}
new const weapon_sound[4][] =
{
    "weapons/tknife_shoot1.wav",
    "weapons/tknifeex2_shoot1.wav",
    "weapons/tknifeex2_draw.wav",
    "weapons/tact_hit.wav"
}
 
 
new const WeaponResource[4][] =
{
    "sprites/weapon_tknifeex2.txt",
    "sprites/640hud12.spr",
    "sprites/640hud96.spr",
    "sprites/640hud97.spr"
}
 
enum
{
    ANIM_IDLE = 0,
    ANIM_SHOOT,
    ANIM_DRAW,
    ANIM_SHOOT2
}
 
new g_MsgDeathMsg
 
new g_had_tact[33], g_tact_ammo[33], g_Shoot_Count[33]
new g_old_weapon[33], m_iBlood[2]
new sTrail, cvar_dmg_slash_tact, cvar_dmg_stab_tact, cvar_ammo_tactical
 
const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)

public plugin_natives()
{
    register_native("ze_get_tactical", "native_ze_get_tactical", 1)
    register_native("ze_remove_tactical", "native_ze_remove_tactical", 1)
}

public native_ze_get_tactical(id)
{
    if (!is_user_connected(id))
        return
        
    get_tact(id)
}

public native_ze_remove_tactical(id)
{
    if (!is_user_connected(id))
        return
        
    remove_tact(id)
}

public plugin_precache()
{
    precache_model(v_model)
    precache_model(p_model)
    precache_model(w_model)
    precache_model(ARROW_MODEL)
   
    for(new i = 0; i < sizeof(weapon_sound); i++)
        precache_sound(weapon_sound[i])
   
    for(new i = 0; i < sizeof(tact_wall); i++)
        precache_sound(tact_wall[i])
   
    precache_generic(WeaponResource[0])
    for(new i = 1; i < sizeof(WeaponResource); i++)
        precache_model(WeaponResource[i])
   
    m_iBlood[0] = precache_model("sprites/blood.spr")
    m_iBlood[1] = precache_model("sprites/bloodspray.spr")
    sTrail = precache_model("sprites/laserbeam.spr")
}
 
public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_cvar("tact_version", "m4m3ts", FCVAR_SERVER|FCVAR_SPONLY)
    register_forward(FM_CmdStart, "fw_CmdStart")
    register_forward(FM_SetModel, "fw_SetModel")
    register_think(SYSTEM_CLASSNAME, "fw_Think")
    register_think(SYSTEM_CLASSNAME2, "fw_Think")
    register_touch(SYSTEM_CLASSNAME, "*", "fw_touch")
    register_touch(SYSTEM_CLASSNAME2, "*", "fw_touch2")
    register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
    register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)    
    RegisterHam(Ham_Item_AddToPlayer, weapon_tact, "fw_AddToPlayer_Post", 1)
    register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
   
    register_clcmd("weapon_tknifeex2", "hook_weapon")
   
    cvar_dmg_slash_tact = register_cvar("zp_tactical_dmg_slash", "61.0")
    cvar_dmg_stab_tact = register_cvar("zp_tactical_dmg_stab", "140.0")
    cvar_ammo_tactical = register_cvar("zp_tactical_ammo", "60")
   
    g_MsgDeathMsg = get_user_msgid("DeathMsg")
   
}
 
public ze_user_humanized(id)
{
    remove_tact(id)
}
 
public ze_user_infected(Victim)
{
    remove_tact(Victim)
}
 
public client_putinserver(id)
{
    remove_tact(id)
}
 
public client_disconnected(id)
{
    remove_tact(id)
}
 
public fw_PlayerKilled(id)
{
    remove_tact(id)
}
 
public hook_weapon(id)
{
    engclient_cmd(id, weapon_tact)
    return
}
 
public get_tact(id)
{
    if(!is_user_alive(id))
        return
    drop_weapons(id, 1)
    g_had_tact[id] = 1
    g_tact_ammo[id] = get_pcvar_num(cvar_ammo_tactical)
   
    give_item(id, weapon_tact)
   
    static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, weapon_tact, id)
    if(pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent, 1)
}
 
public remove_tact(id)
{
    g_had_tact[id] = 0
    g_tact_ammo[id] = 0
}
 
public refill_tact(id)
{
    g_tact_ammo[id] = get_pcvar_num(cvar_ammo_tactical)
    update_ammo(id)
}
   
public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{
    if(!is_user_alive(id) || !is_user_connected(id))
        return FMRES_IGNORED    
    if(get_user_weapon(id) == CSW_TACT && g_had_tact[id])
        set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
   
    return FMRES_HANDLED
}
 
public Event_CurWeapon(id)
{
    if(!is_user_alive(id))
        return
       
    if(get_user_weapon(id) == CSW_TACT && g_had_tact[id])
    {
        set_pev(id, pev_viewmodel2, v_model)
        set_pev(id, pev_weaponmodel2, p_model)
        set_pdata_string(id, (492) * 4, WEAPON_ANIMEXT, -1 , 20)
        set_weapon_anim(id, ANIM_DRAW)
        update_ammo(id)
    }
   
    g_old_weapon[id] = get_user_weapon(id)
}
 
public fw_CmdStart(id, uc_handle, seed)
{
    if(!is_user_alive(id) || !is_user_connected(id))
        return
    if(get_user_weapon(id) != CSW_TACT || !g_had_tact[id])
        return
   
    static ent; ent = fm_get_user_weapon_entity(id, CSW_TACT)
    if(!pev_valid(ent))
        return
    if(get_pdata_float(ent, 46, OFFSET_LINUX_WEAPONS) > 0.0 || get_pdata_float(ent, 47, OFFSET_LINUX_WEAPONS) > 0.0)
        return
   
    static CurButton
    CurButton = get_uc(uc_handle, UC_Buttons)
   
    if(CurButton & IN_ATTACK)
    {
        CurButton &= ~IN_ATTACK
        set_uc(uc_handle, UC_Buttons, CurButton)
       
        if(g_tact_ammo[id] == 0)
            return
        if(get_pdata_float(id, 83, 5) <= 0.0)
        {
            g_tact_ammo[id]--
            g_Shoot_Count[id] = 0
            update_ammo(id)
            set_task(0.2, "throw_knife", id)
            set_weapon_anim(id, ANIM_SHOOT)
            set_weapons_timeidle(id, CSW_TACT, ATTACK_TIME)
            set_player_nextattackx(id, ATTACK_TIME)
        }
    }
    else if(CurButton & IN_ATTACK2)
    {
        if(get_pdata_float(id, 83, 5) <= 0.0)
        {
            set_weapon_anim(id, ANIM_SHOOT2)
            FireArrow_Charge(id)
            emit_sound(id, CHAN_VOICE, weapon_sound[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
            set_weapons_timeidle(id, CSW_TACT, STAB_TIME)
            set_player_nextattackx(id, STAB_TIME)
        }
    }
}
 
public throw_knife(id)
{
    FireArrow1(id)
    FireArrow2(id)
    FireArrow3(id)
}
 
public FireArrow1(id)
{
    static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3], Float:anglestrue[3]
    get_position(id, 2.0, 4.0, -3.0, StartOrigin)
 
    pev(id,pev_v_angle,angles)
    static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
    if(!pev_valid(Ent)) return
    anglestrue[0] = 180.0 - angles[0]
    anglestrue[1] = angles[1]
    anglestrue[2] = angles[2]
   
    // Set info for ent
    set_pev(Ent, pev_movetype, MOVETYPE_TOSS)
    set_pev(Ent, pev_owner, id) // Better than pev_owner
    set_pev(Ent, pev_fuser1, get_gametime() + 4.0)
    set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
   
    entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME)
    engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
    set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
    set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
    set_pev(Ent, pev_origin, StartOrigin)
    set_pev(Ent, pev_angles, anglestrue)
    set_pev(Ent, pev_gravity, 0.5)
    set_pev(Ent, pev_solid, SOLID_BBOX)
    set_pev(Ent, pev_frame, 0.0)
   
    static Float:Velocity[3]
    get_position(id, 1024.0, 12.0, -12.0, TargetOrigin)
    get_speed_vector(StartOrigin, TargetOrigin, 2300.0, Velocity)
    set_pev(Ent, pev_velocity, Velocity)
 
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(TE_BEAMFOLLOW) // Temporary entity ID
    write_short(Ent) // Entity
    write_short(sTrail) // Sprite index
    write_byte(7) // Life
    write_byte(1) // Line width
    write_byte(255) // Red
    write_byte(255) // Green
    write_byte(255) // Blue
    write_byte(65) // Alpha
    message_end()
}
 
public FireArrow2(id)
{
    static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3], Float:anglestrue[3]
    get_position(id, 2.0, -4.0, -2.0, StartOrigin)
 
    pev(id,pev_v_angle,angles)
    static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
    if(!pev_valid(Ent)) return
    anglestrue[0] = 180.0 - angles[0]
    anglestrue[1] = angles[1]
    anglestrue[2] = angles[2]
   
    // Set info for ent
    set_pev(Ent, pev_movetype, MOVETYPE_TOSS)
    set_pev(Ent, pev_owner, id) // Better than pev_owner
    set_pev(Ent, pev_fuser1, get_gametime() + 4.0)
    set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
   
    entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME)
    engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
    set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
    set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
    set_pev(Ent, pev_origin, StartOrigin)
    set_pev(Ent, pev_angles, anglestrue)
    set_pev(Ent, pev_gravity, 0.5)
    set_pev(Ent, pev_solid, SOLID_BBOX)
    set_pev(Ent, pev_frame, 0.0)
   
    static Float:Velocity[3]
    get_position(id, 1024.0, -12.0, -12.0, TargetOrigin)
    get_speed_vector(StartOrigin, TargetOrigin, 2300.0, Velocity)
    set_pev(Ent, pev_velocity, Velocity)
 
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(TE_BEAMFOLLOW) // Temporary entity ID
    write_short(Ent) // Entity
    write_short(sTrail) // Sprite index
    write_byte(7) // Life
    write_byte(1) // Line width
    write_byte(255) // Red
    write_byte(255) // Green
    write_byte(255) // Blue
    write_byte(65) // Alpha
    message_end()
}
 
public FireArrow3(id)
{
    static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3], Float:anglestrue[3]
    get_position(id, 2.0, 2.0, 4.0, StartOrigin)
 
    pev(id,pev_v_angle,angles)
    static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
    if(!pev_valid(Ent)) return
    anglestrue[0] = 180.0 - angles[0]
    anglestrue[1] = angles[1]
    anglestrue[2] = angles[2]
   
    // Set info for ent
    set_pev(Ent, pev_movetype, MOVETYPE_TOSS)
    set_pev(Ent, pev_owner, id) // Better than pev_owner
    set_pev(Ent, pev_fuser1, get_gametime() + 4.0)
    set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
   
    entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME)
    engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
    set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
    set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
    set_pev(Ent, pev_origin, StartOrigin)
    set_pev(Ent, pev_angles, anglestrue)
    set_pev(Ent, pev_gravity, 0.5)
    set_pev(Ent, pev_solid, SOLID_BBOX)
    set_pev(Ent, pev_frame, 0.0)
   
    static Float:Velocity[3]
    get_position(id, 1024.0, 12.0, 12.0, TargetOrigin)
    get_speed_vector(StartOrigin, TargetOrigin, 2300.0, Velocity)
    set_pev(Ent, pev_velocity, Velocity)
 
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(TE_BEAMFOLLOW) // Temporary entity ID
    write_short(Ent) // Entity
    write_short(sTrail) // Sprite index
    write_byte(7) // Life
    write_byte(1) // Line width
    write_byte(255) // Red
    write_byte(255) // Green
    write_byte(255) // Blue
    write_byte(65) // Alpha
    message_end()
}
 
public FireArrow_Charge(id)
{
    static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3]
    get_position(id, 2.0, 0.0, 0.0, StartOrigin)
 
    pev(id,pev_angles,angles)
    static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
    if(!pev_valid(Ent)) return
   
    // Set info for ent
    set_pev(Ent, pev_movetype, MOVETYPE_FLY)
    set_pev(Ent, pev_owner, id) // Better than pev_owner
    set_pev(Ent, pev_rendermode, kRenderTransAdd)
    set_pev(Ent, pev_renderamt, 1.0)
    set_pev(Ent, pev_fuser1, get_gametime() + 0.1)
    set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
   
    entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME2)
    engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
    set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
    set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
    set_pev(Ent, pev_origin, StartOrigin)
    set_pev(Ent, pev_angles, angles)
    set_pev(Ent, pev_gravity, 0.01)
    set_pev(Ent, pev_solid, SOLID_BBOX)
    set_pev(Ent, pev_frame, 0.0)
   
    static Float:Velocity[3]
    fm_get_aim_origin(id, TargetOrigin)
    get_speed_vector(StartOrigin, TargetOrigin, 800.0, Velocity)
    set_pev(Ent, pev_velocity, Velocity)
}
 
public fw_Think(ent)
{
    if(!pev_valid(ent))
        return
   
    static Float:fFrame; pev(ent, pev_frame, fFrame)
   
    fFrame += 1.5
    fFrame = floatmin(21.0, fFrame)
   
    set_pev(ent, pev_frame, fFrame)
    set_pev(ent, pev_nextthink, get_gametime() + 0.05)
   
    // time remove
    static Float:fTimeRemove, Float:Amount
    pev(ent, pev_fuser1, fTimeRemove)
    pev(ent, pev_renderamt, Amount)
   
    if(get_gametime() >= fTimeRemove)
    {
        remove_entity(ent)
    }
}
 
public fw_touch(Ent, Id)
{
    // If ent is valid
    if(!pev_valid(Ent))
        return
    static Owner; Owner = pev(Ent, pev_owner)
    if(pev(Ent, pev_movetype) == MOVETYPE_NONE)
        return
    static classnameptd[32]
    pev(Id, pev_classname, classnameptd, 31)
    if (equali(classnameptd, "func_breakable")) ExecuteHamB( Ham_TakeDamage, Id, 0, 0, 60.0, DMG_GENERIC )
    Damage_tact(Ent, Id)
   
    // Get it's origin
    new Float:originF[3]
    pev(Ent, pev_origin, originF)
    // Alive...
   
    if(is_user_alive(Id) && ze_is_user_zombie(Id))
    {
        remove_entity(Ent)
        create_blood(originF)
        create_blood(originF)
        emit_sound(Id, CHAN_BODY, weapon_sound[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
   
    else if(is_user_alive(Id) && !ze_is_user_zombie(Id))
    {
        remove_entity(Ent)
        emit_sound(Id, CHAN_VOICE, weapon_sound[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
   
    else
    {
        set_pev(Ent, pev_fuser1, get_gametime() + 1.0)
        make_bullet(Owner, originF)
        engfunc(EngFunc_EmitSound, Ent, CHAN_WEAPON, tact_wall[random( sizeof(tact_wall))], 1.0, ATTN_STATIC, 0, PITCH_NORM)
        set_pev(Ent, pev_movetype, MOVETYPE_NONE)
        set_pev(Ent, pev_solid, SOLID_NOT)
    }
}
 
public fw_touch2(Ent, Id)
{
    // If ent is valid
    if(!pev_valid(Ent))
        return
    if(pev(Ent, pev_movetype) == MOVETYPE_NONE)
        return
   
    static classnameptd[32]
    pev(Id, pev_classname, classnameptd, 31)
    if (equali(classnameptd, "func_breakable")) ExecuteHamB( Ham_TakeDamage, Id, 0, 0, 200.0, DMG_GENERIC )
    Damage_tact2(Ent, Id)
   
    // Get it's origin
    new Float:originF[3]
    pev(Ent, pev_origin, originF)
    // Alive...
   
    if(is_user_alive(Id) && ze_is_user_zombie(Id))
    {
        remove_entity(Ent)
        create_blood(originF)
        create_blood(originF)
        emit_sound(Id, CHAN_BODY, weapon_sound[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
   
    else if(is_user_alive(Id) && !ze_is_user_zombie(Id))
    {
        remove_entity(Ent)
        emit_sound(Id, CHAN_VOICE, weapon_sound[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
   
    else
    {
        engfunc(EngFunc_EmitSound, Ent, CHAN_WEAPON, tact_wall[random( sizeof(tact_wall))], 1.0, ATTN_STATIC, 0, PITCH_NORM)
        set_pev(Ent, pev_movetype, MOVETYPE_NONE)
        set_pev(Ent, pev_solid, SOLID_NOT)
    }
}
       
public Remove_tactBall(Ent)
{
    if(!pev_valid(Ent)) return
    engfunc(EngFunc_RemoveEntity, Ent)
}
 
public Damage_tact(Ent, Id)
{
    static Owner; Owner = pev(Ent, pev_owner)
    static Attacker;
    if(!is_user_alive(Owner))
    {
        Attacker = 0
        return
    } else Attacker = Owner
 
    new bool:bIsHeadShot; // never make that one static
    new Float:flAdjustedDamage, bool:death
 
    switch( Get_MissileWeaponHitGroup(Ent) )
    {
        case HIT_GENERIC: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 1.5
        case HIT_CHEST: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 1.0
        case HIT_STOMACH: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 1.0
        case HIT_LEFTLEG, HIT_RIGHTLEG: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 0.75
        case HIT_LEFTARM, HIT_RIGHTARM: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 0.35
        case HIT_HEAD:
        {
            flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 2.50
            bIsHeadShot = true;
        }
    }
    if(pev(Id, pev_health) <= flAdjustedDamage) death = true
   
    if(is_user_alive(Id))
    {
        if( bIsHeadShot && death)
        {
            emessage_begin(MSG_BROADCAST, g_MsgDeathMsg)
            ewrite_byte(Attacker)
            ewrite_byte(Id)
            ewrite_byte(1)
            ewrite_string("Triple Tactical Knife")
            emessage_end()
           
            set_msg_block(g_MsgDeathMsg, BLOCK_SET)
            user_silentkill(Id)
            set_msg_block(g_MsgDeathMsg, BLOCK_NOT)
 
            death = false
        }
        else ExecuteHamB(Ham_TakeDamage, Id, Ent, Attacker, flAdjustedDamage, DMG_BULLET)
    }
}
 
public Damage_tact2(Ent, Id)
{
    static Owner; Owner = pev(Ent, pev_owner)
    static Attacker;
    if(!is_user_alive(Owner))
    {
        Attacker = 0
        return
    } else Attacker = Owner
   
    new bool:bIsHeadShot; // never make that one static
    new Float:flAdjustedDamage, bool:death
 
    switch( Get_MissileWeaponHitGroup(Ent) )
    {
        case HIT_GENERIC: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 1.5
        case HIT_CHEST: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 1.0
        case HIT_STOMACH: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 1.0
        case HIT_LEFTLEG, HIT_RIGHTLEG: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 0.75
        case HIT_LEFTARM, HIT_RIGHTARM: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 0.35
        case HIT_HEAD:
        {
            flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 2.50
            bIsHeadShot = true;
        }
    }
    if(pev(Id, pev_health) <= flAdjustedDamage) death = true
   
    if(is_user_alive(Id))
    {
        if( bIsHeadShot && death)
        {
            emessage_begin(MSG_BROADCAST, g_MsgDeathMsg)
            ewrite_byte(Attacker)
            ewrite_byte(Id)
            ewrite_byte(1)
            ewrite_string("Triple Tactical Knife")
            emessage_end()
           
            set_msg_block(g_MsgDeathMsg, BLOCK_SET)
            user_silentkill(Id)
            set_msg_block(g_MsgDeathMsg, BLOCK_NOT)
 
            death = false
        }
        else ExecuteHamB(Ham_TakeDamage, Id, Ent, Attacker, flAdjustedDamage, DMG_BULLET)
    }
}
 
public fw_SetModel(entity, model[])
{
    if(!pev_valid(entity))
        return FMRES_IGNORED
   
    static Classname[64]
    pev(entity, pev_classname, Classname, sizeof(Classname))
   
    if(!equal(Classname, "weaponbox"))
        return FMRES_IGNORED
   
    static id
    id = pev(entity, pev_owner)
   
    if(equal(model, old_w_model))
    {
        static weapon
        weapon = fm_get_user_weapon_entity(entity, CSW_TACT)
       
        if(!pev_valid(weapon))
            return FMRES_IGNORED
       
        if(g_had_tact[id])
        {
            set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
            set_pev(weapon, pev_iuser4, g_tact_ammo[id])
            engfunc(EngFunc_SetModel, entity, w_model)
           
            g_had_tact[id] = 0
            g_tact_ammo[id] = 0
           
            return FMRES_SUPERCEDE
        }
    }
 
    return FMRES_IGNORED;
}
 
public fw_AddToPlayer_Post(ent, id)
{
    if(pev(ent, pev_impulse) == WEAPON_SECRETCODE)
    {
        g_had_tact[id] = 1
        g_tact_ammo[id] = pev(ent, pev_iuser4)
       
        set_pev(ent, pev_impulse, 0)
    }          
   
    message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("WeaponList"), _, id)
    write_string((g_had_tact[id] == 1 ? "weapon_tknifeex2" : "weapon_p228"))
    write_byte(1)
    write_byte(52)
    write_byte(-1)
    write_byte(-1)
    write_byte(1)
    write_byte(3)
    write_byte(CSW_TACT)
    write_byte(0)
    message_end()
}
 
public update_ammo(id)
{
    if(!is_user_alive(id))
        return
   
    static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, weapon_tact, id)
    if(pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent, 1)
   
    cs_set_user_bpammo(id, CSW_P228, 0)
   
    engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), {0, 0, 0}, id)
    write_byte(1)
    write_byte(CSW_TACT)
    write_byte(-1)
    message_end()
   
    message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
    write_byte(1)
    write_byte(g_tact_ammo[id])
    message_end()
}
 
stock make_bullet(id, Float:Origin[3])
{
    // Find target
    new decal = random_num(41, 45)
    const loop_time = 2
   
    static Body, Target
    get_user_aiming(id, Target, Body, 999999)
   
    if(is_user_connected(Target))
        return
   
    for(new i = 0; i < loop_time; i++)
    {
        // Put decal on "world" (a wall)
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(TE_WORLDDECAL)
        engfunc(EngFunc_WriteCoord, Origin[0])
        engfunc(EngFunc_WriteCoord, Origin[1])
        engfunc(EngFunc_WriteCoord, Origin[2])
        write_byte(decal)
        message_end()
       
        // Show sparcles
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(TE_GUNSHOTDECAL)
        engfunc(EngFunc_WriteCoord, Origin[0])
        engfunc(EngFunc_WriteCoord, Origin[1])
        engfunc(EngFunc_WriteCoord, Origin[2])
        write_short(id)
        write_byte(decal)
        message_end()
    }
}
 
stock set_weapon_anim(id, anim)
{
    if(!is_user_alive(id))
        return
   
    set_pev(id, pev_weaponanim, anim)
   
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
    write_byte(anim)
    write_byte(pev(id, pev_body))
    message_end()
}
 
stock create_blood(const Float:origin[3])
{
    // Show some blood :)
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(TE_BLOODSPRITE)
    engfunc(EngFunc_WriteCoord, origin[0])
    engfunc(EngFunc_WriteCoord, origin[1])
    engfunc(EngFunc_WriteCoord, origin[2])
    write_short(m_iBlood[1])
    write_short(m_iBlood[0])
    write_byte(75)
    write_byte(8)
    message_end()
}
 
stock drop_weapons(id, dropwhat)
{
    static weapons[32], num, i, weaponid
    num = 0
    get_user_weapons(id, weapons, num)
     
    for (i = 0; i < num; i++)
    {
        weaponid = weapons[i]
         
        if (dropwhat == 1 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))
        {
            static wname[32]
            get_weaponname(weaponid, wname, sizeof wname - 1)
            engclient_cmd(id, "drop", wname)
        }
    }
}
 
stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
    new_velocity[0] = origin2[0] - origin1[0]
    new_velocity[1] = origin2[1] - origin1[1]
    new_velocity[2] = origin2[2] - origin1[2]
    static Float:num; 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;
}
 
stock Get_MissileWeaponHitGroup( iEnt )
{
    new Float:flStart[ 3 ], Float:flEnd[ 3 ];
   
    pev( iEnt, pev_origin, flStart );
    pev( iEnt, pev_velocity, flEnd );
    xs_vec_add( flStart, flEnd, flEnd );
   
    new ptr = create_tr2();
    engfunc( EngFunc_TraceLine, flStart, flEnd, 0, iEnt, ptr );
   
    new iHitGroup
    iHitGroup = get_tr2( ptr, TR_iHitgroup )
    free_tr2( ptr );
   
    return iHitGroup;
}
 
stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
{
    static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
   
    pev(id, pev_origin, vOrigin)
    pev(id, pev_view_ofs, vUp) //for player
    xs_vec_add(vOrigin, vUp, vOrigin)
    pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
   
    angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
    angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
    angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
   
    vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
    vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
    vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}
 
stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
{
    if(!is_user_alive(id))
        return
       
    static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
    if(!pev_valid(entwpn))
        return
       
    set_pdata_float(entwpn, 46, TimeIdle, OFFSET_LINUX_WEAPONS)
    set_pdata_float(entwpn, 47, TimeIdle, OFFSET_LINUX_WEAPONS)
    set_pdata_float(entwpn, 48, TimeIdle + 0.5, OFFSET_LINUX_WEAPONS)
}
 
stock set_player_nextattackx(id, Float:nexttime)
{
    if(!is_user_alive(id))
        return
       
    set_pdata_float(id, 83, nexttime, 5)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/[code]
Not interested in CS/Pawn anymore.
Accepting web projects.

User avatar
Muhammet20
Senior Member
Senior Member
Syria
Posts: 248
Joined: 10 Months Ago
Location: Turkey
Has thanked: 28 times
Been thanked: 1 time
Age: 13
Contact:

#3

Post by Muhammet20 » 5 Months Ago

@jack you are really good :) , nice to meet you

[ Post made via Android ]
I just believe in two things , First one is who i see him in the mirror , and second one is who i don't see him in the sky.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests