View Single Post
Author Message
BerkayF
Junior Member
Join Date: Jun 2020
Old 07-16-2022 , 05:41   [ZP] Buy Limit Armor
Reply With Quote #1

[ZP] Buy Limit Armor

Hello guys
I'm Making an Armor Limit
I'm stuck somewhere
Current Problem: The problem is that the limit of players is not renewed when they move to the new round

Problem lines:
PHP Code:
public round_start()
{
    new 
players[32]
    
get_players(players)
    
    
g_armor_buy[players] = get_pcvar_num(cvar_armor_limit)


Full SMA:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>

/*================================================================================
 [Plugin Customization]
=================================================================================*/

new const g_item_name[] = { "Anti-Infection Armor" }
const 
g_item_cost 20                // Armor Cost

new const g_sound_buyarmor[] = { "items/tr_kevlar.wav" }
const 
g_armor_amount 100           // Armor Amount
const g_armor_limit 250            // Armor Limit
new g_armor_buy[33]                  // Armor Buy Limit
new cvar_armor_limit

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

// 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","round_start","a","1=0","2=0")
    
register_clcmd("reset_buy_armor_id""reset_buy_armor_id")
    
cvar_armor_limit register_cvar("zp_armor_limit""5")
    
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 (
g_armor_buy[player] <= get_pcvar_num(cvar_armor_limit) && g_armor_buy[player] != 0)
    {
    if (
itemid == g_itemid_humanarmor)
    {
        
g_armor_buy[player]--
        
set_pev(playerpev_armorvaluefloat(min(pev(playerpev_armorvalue)+g_armor_amountg_armor_limit)))
        
engfunc(EngFunc_EmitSoundplayerCHAN_BODYg_sound_buyarmor1.0ATTN_NORM0PITCH_NORM)
        
client_print(playerprint_chat"[ZP] Your remaining armor purchase limit: %d/%d"g_armor_buy[player], get_pcvar_num(cvar_armor_limit))
    }
    }
    
    if (
g_armor_buy[player] < 1)
    {
    if (
itemid == g_itemid_humanarmor)
    {
        
zp_set_user_ammo_packs(player,zp_get_user_ammo_packs(player) + g_item_cost);
        
client_print(playerprint_chat"[ZP] We have reached the armor purchase limit")
    }
    }
}

public 
round_start()
{
    new 
players[32]
    
get_players(players)
    
    
g_armor_buy[players] = get_pcvar_num(cvar_armor_limit)
}

public 
client_putinserver(player)
{
    
g_armor_buy[player] = get_pcvar_num(cvar_armor_limit)

Attached Files
File Type: sma Get Plugin or Get Source (zp_extra_armor.sma - 46 views - 2.7 KB)

Last edited by BerkayF; 07-16-2022 at 06:32. Reason: thank you to those who solved the problem
BerkayF is offline