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

[CS][Forward] client_buy


Post New Thread Reply   
 
Thread Tools Display Modes
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 08-14-2012 , 09:14   Re: [CS][Forward] client_buy
Reply With Quote #51

Oh, well.. I have coded the plugin fast, didn't think about the prefixes etc, else I'd use "const Bits_Restricted_Weapons" or even "const Restricted_Weapons". Keep up the good work, this forward made my work much easier with the weapons requests in the official bulgarian amxmodx forum.

Last edited by dark_style; 08-14-2012 at 09:15.
dark_style is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 08-14-2012 , 12:29   Re: [CS][Forward] client_buy
Reply With Quote #52

I'm using this code:

PHP Code:
#include <amxmodx> 
#include <fakemeta> 
#include <cstrike> 
#include <cl_buy>

#define VERSION "0.1.1" 
#define PLUGIN "client_buy forward" 

enum _:iMenus 
    
Menu_Buy 4
    
Menu_BuyPistol 5
    
Menu_BuyRifle 6
    
Menu_BuyMachineGun 7
    
Menu_BuyShotgun 8
    
Menu_BuySubMachineGun 9
    
Menu_BuyItem 10 
};

#define XO_PLAYER 5
#define m_iMenu 205
#define cs_get_user_menu(%0) get_pdata_int(%0, m_iMenu, XO_PLAYER)

new const g_iMenuItemsTe[][] = { 
    {
000000CSW_PRIMAMMOCSW_SECAMMO0},
    {
0CSW_GLOCK18CSW_USPCSW_P228CSW_DEAGLECSW_ELITE000},
    {
0CSW_GALILCSW_AK47CSW_SCOUTCSW_SG552CSW_AWPCSW_G3SG100},
    {
0CSW_M2490000000},
    {
0CSW_M3CSW_XM1014000000},
    {
0CSW_MAC10CSW_MP5NAVYCSW_UMP45CSW_P900000},
    {
0CSW_VESTCSW_VESTHELMCSW_FLASHBANGCSW_HEGRENADECSW_SMOKEGRENADECSW_NVGS00}
};

new const 
g_iMenuItemsCt[][] = { 
    {
000000CSW_PRIMAMMOCSW_SECAMMO0}, 
    {
0CSW_GLOCK18CSW_USPCSW_P228CSW_DEAGLECSW_FIVESEVEN000},
    {
0CSW_FAMASCSW_SCOUTCSW_M4A1CSW_AUGCSW_SG550CSW_AWP00},
    {
0CSW_M2490000000},
    {
0CSW_M3CSW_XM1014000000},
    {
0CSW_TMPCSW_MP5NAVYCSW_UMP45CSW_P900000},
    {
0CSW_VESTCSW_VESTHELMCSW_FLASHBANGCSW_HEGRENADECSW_SMOKEGRENADECSW_NVGSCSW_DEFUSERCSW_SHIELD}
};

new 
g_iBuyForwardg_iReturn;

public 
plugin_init() { 
    
register_plugin(PLUGINVERSION"ConnorMcLeod");


public 
plugin_cfg() { 
    new 
pluginsNum get_pluginsnum();
    
    for(new 
pluginIndexpluginIndex<pluginsNumpluginIndex++) { 
        if(
get_func_id("client_buy"pluginIndex) != -1) { 
            
register_clcmd("menuselect""ClCmd_MenuSelect"); 
            
g_iBuyForward CreateMultiForward("client_buy"ET_STOPFP_CELLFP_CELL); 
            break;
        } 
    } 
}

public 
plugin_natives() 
    
register_library("cl_buy");

public 
client_command(id) { 
    if(
is_user_alive(id)) { 
        new 
szCommand[13];
        
        if(
read_argv(0szCommandcharsmax(szCommand)) < 12
            return 
CheckBuyCmd(idszCommand);
    }
    return 
PLUGIN_CONTINUE;


public 
CS_InternalCommand(id, const szCommand[]) { 
    if(
is_user_alive(id)) { 
        new 
szCmd[13];
        if(
copy(szCmdcharsmax(szCmd), szCommand) < 12
            return 
CheckBuyCmd(idszCmd
    } 
    return 
PLUGIN_CONTINUE;


CheckBuyCmd(id szCmd[]) { 
    new 
iItem GetAliasId(szCmd);
    
    if(
iItem
        return 
CanBuyItem(idiItem); 
    
    return 
PLUGIN_CONTINUE;


public 
ClCmd_MenuSelect(id) { 
    if(!
is_user_alive(id)) 
        return 
PLUGIN_CONTINUE;
    
    new 
szSlot[3];
    
    if(
read_argv(1szSlotcharsmax(szSlot)) == 1) { 
        new 
iSlot szSlot[0] - '0';
        
        if(
<= iSlot <= 8) { 
            new 
iMenu cs_get_user_menu(id);
            
            if(
Menu_Buy <= iMenu <= Menu_BuyItem) { 
                new 
iItem;
                
                switch(
cs_get_user_team(id)) { 
                    case 
CS_TEAM_T:iItem g_iMenuItemsTe[iMenu-4][iSlot];
                    case 
CS_TEAM_CT:iItem g_iMenuItemsCt[iMenu-4][iSlot]; 
                } 
                
                if(
iItem
                    return 
CanBuyItem(idiItem);
            } 
        } 
    } 
    return 
PLUGIN_CONTINUE;


CanBuyItem(idiItem) { 
    
ExecuteForward(g_iBuyForwardg_iReturnidiItem); 
    
    if(
g_iReturn != PLUGIN_CONTINUE)
        return 
PLUGIN_HANDLED
    
    return 
PLUGIN_CONTINUE;


GetAliasId(szAlias[]) { 
    static 
Trie:tAliasesIds Invalid_Trie;
    
    if(
tAliasesIds == Invalid_Trie) { 
        
tAliasesIds TrieCreate();
        
TrieSetCell(tAliasesIds"p228"CSW_P228);
        
TrieSetCell(tAliasesIds"228compact"CSW_P228); 
        
TrieSetCell(tAliasesIds"scout"CSW_SCOUT); 
        
TrieSetCell(tAliasesIds"hegren"CSW_HEGRENADE); 
        
TrieSetCell(tAliasesIds"xm1014"CSW_XM1014); 
        
TrieSetCell(tAliasesIds"autoshotgun"CSW_XM1014); 
        
TrieSetCell(tAliasesIds"mac10"CSW_MAC10); 
        
TrieSetCell(tAliasesIds"aug"CSW_AUG); 
        
TrieSetCell(tAliasesIds"bullpup"CSW_AUG); 
        
TrieSetCell(tAliasesIds"sgren"CSW_SMOKEGRENADE); 
        
TrieSetCell(tAliasesIds"elites"CSW_ELITE); 
        
TrieSetCell(tAliasesIds"fn57"CSW_FIVESEVEN); 
        
TrieSetCell(tAliasesIds"fiveseven"CSW_FIVESEVEN); 
        
TrieSetCell(tAliasesIds"ump45"CSW_UMP45); 
        
TrieSetCell(tAliasesIds"sg550"CSW_SG550); 
        
TrieSetCell(tAliasesIds"krieg550"CSW_SG550); 
        
TrieSetCell(tAliasesIds"galil"CSW_GALIL); 
        
TrieSetCell(tAliasesIds"defender"CSW_GALIL); 
        
TrieSetCell(tAliasesIds"famas"CSW_FAMAS); 
        
TrieSetCell(tAliasesIds"clarion"CSW_FAMAS); 
        
TrieSetCell(tAliasesIds"usp"CSW_USP); 
        
TrieSetCell(tAliasesIds"km45"CSW_USP); 
        
TrieSetCell(tAliasesIds"glock"CSW_GLOCK18); 
        
TrieSetCell(tAliasesIds"9x19mm"CSW_GLOCK18); 
        
TrieSetCell(tAliasesIds"awp"CSW_AWP); 
        
TrieSetCell(tAliasesIds"magnum"CSW_AWP); 
        
TrieSetCell(tAliasesIds"mp5"CSW_MP5NAVY); 
        
TrieSetCell(tAliasesIds"smg"CSW_MP5NAVY); 
        
TrieSetCell(tAliasesIds"m249"CSW_M249); 
        
TrieSetCell(tAliasesIds"m3"CSW_M3); 
        
TrieSetCell(tAliasesIds"12gauge"CSW_M3); 
        
TrieSetCell(tAliasesIds"m4a1"CSW_M4A1); 
        
TrieSetCell(tAliasesIds"tmp"CSW_TMP); 
        
TrieSetCell(tAliasesIds"mp"CSW_TMP); 
        
TrieSetCell(tAliasesIds"g3sg1"CSW_G3SG1); 
        
TrieSetCell(tAliasesIds"d3au1"CSW_G3SG1);
        
TrieSetCell(tAliasesIds"flash"CSW_FLASHBANG); 
        
TrieSetCell(tAliasesIds"deagle"CSW_DEAGLE); 
        
TrieSetCell(tAliasesIds"nighthawk"CSW_DEAGLE);
        
TrieSetCell(tAliasesIds"sg552"CSW_SG552); 
        
TrieSetCell(tAliasesIds"krieg552"CSW_SG552); 
        
TrieSetCell(tAliasesIds"ak47"CSW_AK47); 
        
TrieSetCell(tAliasesIds"cv47"CSW_AK47); 
        
TrieSetCell(tAliasesIds"p90"CSW_P90); 
        
TrieSetCell(tAliasesIds"c90"CSW_P90); 
        
        
TrieSetCell(tAliasesIds"vest"CSW_VEST); 
        
TrieSetCell(tAliasesIds"vesthelm"CSW_VESTHELM); 
        
        
TrieSetCell(tAliasesIds"defuser"CSW_DEFUSER); 
        
TrieSetCell(tAliasesIds"nvgs"CSW_NVGS);
        
TrieSetCell(tAliasesIds"shield"CSW_SHIELD); 
        
TrieSetCell(tAliasesIds"buyammo1"CSW_PRIMAMMO); 
        
TrieSetCell(tAliasesIds"primammo"CSW_PRIMAMMO); 
        
TrieSetCell(tAliasesIds"buyammo2"CSW_SECAMMO); 
        
TrieSetCell(tAliasesIds"secammo"CSW_SECAMMO); 
    }
    
    
strtolower(szAlias); 
    
    new 
iId;
    
    if(
TrieGetCell(tAliasesIdsszAliasiId)) 
        return 
iId
    
    return 
0;
}  

public 
client_buy(idiItem) {
    if(
get_cvar_num("block_nades") == 1) {
        if(
iItem == CSW_FLASHBANG && !user_has_weapon(idCSW_FLASHBANG
        || 
iItem == CSW_HEGRENADE && !user_has_weapon(idCSW_HEGRENADE
        || 
iItem == CSW_SMOKEGRENADE && !user_has_weapon(idCSW_SMOKEGRENADE)
        )
            return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;

It works. But, when I click to buy on HE, SMOKE and Flash, appears "You already have one!", and every shows it when I open the buy menu.

Sorry for my bad english
__________________

Last edited by kramesa; 08-14-2012 at 12:30.
kramesa is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-14-2012 , 12:33   Re: [CS][Forward] client_buy
Reply With Quote #53

Don't edit the existing plugin. Keep it as it is and make your own.

PHP Code:
#include <amxmodx>
#include <cl_buy>

public client_buy(idiItem) {
    if(
get_cvar_num("block_nades") == 1) {
        if(
iItem == CSW_FLASHBANG && !user_has_weapon(idCSW_FLASHBANG
        || 
iItem == CSW_HEGRENADE && !user_has_weapon(idCSW_HEGRENADE
        || 
iItem == CSW_SMOKEGRENADE && !user_has_weapon(idCSW_SMOKEGRENADE)
        )
            return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Old 08-14-2012, 12:38
kramesa
This message has been deleted by kramesa. Reason: nvm
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 08-14-2012 , 12:55   Re: [CS][Forward] client_buy
Reply With Quote #54

Quote:
Originally Posted by Exolent[jNr] View Post
Don't edit the existing plugin. Keep it as it is and make your own.

PHP Code:
#include <amxmodx>
#include <cl_buy>

public client_buy(idiItem) {
    if(
get_cvar_num("block_nades") == 1) {
        if(
iItem == CSW_FLASHBANG && !user_has_weapon(idCSW_FLASHBANG
        || 
iItem == CSW_HEGRENADE && !user_has_weapon(idCSW_HEGRENADE
        || 
iItem == CSW_SMOKEGRENADE && !user_has_weapon(idCSW_SMOKEGRENADE)
        )
            return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;

Ok.

Edit: Same problem...
__________________
kramesa is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-14-2012 , 13:10   Re: [CS][Forward] client_buy
Reply With Quote #55

Because you return PLUGIN_CONTINUE when users already have a nade...
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 08-14-2012 , 13:16   Re: [CS][Forward] client_buy
Reply With Quote #56

Quote:
Originally Posted by ConnorMcLeod View Post
Because you return PLUGIN_CONTINUE when users already have a nade...
What's the correct?

I tried this:

PHP Code:
#include <amxmodx>
#include <cl_buy>

public client_buy(idiItem) {
    if(
get_cvar_num("block_nades") == 1) {
        if(
iItem == CSW_FLASHBANG && !user_has_weapon(idCSW_FLASHBANG
        || 
iItem == CSW_HEGRENADE && !user_has_weapon(idCSW_HEGRENADE
        || 
iItem == CSW_SMOKEGRENADE && !user_has_weapon(idCSW_SMOKEGRENADE)
        )
            return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_HANDLED;

But I can buy anything
__________________

Last edited by kramesa; 08-14-2012 at 13:19.
kramesa is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-14-2012 , 13:18   Re: [CS][Forward] client_buy
Reply With Quote #57

I don't see what you really try to do.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 08-14-2012 , 13:28   Re: [CS][Forward] client_buy
Reply With Quote #58

Quote:
Originally Posted by ConnorMcLeod View Post
I don't see what you really try to do.
Simple nade block
__________________
kramesa is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-14-2012 , 14:06   Re: [CS][Forward] client_buy
Reply With Quote #59

Then use http://forums.alliedmods.net/showthr...46#post1768546
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 08-14-2012 , 17:49   Re: [CS][Forward] client_buy
Reply With Quote #60

Quote:
Originally Posted by ConnorMcLeod View Post
OMG, the "You already have one" appears because I have this bind: bind b "buy;defuser"

But thanks anyway
__________________
kramesa 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 23:02.


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