[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_name, g_item_cost, ZP_TEAM_HUMAN)
}
// Human buys our upgrade, give him some armor
public zp_extra_item_selected(player, itemid)
{
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(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)
client_print(player, print_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(player, print_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)
}