Raised This Month: $ Target: $400
 0% 

How give armor to player? [ZP]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rhyme
Member
Join Date: Aug 2010
Location: Russia (Moscow)
Old 08-20-2010 , 16:09   How give armor to player? [ZP]
Reply With Quote #1

help add to those who buy this item armor +500

PHP Code:
#include <amxmodx> 
#include <fakemeta> 
#include <engine> 
#include <hamsandwich> 
#include <zombieplague> 

const knifespeed_ap_cost 15 // Ap cast 

new Float:knifespeed_mins[3] = { -2.0, -2.0, -2.0 
new 
Float:knifespeed_maxs[3] = { 2.02.02.0 

new 
g_iItemIDg_msgCurWeapong_msgSayText 

// arrays 
new g_hasks[33], g_iCurrentWeapon[33

// cvars 
new cvar_enablecvar_oneroundcvar_dropflagscvar_pattack_ratecvar_sattack_rate 

// drop flags 
const DROPFLAG_INDEATH =    (1<<0// a - death victim 
const DROPFLAG_INFECTED =    (1<<1// b - drop in infected 
const DROPFLAG_SURVHUMAN =    (1<<2// c - drop become survivor 

// offset 
const m_pPlayer =         41 
const m_flNextPrimaryAttack =     46 
const m_flNextSecondaryAttack =    47 
const m_flTimeWeaponIdle =     48 

// Plug info. 
#define PLUG_VERSION "1.0" 
#define PLUG_AUTH "Rhyme" 

public plugin_init() 

    
// register plugin 
    
register_plugin("[ZP] Extra Item: Knife Speed"PLUG_VERSIONPLUG_AUTH
     
    
// events     
    
register_event("HLTV""event_RoundStart""a""1=0""2=0"
    
register_event("CurWeapon""event_CurWeapon""b""1=1"
     
    
// cvars 
    
cvar_enable register_cvar("zp_ks_enable""1"
    
cvar_oneround register_cvar("zp_ks_oneround""0"
    
cvar_dropflags register_cvar("zp_ks_dropflags""bcd"
    
cvar_pattack_rate register_cvar("zp_ks_attack1_rate""0.1"
    
cvar_sattack_rate register_cvar("zp_ks_attack2_rate""0.7"
     
    new 
szCvar[30
    
formatex(szCvarcharsmax(szCvar), "v%s by %s"PLUG_VERSIONPLUG_AUTH
    
register_cvar("zp_extra_knifespeed"szCvarFCVAR_SERVER|FCVAR_SPONLY
     
    
// engine forwards 
    
register_touch("cs_knifespeed""player""fw_Knifespeed_Touch"
     
    
// Ham Forwards 
    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn_Post"1
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled"
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""fw_Knife_PrimaryAttack_Post"1
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""fw_Knife_SecondaryAttack_Post"1
     
    
// Variables 
    
g_iItemID zp_register_extra_item("Knife Speed"knifespeed_ap_costZP_TEAM_HUMAN
     
    
// Message ID's vars 
    
g_msgSayText get_user_msgid("SayText"
    
g_msgCurWeapon get_user_msgid("CurWeapon"
     
    
// Client Commands 
    
register_clcmd("drop""clcmd_drop"


public 
plugin_precache() 

    
precache_sound("items/gunpickup2.wav"


public 
event_RoundStart() 

    
// Remove knifespeeds (entities) 
    
remove_entity_name("cs_knifespeed"


public 
event_CurWeapon(id

    
// Not alive... 
    
if(!is_user_alive(id)) 
        return 
PLUGIN_CONTINUE 
         
    
// Updating weapon array 
    
g_iCurrentWeapon[id] = read_data(2
     
    
// Check 
    
if(zp_get_user_zombie(id) || zp_get_user_survivor(id)) 
        return 
PLUGIN_CONTINUE 
         
    
// Has knifespeed and weapon is Knife 
    
if(!g_hasks[id] || g_iCurrentWeapon[id] != CSW_KNIFE)  
        return 
PLUGIN_CONTINUE 
         
    
return PLUGIN_CONTINUE 


/*================================================================================ 
 [Main Functions] 
=================================================================================*/ 

public drop_knifespeed(id)  

    
// Get Aim and Origin 
    
static Float:flAim[3], Float:flOrigin[3
    
VelocityByAim(id64flAim
    
entity_get_vector(idEV_VEC_originflOrigin
     
    
// Changing Origin coords 
    
flOrigin[0] += flAim[0
    
flOrigin[1] += flAim[1
     
    
// Creating the Entity 
    
new iEnt create_entity("info_target"
     
    
// Classname 
    
entity_set_string(iEntEV_SZ_classname"cs_knifespeed"
     
    
// Origin 
    
entity_set_origin(iEntflOrigin
     
    
// Size 
    
set_size(iEntknifespeed_minsknifespeed_maxs
    
entity_set_vector(iEntEV_VEC_minsknifespeed_mins
    
entity_set_vector(iEntEV_VEC_maxsknifespeed_maxs
     
    
// Solid Type 
    
entity_set_int(iEntEV_INT_solidSOLID_TRIGGER
     
    
// Movetype 
    
entity_set_int(iEntEV_INT_movetypeMOVETYPE_TOSS
     
    
// Var's 
    
g_hasks[id] = false 
     
    
// Model bugfix 
    
reset_user_knife(id


public 
reset_user_knife(id

    
// Execute weapon Deploy 
    
if(user_has_weapon(idCSW_KNIFE)) 
        
ExecuteHamB(Ham_Item_Deployfind_ent_by_owner(-1"weapon_knife"id)) 
         
    
// Updating Model 
    
engclient_cmd(id"weapon_knife"
    
emessage_begin(MSG_ONEg_msgCurWeapon_id
    
ewrite_byte(1// active 
    
ewrite_byte(CSW_KNIFE// weapon 
    
ewrite_byte(-1// clip 
    
emessage_end() 


/*================================================================================ 
 [ZombiePlague Forwards] 
=================================================================================*/ 

public zp_extra_item_selected(iditemid

    if (
itemid == g_iItemID
    { 
        
// Check cvar 
        
if(get_pcvar_num(cvar_enable)) 
        { 
            
// Already has a KnifeSpeed 
            
if (g_hasks[id]) 
            { 
                
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) + knifespeed_ap_cost
                
client_printcolor(id"/g[ZP]/y You already have a /gKnife Speed"
            } 
            else  
            { 
                
// Boolean 
                
g_hasks[id] = true 
                 
                
// Emiting Sound 
                
emit_sound(idCHAN_WEAPON"items/gunpickup2.wav"1.0ATTN_NORM0PITCH_NORM
                 
                
// Client Print 
                
client_printcolor(id"/g[ZP]/y You now have a /gKnife Speed"
                 
                
// Change weapon to Knife 
                
reset_user_knife(id
            } 
        } 
        
// Isn't enabled... 
        
else 
        { 
            
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) + knifespeed_ap_cost
            
client_printcolor(id"/g[ZP]/y Knife Speed item has been disabled. /gContact Admin"
        } 
    } 


public 
zp_user_infected_pre(idinfector

    
// Drop in infection 
    
if (g_hasks[id]) 
    { 
        if(
check_drop_flag(DROPFLAG_INFECTED)) 
            
drop_knifespeed(id
        else 
        { 
            
g_hasks[id] = false 
            reset_user_knife
(id
        } 
    } 


public 
zp_user_humanized_post(id

    
// Is survivor 
    
if(zp_get_user_survivor(id) && g_hasks[id]) 
    { 
        if(
check_drop_flag(DROPFLAG_SURVHUMAN)) 
            
drop_knifespeed(id
        else 
        { 
            
g_hasks[id] = false 
            reset_user_knife
(id
        } 
    } 


/*================================================================================ 
 [Main Forwards] 
=================================================================================*/ 

public client_putinserver(id

    
g_hasks[id] = false 


public 
client_disconnect(id

    
g_hasks[id] = false 

     
public 
fw_PlayerSpawn_Post(id

    
// Check Oneround Cvar and Strip all the KnifeSpeeds 
    
if(get_pcvar_num(cvar_oneround) || !get_pcvar_num(cvar_enable)) 
    { 
        
// Has KnifeSpeed 
        
if(g_hasks[id]) 
        { 
            
// Var's 
            
g_hasks[id] = false 

            
// Update Knife 
            
reset_user_knife(id
        } 
    } 


public 
fw_PlayerKilled(victimattackershouldgib

    
// Check 
    
if(victim == attacker || !attacker
        return 
HAM_IGNORED 
         
    
// Attacker is not a Player 
    
if(!is_user_connected(attacker)) 
        return 
HAM_IGNORED 
         
    
// Attacker Has a KnifeSpeed 
    
if(g_hasks[attacker] && g_iCurrentWeapon[attacker] == CSW_KNIFE && !zp_get_user_nemesis(victim)) 
     
    
// Victim Has a KnifeSpeed 
    
if(g_hasks[victim]) 
    { 
        if(
check_drop_flag(DROPFLAG_INDEATH)) 
            
drop_knifespeed(victim
        else 
        { 
            
g_hasks[victim] = false 
            reset_user_knife
(victim
        } 
    } 
     
    return 
HAM_IGNORED 


public 
fw_Knifespeed_Touch(sawplayer

    
// Entities are not valid 
    
if(!is_valid_ent(saw) || !is_valid_ent(player)) 
        return 
PLUGIN_CONTINUE 
         
    
// Is a valid player? 
    
if(!is_user_connected(player)) 
        return 
PLUGIN_CONTINUE 
         
    
// Alive, Zombie or Survivor 
    
if(!is_user_alive(player) || zp_get_user_zombie(player) || zp_get_user_survivor(player) || g_hasks[player]) 
        return 
PLUGIN_CONTINUE 
         
    
// Var's 
    
g_hasks[player] = true 
     
    
// Emiting Sound 
    
emit_sound(playerCHAN_WEAPON"items/gunpickup2.wav"1.0ATTN_NORM0PITCH_NORM
     
    
// Knife Deploy 
    
reset_user_knife(player
     
    
// Remove dropped KnifeSpeed 
    
remove_entity(saw
         
    return 
PLUGIN_CONTINUE 


public 
fw_Knife_PrimaryAttack_Post(knife
{     
    
// Get knife owner 
    
static id 
    id 
get_pdata_cbase(knifem_pPlayer4
     
    
// has a KnifeSpeed 
    
if(is_user_connected(id) && g_hasks[id]) 
    { 
        
// Get new fire rate 
        
static Float:flRate 
        flRate 
get_pcvar_float(cvar_pattack_rate
         
        
// Set new rates 
        
set_pdata_float(knifem_flNextPrimaryAttackflRate4
        
set_pdata_float(knifem_flNextSecondaryAttackflRate4
        
set_pdata_float(knifem_flTimeWeaponIdleflRate4
         
    } 
     
    return 
HAM_IGNORED 


public 
fw_Knife_SecondaryAttack_Post(knife
{     
    
// Get knife owner 
    
static id 
    id 
get_pdata_cbase(knifem_pPlayer4
     
    
// has a KnifeSpeed 
    
if(is_user_connected(id) && g_hasks[id]) 
    { 
        
// Get new fire rate 
        
static Float:flRate 
        flRate 
get_pcvar_float(cvar_sattack_rate
         
        
// Set new rates 
        
set_pdata_float(knifem_flNextPrimaryAttackflRate4
        
set_pdata_float(knifem_flNextSecondaryAttackflRate4
        
set_pdata_float(knifem_flTimeWeaponIdleflRate4
    } 
     
    return 
HAM_IGNORED 



check_drop_flag(flag

    new 
szFlags[10
    
get_pcvar_string(cvar_dropflagsszFlagscharsmax(szFlags)) 
     
    if(
read_flags(szFlags) & flag
        return 
true 
         
    
return false 


stock client_printcolor(const id, const input[], any:...) 

    new 
iCount 1iPlayers[32
     
    static 
szMsg[191
    
vformat(szMsgcharsmax(szMsg), input3
     
    
replace_all(szMsg190"/g""^4"// green txt 
    
replace_all(szMsg190"/y""^1"// orange txt 
    
replace_all(szMsg190"/ctr""^3"// team txt 
    
replace_all(szMsg190"/w""^0"// team txt 
     
    
if(idiPlayers[0] = id 
    
else get_players(iPlayersiCount"ch"
         
    for (new 
0iCounti++) 
    { 
        if (
is_user_connected(iPlayers[i])) 
        { 
            
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_iPlayers[i]) 
            
write_byte(iPlayers[i]) 
            
write_string(szMsg
            
message_end() 
        } 
    } 

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE 
*{\\ rtf1\\ ansi\\ ansicpg1251\\ deff0\\ deflang1049{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par } 
*/ 
Rhyme is offline
Send a message via ICQ to Rhyme Send a message via Skype™ to Rhyme
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 08-20-2010 , 16:12   Re: How give armor to player? [ZP]
Reply With Quote #2

There's something called stick to one thread.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Vechta
Veteran Member
Join Date: Jun 2010
Old 08-21-2010 , 02:27   Re: How give armor to player? [ZP]
Reply With Quote #3

PHP Code:
#include fun 
and
PHP Code:
                else   
                {  
                        
// Boolean  
                        
g_hasks[id] = true  
                  
                        
// Emiting Sound  
                        
emit_sound(idCHAN_WEAPON"items/gunpickup2.wav"1.0ATTN_NORM0PITCH_NORM)  
                  
                         
// Client Print  
                        
client_printcolor(id"/g[ZP]/y You now have a /gKnife Speed")  
                  
                        
// Change weapon to Knife  
                        
reset_user_knife(id)  
 
                        
set_user_armor(idget_user_armor(id) + 500)
            } 
Vechta is offline
Rhyme
Member
Join Date: Aug 2010
Location: Russia (Moscow)
Old 08-23-2010 , 03:43   Re: How give armor to player? [ZP]
Reply With Quote #4

thanks
Rhyme is offline
Send a message via ICQ to Rhyme Send a message via Skype™ to Rhyme
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:57.


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