AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [help] zp 4.3 armor item limit per round (https://forums.alliedmods.net/showthread.php?t=243513)

lSpira 07-05-2014 16:21

[help] zp 4.3 armor item limit per round
 
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)
    }



Flick3rR 07-05-2014 18:10

Re: [help] zp 4.3 armor item limit per round
 
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.

zmd94 07-05-2014 18:41

Re: [help] zp 4.3 armor item limit per round
 
Quote:

Originally Posted by Flick3rR (Post 2162577)
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?

mottzi 07-05-2014 20:54

Re: [help] zp 4.3 armor item limit per round
 
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.

zmd94 07-06-2014 00:07

Re: [help] zp 4.3 armor item limit per round
 
Quote:

Originally Posted by mottzi (Post 2162639)
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.

:wink:

Freezo Begin 07-06-2014 07:28

Re: [help] zp 4.3 armor item limit per 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
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
    
}



mottzi 07-06-2014 07:35

Re: [help] zp 4.3 armor item limit per round
 
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...

zmd94 07-06-2014 09:37

Re: [help] zp 4.3 armor item limit per round
 
Quote:

Originally Posted by mottzi (Post 2162829)
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.

lSpira 07-26-2014 23:33

Re: [help] zp 4.3 armor item limit per round
 
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

zmd94 07-26-2014 23:54

Re: [help] zp 4.3 armor item limit per round
 
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;




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

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