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

Solved Health shop [ ONLY FOR CT ]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pizzadaking
Member
Join Date: Oct 2019
Old 04-02-2020 , 16:42   Health shop [ ONLY FOR CT ]
Reply With Quote #1

So i found this health shop here in alliedmodders i edited the hp amount u can buy and the price to the one i wanted , what i want help with is to make this shop only available for CT , cause i have a basebuilder server and i dont want zombies to be able to buy HP.
Thanks

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Health Shop"
#define VERSION "1.0"
#define AUTHOR "ZaCkY"

#define FM_MONEY_OFFSET 115

new health50[200]
new 
health100[200]
new 
health200[200]
new 
health250[200]


new 
cost_50hp,cost_100hpcost_200hpcost_250hp

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /hpshop""show_menu_buy_hp")
    
register_clcmd("say_team /hpshop""show_menu_buy_hp")
    
    
register_logevent("Event_Round_Start"2"1=Round_Start")
    
    
cost_50hp register_cvar("hs_50hp_cost""1500")
    
cost_100hp register_cvar("hs_100hp_cost""2700")
    
cost_200hp register_cvar("hs_200hp_cost""4200")
    
cost_250hp register_cvar("hs_250hp_cost""5500")
}

public 
show_menu_buy_hp(id)
{
    new 
menu menu_create("\r VIP \yHealth Shop""handle_buy_hp_menu")
    
    
formatex(health50199"+50 Health - $%d"get_pcvar_num(cost_50hp))
    
menu_additem(menuhealth50"1")
    
formatex(health100199"+100 Health - $%d"get_pcvar_num(cost_100hp))
    
menu_additem(menuhealth100"2")
        
formatex(health200199"+200 Health - $%d"get_pcvar_num(cost_200hp))
    
menu_additem(menuhealth200"3")
    
formatex(health250199"+250 Health - $%d"get_pcvar_num(cost_250hp))
    
menu_additem(menuhealth250"4")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
handle_buy_hp_menu(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
Data[6];
    new 
Access;
    new 
Callback;
    new 
Name[64];
    
menu_item_getinfo(menuitemAccessData5Name63Callback)
    
    new 
Key str_to_num(Data);
    
    switch (
Key)
    {
        case 
1:
        {
            if (!
is_user_alive(id))
            {
                
client_print(idprint_chat"You Have To Be Alive To Buy Health")
                return 
PLUGIN_HANDLED
            
}
            
            new 
Money fm_get_user_money(id)
            new 
Pcvar get_pcvar_num(cost_50hp)
            new 
Health get_user_health(id)
            
            if (
Money Pcvar)
            {
                
client_print(idprint_chat"You don't have enough money to buy this")
            }
            else
            {
                
client_print(idprint_chat"You just purchared +50 HP")
                
fm_set_user_money(idMoney-Pcvar)
                
fm_set_user_health (idHealth+50)
            }
        }
        
        case 
2:
        {
            if (!
is_user_alive(id))
            {
                
client_print(idprint_chat"You Have To Be Alive To Buy Health")
                return 
PLUGIN_HANDLED
            
}
            
            new 
Money fm_get_user_money(id)
            new 
Pcvar get_pcvar_num(cost_100hp)
            new 
Health get_user_health(id)
            
            if (
Money Pcvar)
            {
                
client_print(idprint_chat"You don't have enough money to buy this")
            }
            else
            {
                
client_print(idprint_chat"You just purchared +100 HP")
                
fm_set_user_money(idMoney-Pcvar)
                
fm_set_user_health (idHealth+100)
            }
        }
        
        case 
3:
        {
            if (!
is_user_alive(id))
            {
                
client_print(idprint_chat"You Have To Be Alive To Buy Health")
                return 
PLUGIN_HANDLED
            
}
            
            new 
Money fm_get_user_money(id)
            new 
Pcvar get_pcvar_num(cost_200hp)
            new 
Health get_user_health(id)
            
            if (
Money Pcvar)
            {
                
client_print(idprint_chat"You don't have enough money to buy this")
            }
            else
            {
                
client_print(idprint_chat"You just purchared +200 HP")
                
fm_set_user_money(idMoney-Pcvar)
                
fm_set_user_health (idHealth+200)
            }
        }
        
        case 
4:
        {
            if (!
is_user_alive(id))
            {
                
client_print(idprint_chat"You Have To Be Alive To Buy Health")
                return 
PLUGIN_HANDLED
            
}
            
            new 
Money fm_get_user_money(id)
            new 
Pcvar get_pcvar_num(cost_250hp)
            new 
Health get_user_health(id)
            
            if (
Money Pcvar)
            {
                
client_print(idprint_chat"You don't have enough money to buy this")
            }
            else
            {
                
client_print(idprint_chat"You just purchared +250 HP")
                
fm_set_user_money(idMoney-Pcvar)
                
fm_set_user_health (idHealth+250)
            }
        }

    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}

public 
Event_Round_Start()
{
    
client_print(0print_chat"To Open Up Health Shop, Type /hpshop in chat")
}

stock fm_set_user_health(indexhealth
{
    
health set_pev(indexpev_healthfloat(health)) : dllfunc(DLLFunc_ClientKillindex)
    return 
1
}

stock fm_get_user_money(index
{
    return 
get_pdata_int(indexFM_MONEY_OFFSET)
}

stock fm_set_user_money(indexmoneyflash 1
{
    
set_pdata_int(indexFM_MONEY_OFFSETmoney);
    
    
message_begin(MSG_ONEget_user_msgid("Money"), _index);
    
write_long(money);
    
write_byte(flash 0);
    
message_end();
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1053\\ f0\\ fs16 \n\\ par }
*/ 

Last edited by Pizzadaking; 04-02-2020 at 19:16.
Pizzadaking is offline
Pizzadaking
Member
Join Date: Oct 2019
Old 04-02-2020 , 17:17   Re: Health shop [ ONLY FOR CT ]
Reply With Quote #2

UPDATE: i had to put the code below on the public show_menu_buy_hp

Quote:
if(cs_get_user_team(id) == !CS_TEAM_CT) {
client_print(id, print_chat, "^x01 [^x04 BIBITA ^x01] You need to be alive to enter the shop")
return PLUGIN_HANDLED
}
else {
Pizzadaking 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 21:13.


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