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

Blocking Buy Commands (Basic)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fezh
Veteran Member
Join Date: Dec 2008
Location: BANNED
Old 09-04-2009 , 12:09   Blocking Buy Commands (Basic)
Reply With Quote #1

PHP Code:
#include <amxmodx>

// Here is the name of all "buy weapons" commands of CS, took from CS Weapons Information (AM Wiki).
// Is a tridimensional array because I'm going to use it in a loop, but actually this is not necessary,
// you can register all commands separately, but I think this is the easier & clean way to do it.
new gBuyCommands[][] = 
{
     
"usp""glock""deagle""p228""elites""fn57""m3""xm1014""mp5""tmp""p90""mac10""ump45""ak47"
    
"galil""famas""sg552""m4a1""aug""scout""awp""g3sg1""sg550""m249""vest""vesthelm""flash""hegren",
    
"sgren""defuser""nvgs""shield""primammo""secammo""km45""9x19mm""nighthawk""228compact""12gauge",
    
"autoshotgun""smg""mp""c90""cv47""defender""clarion""krieg552""bullpup""magnum""d3au1""krieg550",
    
"buyammo1""buyammo2"
}

// Variable that I'm going to use to register the pCVAR.
new gCvarPluginToggle

public plugin_init()
{
    
// I think there is no need for explain this.
    
register_plugin("Block Buy Example""0.1.0""fezh")

    
// Toggle CVAR
    
gCvarPluginToggle register_cvar("amx_block_buy""1")

    
// Registering commands. As I said before, there is no need for creating a loop, but I like it anyways :P
    
for (new isizeof gBuyCommandsi++)
        
register_clcmd(gBuyCommands[i], "BlockBuyCommands")
}

public 
BlockBuyCommands(id)
{
    
// If the plugin don't get the CVAR, it makes you buy normally.
    
if (!get_pcvar_num(gCvarPluginToggle))
        return 
PLUGIN_CONTINUE;

    
// Block the buy commands.
    
return PLUGIN_HANDLED;
}

// Final comments: I did the "tutorial" since I saw that there are some weirds (and not actually functional) ways to do it, 
// like in the plugin called "Block Commands". 
__________________
"There is no knowledge, that is not power"

Last edited by fezh; 01-23-2010 at 11:38.
fezh is offline
crazyeffect
Veteran Member
Join Date: Jul 2008
Location: Belgium
Old 09-04-2009 , 12:28   Re: Blocking Buy Commands (Basic)
Reply With Quote #2

Finally!
__________________
crazyeffect is offline
Send a message via MSN to crazyeffect
fezh
Veteran Member
Join Date: Dec 2008
Location: BANNED
Old 09-04-2009 , 12:35   Re: Blocking Buy Commands (Basic)
Reply With Quote #3

I have a doubt. Why someone put 1 star in my thread? Is there an actual reason for this?
__________________
"There is no knowledge, that is not power"
fezh is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-04-2009 , 13:47   Re: Blocking Buy Commands (Basic)
Reply With Quote #4

This is a better way:
http://forums.alliedmods.net/showpos...29&postcount=6

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

new Trie:g_tBuyCommands;

public 
plugin_init( )
{
    
register_plugin"Disable Buy""0.0.1""Exolent" );
    
    new const 
szBuyCommands[ ][ ] =
    {
        
"usp""glock""deagle""p228""elites",
        
"fn57""m3""xm1014""mp5""tmp""p90",
        
"mac10""ump45""ak47""galil""famas",
        
"sg552""m4a1""aug""scout""awp""g3sg1",
        
"sg550""m249""vest""vesthelm""flash",
        
"hegren""sgren""defuser""nvgs""shield",
        
"primammo""secammo""km45""9x19mm""nighthawk",
        
"228compact""fiveseven""12gauge""autoshotgun",
        
"mp""c90""cv47""defender""clarion""krieg552",
        
"bullpup""magnum""d3au1""krieg550"
        
"buy""buyammo1""buyammo2""buyequip""cl_autobuy",
        
"cl_rebuy""cl_setautobuy""cl_setrebuy"
    
}
    
    
g_tBuyCommands TrieCreate( );
    for( new 
0sizeofszBuyCommands ); i++ )
    {
        
TrieSetCellg_tBuyCommandsszBuyCommands], );
    }
}

public 
plugin_end( )
{
    
TrieDestroyg_tBuyCommands );
}

public 
client_commandclient )
{
    if( !
is_user_aliveclient ) )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    static 
szArg15 ];
    
    if( 
read_argv0szArg14 ) > 13 // cl_setautobuy = 1234567890123 = 13
    
{
        return 
PLUGIN_CONTINUE;
    }
    
    
strtolowerszArg );
    if( 
TrieKeyExistsg_tBuyCommandsszArg )
    && ( 
<< ( _:cs_get_user_teamclient ) ) & ( ( << ( _:CS_TEAM_T ) ) | ( << ( _:CS_TEAM_CT ) ) ) )
    {
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 10-14-2009 at 11:20.
Exolent[jNr] is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 09-04-2009 , 21:47   Re: Blocking Buy Commands (Basic)
Reply With Quote #5

Good Job...

About Exolent method... i don't think you have to replace Exolent code with your code... i think you have to show the 2 differents method... so ppl can understand the basic first and then the other.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-04-2009 , 21:51   Re: Blocking Buy Commands (Basic)
Reply With Quote #6

I don't think fezh's will work 100% because not all commands are able to be hooked with register_clcmd( ).
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 09-04-2009 , 22:07   Re: Blocking Buy Commands (Basic)
Reply With Quote #7

client_command and register_clcmd hook the same function, so the commands they can hooked or not are the same. and I think register_clcmd may be a little faster than client_command, because it let module level to compare the command string.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Jon
Veteran Member
Join Date: Dec 2007
Old 09-06-2009 , 06:34   Re: Blocking Buy Commands (Basic)
Reply With Quote #8

If you want to block all kind of buying it would be better altering the "buying" key at info_map_parameters (eventually creating the entity yourself).

Last edited by Jon; 09-06-2009 at 06:37.
Jon is offline
Zpoke
Senior Member
Join Date: Aug 2009
Location: Sweden
Old 10-12-2009 , 15:45   Re: Blocking Buy Commands (Basic)
Reply With Quote #9

ty exolent this was what iv'e looking for
Zpoke is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 10-12-2009 , 16:07   Re: Blocking Buy Commands (Basic)
Reply With Quote #10

Quote:
Originally Posted by Jon View Post
If you want to block all kind of buying it would be better altering the "buying" key at info_map_parameters (eventually creating the entity yourself).
__________________
Still...lovin' . Connor noob! Hello
Alka 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 00:22.


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