Raised This Month: $ Target: $400
 0% 

Blocking Buy Commands (Basic)


Post New Thread Reply   
 
Thread Tools Display Modes
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 10-13-2009 , 03:51   Re: Blocking Buy Commands (Basic)
Reply With Quote #11

Would be good a tutorial or an example about that Jon said.
__________________
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 10-13-2009 , 12:21   Re: Blocking Buy Commands (Basic)
Reply With Quote #12

Code:
#include < amxmodx > #include < engine > #include < fakemeta > new const info_map_parameters[ ] = "info_map_parameters"; new g_hSpawn; public plugin_precache( ) {     new iEntity = create_entity( info_map_parameters );     DispatchKeyValue( iEntity, "buying", "3" );     DispatchSpawn( iEntity );         g_hSpawn = register_forward( FM_Spawn, "FwdSpawn" ); } public FwdSpawn( iEntity ) {     static szClassname[ 32 ];     entity_get_string( iEntity, EV_SZ_classname, szClassname, 31 );         if( equal( szClassname, info_map_parameters ) ) {         remove_entity( iEntity );                 return FMRES_SUPERCEDE;     }         return FMRES_IGNORED; } public plugin_init( ) {     if( g_hSpawn > 0 ) {         unregister_forward( FM_Spawn, g_hSpawn );     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-13-2009 , 15:52   Re: Blocking Buy Commands (Basic)
Reply With Quote #13

Quote:
Originally Posted by Exolent[jNr] View Post
PHP Code:
    if( TrieKeyExistsg_tBuyCommandsszArg )
    && ( 
<< ( _:cs_get_user_teamclient ) ) & ( ( << ) | ( << ) ) ) 
This is bad practice. You should use detagged CS_TEAM_T and CS_TEAM_CT constants, like this:

PHP Code:
    if( TrieKeyExistsg_tBuyCommandsszArg )
    && ( 
<< ( _:cs_get_user_teamclient ) ) & ( ( << _:CS_TEAM_T ) | ( << _:CS_TEAM_CT ) ) ) 
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-13-2009 , 15:54   Re: Blocking Buy Commands (Basic)
Reply With Quote #14

Other than readability, what is the purpose?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-13-2009 , 15:59   Re: Blocking Buy Commands (Basic)
Reply With Quote #15

Quote:
Originally Posted by Exolent[jNr] View Post
Other than readability, what is the purpose?
What if the constant changes? Of course, it never will in this case, but what if you're working with some kind of volatile API? As you said, there's also the readability issue.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
stupok
Veteran Member
Join Date: Feb 2006
Old 10-14-2009 , 21:34   Re: Blocking Buy Commands (Basic)
Reply With Quote #16

Exolent, can you say a few words about your code in #12? Did you test it? What does it do? Why 3? etc.

Thanks
__________________
stupok is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-14-2009 , 22:24   Re: Blocking Buy Commands (Basic)
Reply With Quote #17

It has been tested.
"buying" is the key for what teams can buy.
The value is the bitsum for the teams that are allowed to buy.
0 - Everyone can buy
1 - Terrorists can't buy
2 - Counter-Terrorists can't buy
3 - No one can buy
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-15-2009 , 05:37   Re: Blocking Buy Commands (Basic)
Reply With Quote #18

Quote:
Originally Posted by stupok View Post
Exolent, can you say a few words about your code in #12? Did you test it? What does it do? Why 3? etc.

Thanks
info_map_parameters is an entity which allows you to change the radius of the bomb target and which team is allowed to buy. You will get message like "Terrorists are not allowed to buy on this map" or something like.

The Exolent[jNr]'s code create an info_map_parameter entity which define which team is allowed to buy, then he deletes the original entity, if it exists. It's more simple to do that instead of checking/altering a value of a specific key.

Here Ham_Spawn should be used, but since RegisterHam() is buggy, you have to use FM_Spawn. Otherwise it will do the same as RegisterHamFromEntity() where it will spawn all the entities of the same internal class. But I'm wondering if this entity shares the same internal class with others entities. It sounds line an unique entity, something worth to check so you could use Ham_Spawn safely here.

About the value for the team ; you can find the description for these keys in the Counter-Strike game definition file (.fgd). I attach here.
Attached Files
File Type: zip cs16expert-hex805.zip (29.4 KB, 188 views)
__________________
Arkshine is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 10-15-2009 , 06:08   Re: Blocking Buy Commands (Basic)
Reply With Quote #19

Quote:
Originally Posted by Arkshine View Post
Here Ham_Spawn should be used, but since RegisterHam() is buggy
Explain. I'vent found anything buggy in RegisterHam. Sure it hooks the virtual table and some entities can have same virtual table and different in-game classname, but where's a bug? It's how it works, and works just fine if we know the facts.
SnoW is offline
Send a message via MSN to SnoW
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-15-2009 , 06:26   Re: Blocking Buy Commands (Basic)
Reply With Quote #20

No, RegisterHam() should hook only by the the classname provided. RegisterHamFromEntity() hooks by internal class. I don't see the purpose for both to hook by internal class. (why both natives so?) If not a bug RegisterHam() (I don't see in the .inc a note like : "This will cause hooks for the entire internal class" why?) should still hook only the classname we provide. It makes more senses to use it in this way. In many situations that's not possible to use Ham_Spawn when it's more efficient to use it. Using FM_Spawn called for all entities + using a native each time as replacement is just idiot. So, yes for me it's a "bug".
__________________

Last edited by Arkshine; 10-15-2009 at 07:21.
Arkshine 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 10:20.


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