AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   bio extra item set hp (https://forums.alliedmods.net/showthread.php?t=347379)

xAlecsu 04-21-2024 13:52

bio extra item set hp
 
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 }
*/


Dexon 04-22-2024 12:17

Re: bio extra item set hp
 
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 }
*/


xAlecsu 04-23-2024 15:57

Re: bio extra item set hp
 
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? .

Tote 04-23-2024 16:20

Re: bio extra item set hp
 
its bcz u've limited it to 200

Tote 04-23-2024 16:21

Re: bio extra item set hp
 
change this line:
set_armor( id, min( (get_armor( id ) + 50), 200) );
to this one:
set_armor(id, get_armor(id) + 50)

xAlecsu 04-23-2024 16:59

Re: bio extra item set hp
 
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.

Tote 04-24-2024 11:30

Re: bio extra item set hp
 
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;
}


xAlecsu 05-02-2024 18:14

Re: bio extra item set hp
 
ty i solved


All times are GMT -4. The time now is 21:56.

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