Originally Posted by wicho
(Post 2025591)
Try..
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <zombieplague>
#include <colorchat>
#define PLUGIN "[ZP4.3] Extra Item: Fast Attack"
#define AUTHOR "schmurgel1983 & wicho"
#define VERSION "1.0"
const OFFSET_WEAPONOWNER = 41
const OFFSET_LINUX_WEAPONS = 4
const m_flNextPrimaryAttack = 46
const m_flNextSecondaryAttack = 47
#define MarkPlayergFastattack(%0) bitPlayerFastattack |= (1 << (%0 & 31))
#define ClearPlayerFastattack(%0) bitPlayerFastattack &= ~(1 << (%0 & 31))
#define IsPlayerFastattack(%0) bitPlayerFastattack & (1 << (%0 & 31))
new bitPlayerFastattack
new item_fastattack
new cvar_Primary, cvar_PrimarySpeed, cvar_Secondary, cvar_SecondarySpeed
new cvar_Fastattack_time
new cvar_Fastattack_limit
new g_Limit[33]
new g_MaxPlayers
const COST = 10
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fwd_Knife_PriAtk_Post", 1)
RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fwd_Knife_SecAtk_Post", 1)
cvar_Primary = register_cvar("zp_fastattack_pri", "1")
cvar_PrimarySpeed = register_cvar("zp_fastattack_pri_speed", "0.33")
cvar_Secondary = register_cvar("zp_fastattack_sec", "1")
cvar_SecondarySpeed = register_cvar("zp_fastattack_sec_speed", "0.33")
cvar_Fastattack_time = register_cvar("zp_fastattack_time", "5.0")
cvar_Fastattack_limit = register_cvar("zp_fastattack_limit", "2")
register_event("HLTV", "NewRound", "a", "1=0", "2=0")
g_MaxPlayers = get_maxplayers()
item_fastattack = zp_register_extra_item("Fast Attack", COST, ZP_TEAM_ZOMBIE)
}
public zp_extra_item_selected(id,itemid)
{
if (itemid == item_fastattack)
return PLUGIN_CONTINUE;
if(is_user_alive(id))
{
if (g_Limit[id] >= get_pcvar_num(cvar_Fastattack_limit))
{
client_print(id, print_chat, "[ZP] You only can buy two times per round")
return ZP_PLUGIN_HANDLED;
}
MarkPlayergFastattack(id)
set_task(get_pcvar_float(cvar_Fastattack_time), "remove_fastattack", id)
ColorChat(id, TEAM_COLOR, "^x01You bought fast attack for ^x04%.f0 ^x01seconds !!!", get_pcvar_float(cvar_Fastattack_time));
g_Limit[id]++
}
return PLUGIN_CONTINUE;
}
public zp_user_infected_post(id)
{
ClearPlayerFastattack(id)
}
public zp_user_humanized_post(id)
{
ClearPlayerFastattack(id)
}
public fw_PlayerKilled(victim, attacker, shouldgib)
{
ClearPlayerFastattack(victim)
}
public zp_round_ended(winteam)
{
bitPlayerFastattack = 0
}
public client_connect(id)
{
ClearPlayerFastattack(id)
}
public client_disconnect(id)
{
ClearPlayerFastattack(id)
}
public fwd_Knife_PriAtk_Post(ent)
{
if (!get_pcvar_num(cvar_Primary))
return HAM_IGNORED;
static owner
owner = ham_cs_get_weapon_ent_owner(ent)
if (~IsPlayerFastattack(owner))
return HAM_IGNORED
static Float:Speed, Float:Primary, Float:Secondary
Speed = get_pcvar_float(cvar_PrimarySpeed)
Primary = get_pdata_float(ent, m_flNextPrimaryAttack, OFFSET_LINUX_WEAPONS) * Speed
Secondary = get_pdata_float(ent, m_flNextSecondaryAttack, OFFSET_LINUX_WEAPONS) * Speed
if (Primary > 0.0 && Secondary > 0.0)
{
set_pdata_float(ent, m_flNextPrimaryAttack, Primary, OFFSET_LINUX_WEAPONS)
set_pdata_float(ent, m_flNextSecondaryAttack, Secondary, OFFSET_LINUX_WEAPONS)
}
return HAM_IGNORED;
}
public fwd_Knife_SecAtk_Post(ent)
{
if (!get_pcvar_num(cvar_Secondary))
return HAM_IGNORED;
static owner
owner = ham_cs_get_weapon_ent_owner(ent)
if (~IsPlayerFastattack(owner))
return HAM_IGNORED
static Float:Speed, Float:Primary, Float:Secondary
Speed = get_pcvar_float(cvar_SecondarySpeed)
Primary = get_pdata_float(ent, m_flNextPrimaryAttack, OFFSET_LINUX_WEAPONS) * Speed
Secondary = get_pdata_float(ent, m_flNextSecondaryAttack, OFFSET_LINUX_WEAPONS) * Speed
if (Primary > 0.0 && Secondary > 0.0)
{
set_pdata_float(ent, m_flNextPrimaryAttack, Primary, OFFSET_LINUX_WEAPONS)
set_pdata_float(ent, m_flNextSecondaryAttack, Secondary, OFFSET_LINUX_WEAPONS)
}
return HAM_IGNORED;
}
public remove_fastattack(id)
{
ClearPlayerFastattack(id)
ColorChat(id, TEAM_COLOR, "^x01Your fast attack is over !!!")
}
public NewRound()
{
for (new id; id <= g_MaxPlayers; id++)
{
g_Limit[id] = 0
}
}
stock ham_cs_get_weapon_ent_owner(entity)
{
if (pev_valid(entity) != 2)
return 0;
return get_pdata_cbase(entity, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
}
|