View Single Post
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-11-2021 , 01:32   Re: Max Player Armor
Reply With Quote #3

Quote:
Originally Posted by Black Rose View Post
You can use zp_extra_item_selected() to hook the purchase. Make your checks, for example:
if ( get_user_armor(id) + g_armor_amount > g_armor_limit ) // If you want to block buying at 101-200 armor.
if ( get_user_armor(id) >= g_armor_limit ) // If you want to enable buying at 101-200.

returning ZP_PLUGIN_HANDLED will cancel the purchase and return the money.

If you choose the second, don't forget to use clamp() on the buy forward later to prevent it from going over 200.
clamp(get_user_armor(id)+g_armor_amount, 0, g_armor_limit);

For the 600 limit, add upp the g_armor_amount for every player in a global variable that you clear each round start/end.
I bet i did it wrong as you thought , but works for me, thanks. ;D
PHP Code:
if ( get_user_armor(player) >= g_armor_limit ) {
        
clamp(get_user_armor(player)+g_armor_amount0g_armor_limit);
        return 
ZP_PLUGIN_HANDLED
        
}
        else 
HowToRuski is offline