Raised This Month: $ Target: $400
 0% 

[help] zp 4.3 armor item limit per round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 07-26-2014 , 23:54   Re: [help] zp 4.3 armor item limit per round
Reply With Quote #1

Just try below:
PHP 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 30

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

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

// Item IDs
new g_itemid_humanarmor
new g_has_humanarmor[33]

public 
plugin_precache()
{
    
precache_sound(g_sound_buyarmor)
}

public 
plugin_init()
{
    
register_plugin("[ZP] Extra: Anti-Infection Armor""1.0""MeRcyLeZZ")
    
    
g_itemid_humanarmor zp_register_extra_item(g_item_nameg_item_costZP_TEAM_HUMAN)
}

// Human buys our upgrade, give him some armor
public zp_extra_item_selected(playeritemid)
{
    if (
itemid == g_itemid_humanarmor)
    {
        if (
g_has_humanarmor[player])
        {
            
client_print(playerprint_chat"[ZP] You already have bought armor.")
            return 
ZP_PLUGIN_HANDLED;
        }
        
g_has_humanarmor[player] = true
        set_pev
(playerpev_armorvaluefloat(min(pev(playerpev_armorvalue)+g_armor_amountg_armor_limit)))
        
engfunc(EngFunc_EmitSoundplayerCHAN_BODYg_sound_buyarmor1.0ATTN_NORM0PITCH_NORM)
    }
    return 
PLUGIN_CONTINUE;

zmd94 is offline
NTARIS
Member
Join Date: Dec 2020
Location: Greece
Old 10-31-2021 , 07:40   Re: [help] zp 4.3 armor item limit per round
Reply With Quote #2

Here is the fix.
Zmd94 you know we are friend.Just the code above had wrong return id value making it bought once per map.
Here is the fix to limit it 1 per round for each player.

PHP 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 10

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

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

// Item IDs
new g_itemid_humanarmorg_PlayerArmor[33]
new 
g_Maxplayers

public plugin_precache()
{
    
precache_sound(g_sound_buyarmor)
}

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

public 
event_new_round()
{
    for(new 
ii<g_Maxplayersi++)
        
g_PlayerArmor[1] = false
}

// Human buys our upgrade, give him some armor
public zp_extra_item_selected(playeritemid)
{
    if (
itemid == g_itemid_humanarmor)
    {
        if (
g_PlayerArmor[1])
        {
            
client_print(playerprint_chat"[ZP] You already have bought armor.")
            return 
ZP_PLUGIN_HANDLED;
        }
set_pev(playerpev_armorvaluefloat(min(pev(playerpev_armorvalue)+g_armor_amountg_armor_limit)))
engfunc(EngFunc_EmitSoundplayerCHAN_BODYg_sound_buyarmor1.0ATTN_NORM0PITCH_NORM)
g_PlayerArmor[1] = true
    
}
    return 
PLUGIN_CONTINUE
__________________

Last edited by NTARIS; 10-31-2021 at 07:44.
NTARIS is offline
Reply



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:08.


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