This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

bio extra item set hp


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xAlecsu
Junior Member
Join Date: Apr 2024
Old 04-21-2024 , 13:52   bio extra item set hp
Reply With Quote #1

Hello ,i have a little problem with my plugin .when the player already have 200 hp and buy again hp he keeps losing money but his life does not increase.

I don't want to lose money more than 200 hp

Code:
#include <amxmodx>
#include <fun>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <biohazard>
#include <bio_shop>
#include <hamsandwich> 
#include <fakemeta_util>

new const item_name[] = "Extra Armour"
new g_itemid_buyhp
#define get_money(%1)   (cs_get_user_money(%1))
#define set_money(%1,%2)    (cs_set_user_money(%1,%2))
#define is_human(%1)    (!is_user_zombie(%1))
#define get_armor(%1)   (get_user_armor(%1))
#define set_armor(%1,%2)    (set_user_armor(%1,%2))

public plugin_init() 
{
    register_plugin("[ZP] Buy Health Points", "1.0", "T[h]E Dis[as]teR")
    g_itemid_buyhp = bio_register_item(item_name, 200, "+50 AP",TEAM_HUMAN)
    
}
public bio_item_selected(id,itemid)
{
        if( is_user_alive( id ) || itemid==g_itemid_buyhp ) {
        if( is_human( id ) ) {
            money = get_money( id ) - 200;
            if( money < 0 ) { Color( id, "!4[Biohazard Shop] !1N-ai bani !! Necesari:!3 2000 $ !1!" ); return 1; } else
            if( get_armor( id ) < 200 ) {
                set_armor( id, min( (get_armor( id ) + 50), 200) );
                set_money( id, money );
                Color( id, "!4[Biohazard Shop] !1Ai cumparat!3 50 Armura !1!" );
            } else Color( id, "!4[Biohazard Shop]!1 Ai Armura Maxim !" );
        } else Color( id, "!4[Biohazard Shop]!1 Doar !3Human !1pot cumpara !" );
        } else Color( id, "!4[Biohazard Shop] !1Trebuie sa fi in viata sa cumperi!3 50 Armura !1!" );
    return PLUGIN_CONTINUE;
}

stock Color( const id, const input[ ], any:... ) {
    new count = 1, players[ 32 ];
    static msg[ 191 ]; vformat( msg, 190, input, 3 );
    replace_all( msg, 190, "!4", "^4" );
    replace_all( msg, 190, "!1", "^1" );
    replace_all( msg, 190, "!3", "^3" );
    replace_all( msg, 190, "!0", "^0" );
    if( id ) players[ 0 ] = id; else get_players( players, count, "ch" ); {
        for( new i = 0; i < count; i++ ) {
            if( is_user_connected( players[ i ] ) ) {
                message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
                write_byte( players[ i ] );
                write_string( msg );
                message_end( );
            }
        }
    }
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/

Last edited by xAlecsu; Yesterday at 18:15. Reason: solved
xAlecsu is offline
Dexon
Member
Join Date: Aug 2019
Old 04-22-2024 , 12:17   Re: bio extra item set hp
Reply With Quote #2

This code is completely and intentionally about giving armour, not about giving health for money.
For health:

Code:
#include <amxmodx>
#include <fun>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <biohazard>
#include <bio_shop>
#include <hamsandwich> 
#include <fakemeta_util>

new const item_name[] = "Extra Armour"
new g_itemid_buyhp
#define get_money(%1)   (cs_get_user_money(%1))
#define set_money(%1,%2)    (cs_set_user_money(%1,%2))
#define is_human(%1)    (!is_user_zombie(%1))
#define get_armor(%1)   (get_user_health(%1))
#define set_armor(%1,%2)    (set_user_health(%1,%2))

public plugin_init() 
{
    register_plugin("[ZP] Buy Health Points", "1.0", "T[h]E Dis[as]teR")
    g_itemid_buyhp = bio_register_item(item_name, 200, "+50 AP",TEAM_HUMAN)
    
}
public bio_item_selected(id,itemid)
{
        if( is_user_alive( id ) || itemid==g_itemid_buyhp ) {
        if( is_human( id ) ) {
            money = get_money( id ) - 200;
            if( money < 0 ) { Color( id, "!4[Biohazard Shop] !1N-ai bani !! Necesari:!3 2000 $ !1!" ); return 1; } else
            if( get_armor( id ) < 200 ) {
                set_armor( id, min( (get_armor( id ) + 50), 200) );
                set_money( id, money );
                Color( id, "!4[Biohazard Shop] !1Ai cumparat!3 50 Armura !1!" );
            } else Color( id, "!4[Biohazard Shop]!1 Ai Armura Maxim !" );
        } else Color( id, "!4[Biohazard Shop]!1 Doar !3Human !1pot cumpara !" );
        } else Color( id, "!4[Biohazard Shop] !1Trebuie sa fi in viata sa cumperi!3 50 Armura !1!" );
    return PLUGIN_CONTINUE;
}

stock Color( const id, const input[ ], any:... ) {
    new count = 1, players[ 32 ];
    static msg[ 191 ]; vformat( msg, 190, input, 3 );
    replace_all( msg, 190, "!4", "^4" );
    replace_all( msg, 190, "!1", "^1" );
    replace_all( msg, 190, "!3", "^3" );
    replace_all( msg, 190, "!0", "^0" );
    if( id ) players[ 0 ] = id; else get_players( players, count, "ch" ); {
        for( new i = 0; i < count; i++ ) {
            if( is_user_connected( players[ i ] ) ) {
                message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
                write_byte( players[ i ] );
                write_string( msg );
                message_end( );
            }
        }
    }
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/
__________________
[ExTasY] Furien Hero [CRAFT SYSTEM]
213.181.206.21:27140

[ExTasY] Zombie Mutation [ZOMBIE NPC]
213.181.206.28:27057

Join now!

Video: https://www.youtube.com/watch?v=fNahCsS8DOU&t=328s
DC: https://discord.gg/swARTUZCZ4

Creating private plugins, reference above.

Last edited by Dexon; 04-22-2024 at 12:17.
Dexon is offline
xAlecsu
Junior Member
Join Date: Apr 2024
Old 04-23-2024 , 15:57   Re: bio extra item set hp
Reply With Quote #3

sry ,that script it's for armour .but i have same script for health .
and what you edit it's same for armour not for health

1 question what did you change to my script? .

Last edited by xAlecsu; 04-23-2024 at 15:59.
xAlecsu is offline
Tote
Senior Member
Join Date: Jul 2023
Old 04-23-2024 , 16:20   Re: bio extra item set hp
Reply With Quote #4

its bcz u've limited it to 200
Tote is offline
Tote
Senior Member
Join Date: Jul 2023
Old 04-23-2024 , 16:21   Re: bio extra item set hp
Reply With Quote #5

change this line:
set_armor( id, min( (get_armor( id ) + 50), 200) );
to this one:
set_armor(id, get_armor(id) + 50)
Tote is offline
xAlecsu
Junior Member
Join Date: Apr 2024
Old 04-23-2024 , 16:59   Re: bio extra item set hp
Reply With Quote #6

Yes i put a limit for armour and hp/armour .But when the limit is reached and i try to buy again hp/armour i lose the money and hp/armour don't increase. I don't want to lose more money when the hp/armour limit it's reached.

Last edited by xAlecsu; 04-23-2024 at 17:01.
xAlecsu is offline
Tote
Senior Member
Join Date: Jul 2023
Old 04-24-2024 , 11:30   Re: bio extra item set hp
Reply With Quote #7

Code:
#include <amxmodx>
#include <cstrike>
#include <fun>

new const item_name[] = "Extra Armour"
#define tag "BIOHAZARD SHOP"
new g_itemid_buyhp

new price_hp

public plugin_init() 
{
	register_plugin("[ZP] Buy Health Points", "1.0", "T[h]E Dis[as]teR/Tote edit")
	g_itemid_buyhp = bio_register_item(item_name, 200, "+50 AP",TEAM_HUMAN)
	price_hp = register_cvar("bio_hp_price", "2000")
	
}

public bio_item_selected(id, itemid) {
	if(is_user_alive(id) || itemid == g_itemid_buyhp) {
		if(!is_user_zombie(id)) {
			if(cs_get_user_money(id) >= get_pcvar_num(price_hp)) {
				if(get_user_armor(id) <= 200) {
					set_user_armor(id, min((get_user_armor(id) + 50), 200));
					cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(price_hp))
					client_print_color(id, 0, "^4[%s]^3 You've successfully purchased + 50 ARMOR^4!", tag)
				} else {
					client_print_color(id, 0, "^4[%s]^3 Sorry, you already have 200 or less than 200 armor^4!", tag)
					return PLUGIN_HANDLED;
				}
			} else {
				client_print_color(id, 0, "^4[%s]^3 You don't have enough money to buy this item! You need: %d$", tag, get_pcvar_num(price_hp))
				return PLUGIN_HANDLED;
			}
		} else {
			client_print_color(id, 0, "^4[%s]^3 You need to be human in order to purchase this item!",tag)
			return PLUGIN_HANDLED;
		}
	}
	return PLUGIN_HANDLED;
}

Last edited by Tote; 04-24-2024 at 11:30.
Tote is offline
xAlecsu
Junior Member
Join Date: Apr 2024
Old Yesterday , 18:14   Re: bio extra item set hp
Reply With Quote #8

ty i solved
xAlecsu 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 13:39.


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