Raised This Month: $32 Target: $400
 8% 

Is it possible to create this plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 06-27-2022 , 05:42   Is it possible to create this plugin?
Reply With Quote #1

I need a plugin where vips and admins with a given flag (ADMIN_KICK) can type /buy in-game and open a menu where they can buy, for example:

M4
AK47
M4 + AWP
AK47 + AWP

This way players may hold two primary weapons, CT's would have access to buy AK47 and such.
I searched for something similar but found nothing.

Thanks!
JuanitoAlimana is offline
TribalBlood
Member
Join Date: Oct 2020
Old 06-27-2022 , 07:03   Re: Is it possible to create this plugin?
Reply With Quote #2

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

public plugin_init()
{
    
register_plugin("Weapon_Menu""1.0""TribalBlood");
    
register_clcmd("say /buy""menu_hook");
}

public 
menu_hook(id)
{
    if(!(
get_user_flags(id) & ADMIN_KICK))
    {
        return;
    }

    new 
menu menu_create("Choose Your Weapon""Menu_Handler");
    
menu_additem(menu"M4A1""X1"0);
    
menu_additem(menu"AK47""X2"0);
    
menu_additem(menu"M4A1+AWP""X3"0);
    
menu_additem(menu"AK47+AWP""X4"0);
    
menu_display(idmenu0);
}

public 
Menu_Handler(idmenuitem)
{
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    new 
key str_to_num(data[1]);
    switch(
data[0])
    {
        case 
'X':
        {
            switch(
key)
            {
                case 
1:
                {
                    
give_item(id"weapon_m4a1");
                    
cs_set_user_bpammo(idCSW_M4A190);
                }
                case 
2:
                {
                    
give_item(id"weapon_ak47");
                    
cs_set_user_bpammo(idCSW_AK4790);
                }
                case 
3:
                {
                    
give_item(id"weapon_m4a1");
                    
cs_set_user_bpammo(idCSW_M4A190);
                    
give_item(id"weapon_awp");
                    
cs_set_user_bpammo(idCSW_AWP30);
                }
                case 
4:
                {
                    
give_item(id"weapon_ak47");
                    
cs_set_user_bpammo(idCSW_AK4790);
                    
give_item(id"weapon_awp");
                    
cs_set_user_bpammo(idCSW_AWP30);
                }
            }
        }
    }

__________________
My Steam Profile

- Online Rarely -
TribalBlood is offline
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 06-27-2022 , 23:22   Re: Is it possible to create this plugin?
Reply With Quote #3

Wow! It works perfectly, thank you very much!
JuanitoAlimana is offline
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 06-27-2022 , 23:37   Re: Is it possible to create this plugin?
Reply With Quote #4

Can you add a chatcolor message to those who don't have access that says "Buy vip to have access to this command"?
JuanitoAlimana is offline
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 06-28-2022 , 01:26   Re: Is it possible to create this plugin?
Reply With Quote #5

Nervermind, I think I managed myself lol. I'll leave it here if anyone wants it.

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

public plugin_init()
{
    
register_plugin("Weapon_Menu""1.0""TribalBlood");
    
register_clcmd("say /buy""menu_hook");
}

public 
menu_hook(id)
{
    if(!(
get_user_flags(id) & ADMIN_LEVEL_E))
    {
    
ChatColor(id"!gBuy VIP to use this command")
    }

    else
    {
    new 
menu menu_create("Weapon Menu""Menu_Handler");
    
menu_additem(menu"M4A1""X1"0);
    
menu_additem(menu"AK47""X2"0);
    
menu_additem(menu"M4A1+AWP""X3"0);
    
menu_additem(menu"AK47+AWP""X4"0);
    
menu_display(idmenu0);
    }
}

public 
Menu_Handler(idmenuitem)
{
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    new 
key str_to_num(data[1]);
    switch(
data[0])
    {
        case 
'X':
        {
            switch(
key)
            {
                case 
1:
                {
                    
give_item(id"weapon_m4a1");
                    
cs_set_user_bpammo(idCSW_M4A190);
                }
                case 
2:
                {
                    
give_item(id"weapon_ak47");
                    
cs_set_user_bpammo(idCSW_AK4790);
                }
                case 
3:
                {
                    
give_item(id"weapon_m4a1");
                    
cs_set_user_bpammo(idCSW_M4A190);
                    
give_item(id"weapon_awp");
                    
cs_set_user_bpammo(idCSW_AWP30);
                }
                case 
4:
                {
                    
give_item(id"weapon_ak47");
                    
cs_set_user_bpammo(idCSW_AK4790);
                    
give_item(id"weapon_awp");
                    
cs_set_user_bpammo(idCSW_AWP30);
                }
            }
        }
    }


stock ChatColor(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4"// Green Color
    
replace_all(msg190"!y""^1"// Default Color
    
replace_all(msg190"!team""^3"// Team Color
    
replace_all(msg190"!team2""^0"// Team2 Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch")
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }


Last edited by JuanitoAlimana; 06-28-2022 at 01:27.
JuanitoAlimana is offline
Reply


Thread Tools
Display Modes

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 10:36.


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