View Single Post
JUSTINR
Member
Join Date: May 2022
Old 07-17-2022 , 12:38   Re: [ZP] Buy Limit Armor
Reply With Quote #6

100% WORKING
Code:
/*================================================================================
	
	-------------------------------------------------
	-*- [ZP] Extra Item: Anti-Infection Armor 1.0 -*-
	-------------------------------------------------
	
	~~~~~~~~~~~~~~~
	- Description -
	~~~~~~~~~~~~~~~
	
	This item gives humans some armor that offers protection
	against zombie injuries.
	
================================================================================*/

#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
/*================================================================================
 [Plugin Customization]
=================================================================================*/

new const g_item_name[] = { "Anti-Infection armor" }
const g_item_cost = 15
new count[33]
new g_Maxplayers

new const g_sound_buyarmor[] = { "items/tr_kevlar.wav" }
const g_armor_amount = 100
const g_armor_limit = 800

/*============================================================================*/

// Item IDs
new g_itemid_humanarmor

public plugin_precache()
{
	precache_sound(g_sound_buyarmor)
}

public plugin_init()
{
	register_plugin("[ZP] Extra: Anti-Infection Armor", "1.0", "MeRcyLeZZ")
	register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
	g_itemid_humanarmor = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
	g_Maxplayers = get_maxplayers()
}

public Event_NewRound ( )
{
      for(new player;player<g_Maxplayers;player++)
      count[player]= 0;
}

// Human buys our upgrade, give him some armor
public zp_extra_item_selected(player, itemid)
{
	if (itemid == g_itemid_humanarmor)
	{
		if (count[player] >= 5)
    		{
        	client_print(player, print_chat, "You can buy this item only 5 times per Round")
        	return ZP_PLUGIN_HANDLED; //give ammo packs back
		}
		set_pev(player, pev_armorvalue, float(min(pev(player, pev_armorvalue)+g_armor_amount, g_armor_limit)))
		engfunc(EngFunc_EmitSound, player, CHAN_BODY, g_sound_buyarmor, 1.0, ATTN_NORM, 0, PITCH_NORM)
		count[player]++
	} 	
	return PLUGIN_CONTINUE; 
}
JUSTINR is offline