Raised This Month: $12 Target: $400
 3% 

[help] zp 4.3 armor item limit per round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lSpira
Junior Member
Join Date: Dec 2013
Old 07-05-2014 , 16:21   [help] zp 4.3 armor item limit per round
Reply With Quote #1

Hi, Somebody can help me with a limit per round, if some player buy 200 armor cant buy more on the round, have to wait for a new round.

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

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)
    {
        
set_pev(playerpev_armorvaluefloat(min(pev(playerpev_armorvalue)+g_armor_amountg_armor_limit)))
        
engfunc(EngFunc_EmitSoundplayerCHAN_BODYg_sound_buyarmor1.0ATTN_NORM0PITCH_NORM)
    }

lSpira is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-05-2014 , 18:10   Re: [help] zp 4.3 armor item limit per round
Reply With Quote #2

Use bool. Set it to true when the player gets armor, and check if it's true in the next tries to get armor. And then you have to se the bool to false on new rouns event.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 07-05-2014 , 18:41   Re: [help] zp 4.3 armor item limit per round
Reply With Quote #3

Quote:
Originally Posted by Flick3rR View Post
Use bool. Set it to true when the player gets armor, and check if it's true in the next tries to get armor. And then you have to set the bool to false on new rouns event.
Thank you. However, may you show the steps? I'm still learning and would be glad if you like to show it.

Eitherwise, may you give any links that can help me to learn to do it?
zmd94 is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-05-2014 , 20:54   Re: [help] zp 4.3 armor item limit per round
Reply With Quote #4

I recommend that you search a zombieplague plugin which has such a limit feature and look how it is done there. Thats generally a good way to lern btw.
mottzi is offline
Send a message via MSN to mottzi
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 07-06-2014 , 00:07   Re: [help] zp 4.3 armor item limit per round
Reply With Quote #5

Quote:
Originally Posted by mottzi View Post
I recommend that you search a zombie plague plugin which has such a limit feature and look how it is done there. Thats generally a good way to learn btw.

Last edited by zmd94; 10-26-2014 at 00:21.
zmd94 is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 07-06-2014 , 07:28   Re: [help] zp 4.3 armor item limit per round
Reply With Quote #6

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
new bool:used[33];
/*============================================================================*/

// 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")
    
    
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");
}
public 
client_connect(id){
    
used[id] = true
}
public 
event_new_round(id){
    
used[id] = true
}
// Human buys our upgrade, give him some armor
public zp_extra_item_selected(playeritemid)
{
    if (
itemid == g_itemid_humanarmor && used[player])
    {
        
set_pev(playerpev_armorvaluefloat(min(pev(playerpev_armorvalue)+g_armor_amountg_armor_limit)))
        
engfunc(EngFunc_EmitSoundplayerCHAN_BODYg_sound_buyarmor1.0ATTN_NORM0PITCH_NORM)
        
used[player] = false
    
}

Freezo Begin is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-06-2014 , 07:35   Re: [help] zp 4.3 armor item limit per round
Reply With Quote #7

Wont the player loose money or ammo packs too when he doesnt get armor? I might be wrong sice I am not familiar with zombie plague...

Last edited by mottzi; 07-06-2014 at 07:35.
mottzi is offline
Send a message via MSN to mottzi
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 07-06-2014 , 09:37   Re: [help] zp 4.3 armor item limit per round
Reply With Quote #8

Quote:
Originally Posted by mottzi View Post
Won't the player loose money or ammo packs too when he doesn't get armor? I might be wrong since I am not familiar with zombie plague.
The player won't loose money or ammo packs. The armor is just as an extra item which a player can buy. When any humans bought it, the zombies need to destroy the armor first before they can infect the humans.
zmd94 is offline
lSpira
Junior Member
Join Date: Dec 2013
Old 07-26-2014 , 23:33   Re: [help] zp 4.3 armor item limit per round
Reply With Quote #9

When i buy armor item i cant buy in the next rounds, i only want a limit of armor per round

Example:

If i buy 200 armor and the Zombie attack me if i try to buy more armor i cant

that's i want
lSpira is offline
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 #10

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
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 09:24.


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