Raised This Month: $ Target: $400
 0% 

Register "+command" from client?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mlar98
Junior Member
Join Date: Mar 2012
Location: Lima, Peru
Old 01-27-2014 , 05:11   Register "+command" from client?
Reply With Quote #1

Hello. I'm using a plugin for unlimited ammo, but I want the plugin to show a message when the client press the reload button. The command is "+reload" so I tried this:
PHP Code:
register_clcmd("+reload""ShowMessage")

public 
ShowMessage(id)
{
     
client_print(idprint_center"You don't need to recharge.")

But no success , also tried with register_concmd, the same. How can I do to register a command like "+command" ? Thank you in advance.
mlar98 is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 01-27-2014 , 05:17   Re: Register "+command" from client?
Reply With Quote #2

If you want to hook reload, you can detect reload button with fakemeta like this:

PHP Code:
#define XO_PLAYER 5
#define m_afButtonPressed 246

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
}

public 
client_PreThink(id)
{
    new 
iButtonPressediButtonReleased;
    
iButtonPressed get_pdata_int(idm_afButtonPressedXO_PLAYER);
    
    if (
iButtonPressed IN_RELOAD)
    {
        
//do something here;
    
}

__________________
What are you looking for here?

Last edited by DavidJr; 01-27-2014 at 05:18.
DavidJr is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 01-27-2014 , 05:40   Re: Register "+command" from client?
Reply With Quote #3

What you've done is close enough to reinvented the game engine method. Therefore effectively the same as register Ham_Weapon_Reload, but very inefficient.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 01-27-2014 , 06:08   Re: Register "+command" from client?
Reply With Quote #4

He said that he uses unlimited ammo, Ham_Weapon_Reload won't be called because the ammo won't be 0?
__________________
What are you looking for here?
DavidJr is offline
mlar98
Junior Member
Join Date: Mar 2012
Location: Lima, Peru
Old 01-27-2014 , 06:20   Re: Register "+command" from client?
Reply With Quote #5

Hello. Thank you for your help, the Ham_Weapon_Reload method seems to be not working when there's no reload, I mean, if you press the reload button but there's no reload, it doesn't work.
Now my other question, how can I block clients for reloading? Reloading is not needed
Again, thank you in advance.
mlar98 is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 01-27-2014 , 06:22   Re: Register "+command" from client?
Reply With Quote #6

You can use Ham_Weapon_Reload and return HAM_SUPERCEDE it ;)
__________________
What are you looking for here?
DavidJr is offline
mlar98
Junior Member
Join Date: Mar 2012
Location: Lima, Peru
Old 01-27-2014 , 06:34   Re: Register "+command" from client?
Reply With Quote #7

Quote:
Originally Posted by DavidJr View Post
You can use Ham_Weapon_Reload and return HAM_SUPERCEDE it ;)
Sorry if i'm too stupid but, How?
mlar98 is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 01-27-2014 , 06:38   Re: Register "+command" from client?
Reply With Quote #8

Quote:
Originally Posted by mlar98 View Post
Sorry if i'm too stupid but, How?
RTFM
__________________
simanovich is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 01-27-2014 , 06:39   Re: Register "+command" from client?
Reply With Quote #9

PHP Code:
RegisterHam(Ham_Weapon_Reload"weapon_*""fwd_Weapon_Reload"); 
PHP Code:
public fwd_Weapon_Reload(iEnt)
{
return 
HAM_SUPERCEDE;

weapon_* is your weapon entity.
__________________
What are you looking for here?

Last edited by DavidJr; 01-27-2014 at 06:40.
DavidJr is offline
mlar98
Junior Member
Join Date: Mar 2012
Location: Lima, Peru
Old 01-27-2014 , 07:00   Re: Register "+command" from client?
Reply With Quote #10

Quote:
Originally Posted by DavidJr View Post
PHP Code:
RegisterHam(Ham_Weapon_Reload"weapon_*""fwd_Weapon_Reload"); 
PHP Code:
public fwd_Weapon_Reload(iEnt)
{
return 
HAM_SUPERCEDE;

weapon_* is your weapon entity.
THANK YOU! Now I got all working with this code:

PHP Code:
RegisterHam(Ham_Weapon_Reload"weapon_deagle""fwd_Weapon_Reload");

public 
fwd_Weapon_Reload(iEnt)
{
    
set_task(0"Message");
    return 
HAM_SUPERCEDE
}  

public 
Message(id)
{
    
client_print(idprint_center"You don't need to recharge.")

PD: For some strange reason (I think because of the iEnt index) client_print doesn't work, it needs the set_task function.

Quote:
Originally Posted by simanovich View Post
RTFM
Sorry, I didn't know how to search about this.
mlar98 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:10.


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