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

[ZP] Buy Limit Armor


Post New Thread Reply   
 
Thread Tools Display Modes
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 - 38 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
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-16-2022 , 11:48   Re: [ZP] Buy Limit Armor
Reply With Quote #2

PHP Code:
public round_start()
{
    static 
iPlayers[MAX_PLAYERS], iNum;
    
get_players(iPlayeriNum"ch");

    for(static 
iiPlayeriNumi++)
    {
        
iPlayer iPlayers[i];

        if(
is_user_alive(iPlayer))
            
g_armor_buy[players] = get_pcvar_num(cvar_armor_limit)
    }


Last edited by lexzor; 07-16-2022 at 11:48.
lexzor is offline
BerkayF
Junior Member
Join Date: Jun 2020
Old 07-16-2022 , 14:18   Re: [ZP] Buy Limit Armor
Reply With Quote #3

I'll try it right away

Quote:
Originally Posted by lexzor View Post
PHP Code:
public round_start()
{
    static 
iPlayers[MAX_PLAYERS], iNum;
    
get_players(iPlayeriNum"ch");

    for(static 
iiPlayeriNumi++)
    {
        
iPlayer iPlayers[i];

        if(
is_user_alive(iPlayer))
            
g_armor_buy[players] = get_pcvar_num(cvar_armor_limit)
    }

BerkayF is offline
BerkayF
Junior Member
Join Date: Jun 2020
Old 07-16-2022 , 14:26   Re: [ZP] Buy Limit Armor
Reply With Quote #4


This code has been tried now
but the error was encountered

Quote:
Originally Posted by lexzor View Post
PHP Code:
public round_start()
{
    static 
iPlayers[MAX_PLAYERS], iNum;
    
get_players(iPlayeriNum"ch");

    for(static 
iiPlayeriNumi++)
    {
        
iPlayer iPlayers[i];

        if(
is_user_alive(iPlayer))
            
g_armor_buy[players] = get_pcvar_num(cvar_armor_limit)
    }

Error:
Code:
77  public round_start()
78  {
79    static iPlayers[MAX_PLAYERS], iNum;
80    get_players(iPlayer, iNum, "ch");
81
82    for(static i, iPlayer; i < iNum; i++)
83    {
84        iPlayer = iPlayers[i];
85
86        if(is_user_alive(iPlayer))
87            g_armor_buy[players] = get_pcvar_num(cvar_armor_limit)
88     }
89  }

Last edited by BerkayF; 07-16-2022 at 14:31.
BerkayF is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-17-2022 , 07:20   Re: [ZP] Buy Limit Armor
Reply With Quote #5

PHP Code:
public round_start()
{
    static 
iPlayers[MAX_PLAYERS], iNum;
    
get_players(iPlayersiNum"ch");

    for(static 
iiPlayeriNumi++)
    {
        
iPlayer iPlayers[i];

        if(
is_user_alive(iPlayer))
            
g_armor_buy[iPlayer] = get_pcvar_num(cvar_armor_limit)
    }


Last edited by lexzor; 07-17-2022 at 09:53.
lexzor is offline
JUSTINR
Member
Join Date: May 2022
Old 07-17-2022 , 12:38   Re: [ZP] Buy Limit Armor
Reply With Quote #6

100% WORKING
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 = 15
new count[33]
new g_Maxplayers

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

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

// 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", "Event_NewRound", "a", "1=0", "2=0")
	g_itemid_humanarmor = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
	g_Maxplayers = get_maxplayers()
}

public Event_NewRound ( )
{
      for(new player;player<g_Maxplayers;player++)
      count[player]= 0;
}

// Human buys our upgrade, give him some armor
public zp_extra_item_selected(player, itemid)
{
	if (itemid == g_itemid_humanarmor)
	{
		if (count[player] >= 5)
    		{
        	client_print(player, print_chat, "You can buy this item only 5 times per Round")
        	return ZP_PLUGIN_HANDLED; //give ammo packs back
		}
		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)
		count[player]++
	} 	
	return PLUGIN_CONTINUE; 
}
JUSTINR is offline
BerkayF
Junior Member
Join Date: Jun 2020
Old 07-17-2022 , 13:11   Re: [ZP] Buy Limit Armor
Reply With Quote #7

You're amazing.
Thank you very much

Quote:
Originally Posted by JUSTINR View Post
100% WORKING
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 = 15
new count[33]
new g_Maxplayers

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

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

// 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", "Event_NewRound", "a", "1=0", "2=0")
	g_itemid_humanarmor = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
	g_Maxplayers = get_maxplayers()
}

public Event_NewRound ( )
{
      for(new player;player<g_Maxplayers;player++)
      count[player]= 0;
}

// Human buys our upgrade, give him some armor
public zp_extra_item_selected(player, itemid)
{
	if (itemid == g_itemid_humanarmor)
	{
		if (count[player] >= 5)
    		{
        	client_print(player, print_chat, "You can buy this item only 5 times per Round")
        	return ZP_PLUGIN_HANDLED; //give ammo packs back
		}
		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)
		count[player]++
	} 	
	return PLUGIN_CONTINUE; 
}
BerkayF 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 20:40.


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