View Single Post
Author Message
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 04-08-2021 , 19:39   BaseBuilder Shop
Reply With Quote #1

Hello, i have basebuilder shop but, my line doesn't work, i want only the person who have the flags can buy the item, like VIP

The lines :
Code:
            case Item_M4A1:
            {
                    if(get_user_flags(id) & FURIEN_VIP)
                    cs_set_user_money(id, iNewMoney, 1)
                    client_print(id, print_chat, "You received the S.M4A1 (VIP ONLY)")
                    if ( user_has_weapon(id, CSW_M4A1) )
                {
                    client_print(id, print_chat, "You have already S.M4A1 !")
                    menu_destroy(menu2)
                    return PLUGIN_HANDLED
                }
                client_print(id, print_chat, "[INFO] If you are not VIP u can't BUY this, sorry type /buyadmin")
              if(get_user_flags(id) & FURIEN_VIP)
                give_item(id, "weapon_m4a1")
                 cs_set_user_bpammo( id, CSW_M4A1, 90 )
            }
        }
    }
Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
 
#define VERSION "5.4"
#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )
#define MAX_PLAYERS 32
#define Ham_Player_ResetMaxSpeed Ham_Item_PreFrame

#define FURIEN_VIP ADMIN_RESERVATION
 
new g_iMaxPlayers
 
new const g_ModelSuperKnife[] = "models/x_knife_skin.mdl"
new const g_ModelM4A1[] = "models/v_golden_m4a1.mdl"
 
new bool:g_HasSuperKnife[MAX_PLAYERS+1]
new bool:g_HasM4A1[MAX_PLAYERS+1]
new bool:g_HasSpeed[MAX_PLAYERS+1]
new bool:g_HasGravityT[MAX_PLAYERS+1]
new bool:g_HasGravityCt[MAX_PLAYERS+1]
 
enum _:ItemsT {
    Item_SuperKnife_T = 1,
    Item_Gravity_T,
    Item_Speed
}

enum _:ItemsCT {
    Item_SuperKnife_Ct = 1,
    Item_Gravity_Ct,
    Item_M249,
    Item_G3SG1,
    Item_He,
    Item_Flash,
    Item_M4A1
}

new g_pCvarTCost[ItemsT], g_pCvarCTCost[ItemsCT]
new g_pCvarQuantityGravityT, g_pCvarQuantityGravityCt
 
public plugin_init()
{
    register_plugin("BaseBuilder Shop", VERSION, "Ace67")
 
    register_clcmd("say /shop", "ShowShop")
    register_clcmd("say_team /shop", "ShowShop")
    register_clcmd("say shop", "ShowShop");
	register_clcmd("say_team shop", "ShowShop");
 
    g_pCvarTCost[Item_SuperKnife_T] = register_cvar("shopbb_cost_superknife_t", "10000")
    g_pCvarTCost[Item_Gravity_T] = register_cvar("shopbb_cost_gravity_t", "8000")
    g_pCvarTCost[Item_Speed] = register_cvar("shopbb_cost_speed", "6000")
    g_pCvarCTCost[Item_SuperKnife_Ct] = register_cvar("shopbb_cost_superknife_ct", "800")
    g_pCvarCTCost[Item_Gravity_Ct] = register_cvar("shopbb_cost_gravity_ct", "8000")
    g_pCvarCTCost[Item_M249] = register_cvar("shopbb_cost_m249", "7000")
    g_pCvarCTCost[Item_G3SG1] = register_cvar("shopbb_cost_g3sg1", "8000")
    g_pCvarCTCost[Item_He] = register_cvar("shopbb_cost_he", "12000")
    g_pCvarCTCost[Item_Flash] = register_cvar("shopbb_cost_flash", "2000")
    g_pCvarCTCost[Item_M4A1] = register_cvar("shopbb_cost_m4a1", "9000")
 
    g_pCvarQuantityGravityT = register_cvar("shopbb_quantity_gravity_t", "0.125")
    g_pCvarQuantityGravityCt = register_cvar("shopbb_quantity_gravity_ct", "0.125")
 
    RegisterHam(Ham_Spawn, "player", "Player_Spawn_Post", 1)
    RegisterHam(Ham_TakeDamage, "player", "ham_TakeDamage_Pre")
    RegisterHam(Ham_Item_Deploy, "weapon_knife", "ham_ItemDeploy_Post", 1)
    RegisterHam(Ham_Item_Deploy, "weapon_m4a1", "ham_ItemDeploy_Post_M4", 1);
    RegisterHam(Ham_Player_ResetMaxSpeed, "player", "Player_ResetMaxSpeed", 1)
 
    g_iMaxPlayers = get_maxplayers()
 
    set_cvar_num("sv_maxspeed", 999)
}
 
public plugin_precache()
{
    precache_model(g_ModelSuperKnife)
    precache_model(g_ModelM4A1)
}
public Player_ResetMaxSpeed( id )
{
    if ( is_user_alive ( id ) )
    {
         if ( get_user_maxspeed(id) != -1.0 )
         {
              if ( g_HasSpeed[id] )
              {
                   set_user_maxspeed(id, 600.0)
              }
         }
    }
}
 
public client_connect( id )
{
    client_cmd(id, "cl_forwardspeed 999;cl_sidespeed 999;cl_backspeed 999")
    g_HasSuperKnife[id] = false
    g_HasM4A1[id] = false
    g_HasSpeed[id] = false;
}

public client_disconnect(id)
{
	g_HasSuperKnife[id] = false;
	g_HasM4A1[id] = false;
}
 
public ShowShop(id)
{
    if ( is_user_alive(id) )
    {
        new Text[32]

        if ( cs_get_user_team(id) == CS_TEAM_T )
        {
            new menu = menu_create ("\w^x03[\r ZOMBIE SHOP \w]", "ShopT")
            formatex(Text, charsmax(Text), "\wSuperKnife \y[\r%d $\y]", get_pcvar_num(g_pCvarTCost[Item_SuperKnife_T]))
            menu_additem(menu, Text, "1")
            formatex(Text, charsmax(Text), "\wLow Gravity \y[\r%d $\y]", get_pcvar_num(g_pCvarTCost[Item_Gravity_T]))
            menu_additem(menu, Text, "2")
            formatex(Text, charsmax(Text), "\wFast Speed \y[\r%d $\y]", get_pcvar_num(g_pCvarTCost[Item_Speed]))
            menu_additem(menu, Text, "3")
 
            menu_setprop(menu, MPROP_EXITNAME, "Quit")
            menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
 
            menu_display(id, menu)
        }
 
        else
        {
            new menu2 = menu_create ("\w^x03[\r HUMAN SHOP \w]", "ShopCt")
            formatex(Text, charsmax(Text), "\wSuperKnife \y[\r%d $\y]", get_pcvar_num(g_pCvarCTCost[Item_SuperKnife_Ct]))
            menu_additem(menu2, Text, "1")
            formatex(Text, charsmax(Text), "\wLow Gravity \y[\r%d $\y]", get_pcvar_num(g_pCvarCTCost[Item_Gravity_Ct]))
            menu_additem(menu2, Text, "2")
            formatex(Text, charsmax(Text), "\wM249 \y[\r%d $\y]", get_pcvar_num(g_pCvarCTCost[Item_M249]))
            menu_additem(menu2, Text, "3")
            formatex(Text, charsmax(Text), "\wG3SG1 \y[\r%d $\y]", get_pcvar_num(g_pCvarCTCost[Item_G3SG1]))
            menu_additem(menu2, Text, "4")
            formatex(Text, charsmax(Text), "\wHE Grenade \y[\r%d $\y]", get_pcvar_num(g_pCvarCTCost[Item_He]))
            menu_additem(menu2, Text, "5")
            formatex(Text, charsmax(Text), "\wFlashbang \y[\r%d $\y]", get_pcvar_num(g_pCvarCTCost[Item_Flash]))
            menu_additem(menu2, Text, "6")
            formatex(Text, charsmax(Text), "\wS.M4A1 (VIP) \y[\r%d $\y]", get_pcvar_num(g_pCvarCTCost[Item_M4A1]))
            menu_additem(menu2, Text, "7")
 
            menu_setprop(menu2, MPROP_EXITNAME, "Quit")
            menu_setprop(menu2, MPROP_EXIT, MEXIT_ALL)
 
            menu_display(id, menu2)
        }
    }
    else
    {
        client_print(id, print_chat, "You must be alive for buy !")
    }
}
 
public ShopT(id, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
 
    if ( !is_user_alive(id) )
    {
        client_print(id, print_chat, "You must be alive for buy !")
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
 
    new info[3]
    new access, callback
    menu_item_getinfo(menu, item, access, info, 2, _, _, callback)
 
    new key = str_to_num(info)
    new iNewMoney = cs_get_user_money(id) - get_pcvar_num(g_pCvarTCost[key])
 
    if ( iNewMoney < 0 )
    {
        client_print(id, print_chat, "You don't have enough money !")
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    else
    {
        switch(key)
        {
            case Item_SuperKnife_T:
            {
                if ( g_HasSuperKnife[id] )
                {
                    client_print(id, print_chat, "You have already the SuperKnife !")
                    menu_destroy(menu)
                    return PLUGIN_HANDLED
                }
                cs_set_user_money(id, iNewMoney, 1)
                g_HasSuperKnife[id] = true;
                client_print(id, print_chat, "You have bought SuperKnife !")
            }
 
            case Item_Gravity_T:
            {
                if ( g_HasGravityT[id] )
                {
                    client_print(id, print_chat, "You have already Low Gravity !")
                    menu_destroy(menu)
                    return PLUGIN_HANDLED
                }
                cs_set_user_money(id, iNewMoney, 1)
                set_user_gravity(id, get_pcvar_float(g_pCvarQuantityGravityT) )
                client_print(id, print_chat, "You have bought Low Gravity !")
                g_HasGravityT[id] = true;
            }
 
            case Item_Speed:
            {
                if ( g_HasSpeed[id] )
                {
                    client_print(id, print_chat, "You have already Fast Speed !")
                    menu_destroy(menu)
                    return PLUGIN_HANDLED
                }
                cs_set_user_money(id, iNewMoney, 1)
                g_HasSpeed[id] = true;
                client_print(id, print_chat, "You have bought Fast Speed !")
            }
        }
    }
    menu_destroy(menu)
    return PLUGIN_HANDLED
}
 
public ShopCt(id, menu2, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu2)
        return PLUGIN_HANDLED
    }
 
    if ( !is_user_alive(id) )
    {
        client_print(id, print_chat, "You must be alive !")
        menu_destroy(menu2)
        return PLUGIN_HANDLED
    }
 
    new info[3]
    new access, callback
    menu_item_getinfo(menu2, item, access, info, 2, _, _, callback)
 
    new key = str_to_num(info)
    new iNewMoney = cs_get_user_money(id) - get_pcvar_num(g_pCvarCTCost[key])
 
    if ( iNewMoney < 0 )
    {
        client_print(id, print_chat, "You don't have enough money ! !")
        menu_destroy(menu2)
        return PLUGIN_HANDLED
    }
    else
    {
        switch(key)
        {
            case Item_SuperKnife_Ct:
            {
                if ( g_HasSuperKnife[id] )
                {
                    client_print(id, print_chat, "You have already the SuperKnife !")
                    menu_destroy(menu2)
                    return PLUGIN_HANDLED
                }
                cs_set_user_money(id, iNewMoney, 1)
                g_HasSuperKnife[id] = true;
                client_print(id, print_chat, "You have bought SuperKnife !")
            }
 
            case Item_Gravity_Ct:
            {    
                if ( g_HasGravityCt[id] )
                {
                    client_print(id, print_chat, "You have already Low Gravity  !")
                    menu_destroy(menu2)
                    return PLUGIN_HANDLED
                }
                cs_set_user_money(id, iNewMoney, 1)
                set_user_gravity(id, get_pcvar_float(g_pCvarQuantityGravityCt))
                client_print(id, print_chat, "You have bought Low Gravity !")
                g_HasGravityCt[id] = true;
            }
 
            case Item_M249:
            {
                if ( user_has_weapon(id, CSW_M249) )
                {
                    client_print(id, print_chat, "You have already M249 !")
                    menu_destroy(menu2)
                    return PLUGIN_HANDLED
                }
                cs_set_user_money(id, iNewMoney, 1)
                cs_set_user_bpammo( id, CSW_M249, 90 )
                give_item(id, "weapon_m249")
                client_print(id, print_chat, "You have bought M249 !")
            }
 
            case Item_G3SG1:
            {
                if ( user_has_weapon(id, CSW_G3SG1) )
                {
                    client_print(id, print_chat, "You have already G3SG1 !")
                    menu_destroy(menu2)
                    return PLUGIN_HANDLED
                }
                cs_set_user_money(id, iNewMoney, 1)
                cs_set_user_bpammo( id, CSW_G3SG1, 90 )
                give_item(id, "weapon_g3sg1")
                client_print(id, print_chat, "You have bought G3SG1 !")
            }
 
            case Item_He:
            {
                if ( user_has_weapon(id, CSW_HEGRENADE) )
                {
                    client_print(id, print_chat, "You have already Grenade !")
                    menu_destroy(menu2)
                    return PLUGIN_HANDLED
                }
                cs_set_user_money(id, iNewMoney, 1)
                give_item(id, "weapon_hegrenade")
                client_print(id, print_chat, "You have bought HeGrenade !")
            }
 
            case Item_Flash:
            {
                if ( cs_get_user_bpammo(id, CSW_FLASHBANG) == 2 )
                {
                    client_print(id, print_chat, "You have already 2 flashbangs !")
                    menu_destroy(menu2)
                    return PLUGIN_HANDLED
                }
                cs_set_user_money(id, iNewMoney, 1)
                give_item(id, "weapon_flashbang")
                client_print(id, print_chat, "You have bought Flashbang !")
            }
 
            case Item_M4A1:
            {
                    if(get_user_flags(id) & FURIEN_VIP)
                    cs_set_user_money(id, iNewMoney, 1)
                    client_print(id, print_chat, "You received the S.M4A1 (VIP ONLY)")
                    if ( user_has_weapon(id, CSW_M4A1) )
                {
                    client_print(id, print_chat, "You have already S.M4A1 !")
                    menu_destroy(menu2)
                    return PLUGIN_HANDLED
                }
                client_print(id, print_chat, "[INFO] If you are not VIP u can't BUY this, sorry type /buyadmin")
              if(get_user_flags(id) & FURIEN_VIP)
                give_item(id, "weapon_m4a1")
                 cs_set_user_bpammo( id, CSW_M4A1, 90 )
            }
        }
    }
    menu_destroy(menu2)
    return PLUGIN_HANDLED
}
 
public Player_Spawn_Post(id)
{
    if ( is_user_alive ( id ) )
    {
        client_print(id, print_chat, "Say /shop in the chat for buy an item !")
 
        if ( g_HasSuperKnife[id] && get_user_weapon(id) == CSW_KNIFE )
        {
            set_pev(id, pev_viewmodel2, "models/v_knife.mdl")
        }
        g_HasSuperKnife[id] = false
        g_HasM4A1[id] = false
        g_HasSpeed[id] = false;
    }
}
 
public ham_TakeDamage_Pre(victim, inflictor, attacker, Float:damage, damage_bits)
{
    if ( IsPlayer(attacker) && g_HasSuperKnife[attacker] && is_user_alive(attacker) && inflictor == attacker && get_user_weapon(attacker) == CSW_KNIFE )
    {
        SetHamParamFloat( 4, damage * 154.0 )
    }
    
    if ( IsPlayer(attacker) && g_HasM4A1[attacker] && is_user_alive(attacker) && inflictor == attacker && get_user_weapon(attacker) == CSW_M4A1 )
	{
		SetHamParamFloat( 4, damage * 999.0 );
	}
}
 
public ham_ItemDeploy_Post(weapon_ent)
{
    static owner
    owner = get_pdata_cbase(weapon_ent, 41, 4)
 
    if ( is_user_alive(owner) && g_HasSuperKnife[owner] )
    {
        set_pev(owner, pev_viewmodel2, g_ModelSuperKnife)
    }
}

public ham_ItemDeploy_Post_M4(weapon_ent)
{
	static owner;
	owner = get_pdata_cbase(weapon_ent, 41, 4);

	if ( is_user_alive(owner) && g_HasM4A1[owner] )
	{
		set_pev(owner, pev_viewmodel2, g_ModelM4A1);
	}
}
__________________
CS:CZ > CS 1.6

Last edited by Ace67; 04-08-2021 at 19:55.
Ace67 is offline