AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   Subplugin Submission [ZP5.0] Extra Item: Fast Attack (https://forums.alliedmods.net/showthread.php?t=223350)

wicho 08-12-2013 13:07

[ZP5.0] Extra Item: Fast Attack
 
1 Attachment(s)
[ZP5.0] Fast Attack

-Description-

With this extra item you can attack fast with knife for some time (can be edited by Cvar).

Default Team : Zombies
Default Price : 10 Ammo Packs

-Credits-

Especial thanks to:

MeRcyLeZZ - For his awesome Zombie Plague mod.
schmurgel1983 - For his Executioner Zombie.
H.RED.ZONE - For help me to convert the bools to bitsums.

-Cvars-

-zp_fastattack_pri 1 // Allow faster primary attack (slash) [0-disabled / 1-enabled]
-zp_fastattack_pri_speed 0.33 // primary attack speed (0.5 = reduces attack speed by a half)
-zp_fastattack_sec 1 // Allow faster secondary attack (stab) [0-disabled / 1-enabled]
-zp_fastattack_sec_speed 0.33 // secondary attack speed (0.5 = reduces attack speed by a half)
-zp_fastattack_time 5.0 // Time of fast attack
-zp_fastattack_limit 3 // per round limit

This is my first plugin I post in the forum I hope you enjoy..

Cigojlo 08-12-2013 16:27

Re: [ZP5.0] Extra Item: Fast Attack
 
hm
#define AUTHOR "schmurgel1983, wicho"

wicho 08-12-2013 16:34

Re: [ZP5.0] Extra Item: Fast Attack
 
I already changed it..

Catastrophe 08-13-2013 04:27

Re: [ZP5.0] Extra Item: Fast Attack
 
Seems nice..... Gj BTW i think this is your first plugin so it's good for that :)

Egan 08-13-2013 10:34

Re: [ZP5.0] Extra Item: Fast Attack
 
shh dont talk in here cat

Catastrophe 08-13-2013 11:33

Re: [ZP5.0] Extra Item: Fast Attack
 
Quote:

Originally Posted by Egan (Post 2012156)
shh dont talk in here cat

Lol you're everywhere xD

BLacking98 08-31-2013 10:20

Re: [ZP5.0] Extra Item: Fast Attack
 
bump

Can you make this for Zombie Plague 4.3 ?

wicho 08-31-2013 13:28

Re: [ZP5.0] Extra Item: Fast Attack
 
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_Primarycvar_PrimarySpeedcvar_Secondarycvar_SecondarySpeed  
new cvar_Fastattack_time 
new cvar_Fastattack_limit
new g_Limit[33]
new 
g_MaxPlayers

const COST 10

public plugin_init() 
{   
    
register_plugin(PLUGINVERSIONAUTHOR)    
    
    
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"COSTZP_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(idprint_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(idTEAM_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(victimattackershouldgib
{   
    
ClearPlayerFastattack(victim
}   

public 
zp_round_ended(winteam
{   
    
bitPlayerFastattack 
}   

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:SpeedFloat:PrimaryFloat:Secondary   
     
    Speed 
get_pcvar_float(cvar_PrimarySpeed)   
    
Primary get_pdata_float(entm_flNextPrimaryAttackOFFSET_LINUX_WEAPONS) * Speed   
    Secondary 
get_pdata_float(entm_flNextSecondaryAttackOFFSET_LINUX_WEAPONS) * Speed   
       
    
if (Primary 0.0 && Secondary 0.0
    {   
        
set_pdata_float(entm_flNextPrimaryAttackPrimaryOFFSET_LINUX_WEAPONS)   
        
set_pdata_float(entm_flNextSecondaryAttackSecondaryOFFSET_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:SpeedFloat:PrimaryFloat:Secondary   
     
    Speed 
get_pcvar_float(cvar_SecondarySpeed)   
    
Primary get_pdata_float(entm_flNextPrimaryAttackOFFSET_LINUX_WEAPONS) * Speed   
    Secondary 
get_pdata_float(entm_flNextSecondaryAttackOFFSET_LINUX_WEAPONS) * Speed   
       
    
if (Primary 0.0 && Secondary 0.0
    {   
        
set_pdata_float(entm_flNextPrimaryAttackPrimaryOFFSET_LINUX_WEAPONS)   
        
set_pdata_float(entm_flNextSecondaryAttackSecondaryOFFSET_LINUX_WEAPONS)   
    }   
    return 
HAM_IGNORED;   
}   

public 
remove_fastattack(id
{   
    
ClearPlayerFastattack(id
    
ColorChat(idTEAM_COLOR"^x01Your fast attack is over !!!")   
}  

public 
NewRound() 
{   
    for (new 
idid <= g_MaxPlayersid++) 
    {                     
        
g_Limit[id] = 0
    
}
}  

stock ham_cs_get_weapon_ent_owner(entity
{   
    if (
pev_valid(entity) != 2)   
        return 
0;   
       
    return 
get_pdata_cbase(entityOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS);   



BLacking98 08-31-2013 13:51

Re: [ZP5.0] Extra Item: Fast Attack
 
Quote:

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_Primarycvar_PrimarySpeedcvar_Secondarycvar_SecondarySpeed  
new cvar_Fastattack_time 
new cvar_Fastattack_limit
new g_Limit[33]
new 
g_MaxPlayers

const COST 10

public plugin_init() 
{   
    
register_plugin(PLUGINVERSIONAUTHOR)    
    
    
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"COSTZP_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(idprint_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(idTEAM_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(victimattackershouldgib
{   
    
ClearPlayerFastattack(victim
}   

public 
zp_round_ended(winteam
{   
    
bitPlayerFastattack 
}   

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:SpeedFloat:PrimaryFloat:Secondary   
     
    Speed 
get_pcvar_float(cvar_PrimarySpeed)   
    
Primary get_pdata_float(entm_flNextPrimaryAttackOFFSET_LINUX_WEAPONS) * Speed   
    Secondary 
get_pdata_float(entm_flNextSecondaryAttackOFFSET_LINUX_WEAPONS) * Speed   
       
    
if (Primary 0.0 && Secondary 0.0
    {   
        
set_pdata_float(entm_flNextPrimaryAttackPrimaryOFFSET_LINUX_WEAPONS)   
        
set_pdata_float(entm_flNextSecondaryAttackSecondaryOFFSET_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:SpeedFloat:PrimaryFloat:Secondary   
     
    Speed 
get_pcvar_float(cvar_SecondarySpeed)   
    
Primary get_pdata_float(entm_flNextPrimaryAttackOFFSET_LINUX_WEAPONS) * Speed   
    Secondary 
get_pdata_float(entm_flNextSecondaryAttackOFFSET_LINUX_WEAPONS) * Speed   
       
    
if (Primary 0.0 && Secondary 0.0
    {   
        
set_pdata_float(entm_flNextPrimaryAttackPrimaryOFFSET_LINUX_WEAPONS)   
        
set_pdata_float(entm_flNextSecondaryAttackSecondaryOFFSET_LINUX_WEAPONS)   
    }   
    return 
HAM_IGNORED;   
}   

public 
remove_fastattack(id
{   
    
ClearPlayerFastattack(id
    
ColorChat(idTEAM_COLOR"^x01Your fast attack is over !!!")   
}  

public 
NewRound() 
{   
    for (new 
idid <= g_MaxPlayersid++) 
    {                     
        
g_Limit[id] = 0
    
}
}  

stock ham_cs_get_weapon_ent_owner(entity
{   
    if (
pev_valid(entity) != 2)   
        return 
0;   
       
    return 
get_pdata_cbase(entityOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS);   



Gnna try it out in a few days because im on my phone


All times are GMT -4. The time now is 14:43.

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