Raised This Month: $ Target: $400
 0% 

Register "+command" from client?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DavidJr
Senior Member
Join Date: Apr 2012
Old 01-27-2014 , 06:39   Re: Register "+command" from client?
Reply With Quote #1

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 #2

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
DavidJr
Senior Member
Join Date: Apr 2012
Old 01-27-2014 , 07:11   Re: Register "+command" from client?
Reply With Quote #3

Quote:
Originally Posted by mlar98 View Post
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.
it's wrong, it should be like this:

PHP Code:
public fwd_Weapon_Reload(iEnt
{
    static 
id;
    
id get_pdata_cbase(iEnt414); //41 is m_pPlayer and obtain the owner of weapon
    
    
Message(id);
    return 
HAM_SUPERCEDE;
}

public 
Message(id

    
client_print(idprint_center"You don't need to recharge.");

Quote:
Originally Posted by mlar98 View Post
Sorry, I didn't know how to search about this.
keywords, Block Reload
__________________
What are you looking for here?
DavidJr is offline
mlar98
Junior Member
Join Date: Mar 2012
Location: Lima, Peru
Old 01-27-2014 , 20:59   Re: Register "+command" from client?
Reply With Quote #4

Quote:
Originally Posted by DavidJr View Post
it's wrong, it should be like this:

PHP Code:
public fwd_Weapon_Reload(iEnt
{
    static 
id;
    
id get_pdata_cbase(iEnt414); //41 is m_pPlayer and obtain the owner of weapon
    
    
Message(id);
    return 
HAM_SUPERCEDE;
}

public 
Message(id

    
client_print(idprint_center"You don't need to recharge.");



keywords, Block Reload
Thank you again I'm a noob but trying to learn!

Quote:
Originally Posted by ConnorMcLeod View Post
Seems to work :

PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >

#pragma semicolon 1

#define PLUGIN ""
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

const XO_CBASEPLAYERITEM 4;
const 
m_pPlayer 41;
const 
m_iId 43;

const 
XO_CBASEPLAYERWEAPON 4;
const 
m_iClip 51;
const 
m_fInReload 54;

// const XO_CBASEPLAYER = 5;
const m_afButtonPressed 246;

const 
NO_RELOAD 1<<CSW_HEGRENADE 1<<CSW_C4 1<<CSW_SMOKEGRENADE 1<<CSW_FLASHBANG 1<<CSW_KNIFE;
const 
SHOTGUNS 1<<CSW_XM1014 1<<CSW_M3;

new const 
g_iMaxClip[CSW_P90+1] = {
    -
1,        // 
    
13,        // CSW_P228
    
-1,        // 
    
10,        // CSW_SCOUT
    
1,        // CSW_HEGRENADE
    
7,        // CSW_XM1014
    
1,        // CSW_C4
    
30,        // CSW_MAC10
    
30,        // CSW_AUG
    
1,        // CSW_SMOKEGRENADE
    
30,        // CSW_ELITE
    
20,        // CSW_FIVESEVEN
    
25,        // CSW_UMP45
    
30,        // CSW_SG550
    
35,        // CSW_GALIL
    
25,        // CSW_FAMAS
    
12,        // CSW_USP
    
20,        // CSW_GLOCK18
    
10,        // CSW_AWP
    
30,        // CSW_MP5NAVY
    
100,    // CSW_M249
    
8,        // CSW_M3
    
30,        // CSW_M4A1
    
30,        // CSW_TMP
    
20,        // CSW_G3SG1
    
2,        // CSW_FLASHBANG
    
7,        // CSW_DEAGLE
    
30,        // CSW_SG552
    
30,        // CSW_AK47
    
-1,        // CSW_KNIFE
    
50        // CSW_P90
};

public 
plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    new 
szWeaponClass[32];
    for(new 
iId CSW_P228iId<=CSW_P90iId++)
    {
        if( ~(
1<<iId) & (NO_RELOAD SHOTGUNS ) && iId != && get_weaponname(iIdszWeaponClasscm(szWeaponClass)) )
        {
            
RegisterHam(Ham_Weapon_ReloadszWeaponClass"OnMisc_Weapon_Reload"false);
        }
    }
}

public 
OnMisc_Weapon_Reloadweapon )
{
    if( 
get_pdata_int(weaponm_fInReloadXO_CBASEPLAYERWEAPON) )
    {
        return 
HAM_IGNORED;
    }

    new 
id get_pdata_cbase(weaponm_pPlayerXO_CBASEPLAYERITEM);
    if( 
pev(idpev_button) & IN_USE )
    {
        return 
HAM_IGNORED;
    }

    new 
iId get_pdata_int(weaponm_iIdXO_CBASEPLAYERITEM);
    new 
iClip get_pdata_int(weaponm_iClipXO_CBASEPLAYERWEAPON);
    new 
iMaxClip g_iMaxClip[iId];
    if( 
iClip == iMaxClip )
    {
        return 
HAM_IGNORED;
    }

    if( 
iClip && float(iClip) / float(iMaxClip) > 0.3 )
    {
        if( 
get_pdata_int(idm_afButtonPressed) & IN_RELOAD )
        {
            
engclient_print(idengprint_center"^n^nYou don't need to reload^n^nPress +use and +reload^n^nto force reload process^n");
        }
        
ExecuteHam(Ham_CS_Weapon_SendWeaponAnimweapon00);
        return 
HAM_SUPERCEDE;
    }
    return 
HAM_IGNORED;

Thank you for your help but can't compile! Replaced this line:
PHP Code:
 ExecuteHam(Ham_CS_Weapon_SendWeaponAnimweapon00); 
with
PHP Code:
 ExecuteHam(Ham_Weapon_SendWeaponAnimweapon00); 
Compiled succesfully after that but then, when the plugin is running, server crashes when someone press the reload button!
mlar98 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-28-2014 , 00:03   Re: Register "+command" from client?
Reply With Quote #5

You need "update" hamsandwich : https://forums.alliedmods.net/showpo...9&postcount=34
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-27-2014 , 07:37   Re: Register "+command" from client?
Reply With Quote #6

Seems to work :

PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >

#pragma semicolon 1

#define PLUGIN ""
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

const XO_CBASEPLAYERITEM 4;
const 
m_pPlayer 41;
const 
m_iId 43;

const 
XO_CBASEPLAYERWEAPON 4;
const 
m_iClip 51;
const 
m_fInReload 54;

// const XO_CBASEPLAYER = 5;
const m_afButtonPressed 246;

const 
NO_RELOAD 1<<CSW_HEGRENADE 1<<CSW_C4 1<<CSW_SMOKEGRENADE 1<<CSW_FLASHBANG 1<<CSW_KNIFE;
const 
SHOTGUNS 1<<CSW_XM1014 1<<CSW_M3;

new const 
g_iMaxClip[CSW_P90+1] = {
    -
1,        // 
    
13,        // CSW_P228
    
-1,        // 
    
10,        // CSW_SCOUT
    
1,        // CSW_HEGRENADE
    
7,        // CSW_XM1014
    
1,        // CSW_C4
    
30,        // CSW_MAC10
    
30,        // CSW_AUG
    
1,        // CSW_SMOKEGRENADE
    
30,        // CSW_ELITE
    
20,        // CSW_FIVESEVEN
    
25,        // CSW_UMP45
    
30,        // CSW_SG550
    
35,        // CSW_GALIL
    
25,        // CSW_FAMAS
    
12,        // CSW_USP
    
20,        // CSW_GLOCK18
    
10,        // CSW_AWP
    
30,        // CSW_MP5NAVY
    
100,    // CSW_M249
    
8,        // CSW_M3
    
30,        // CSW_M4A1
    
30,        // CSW_TMP
    
20,        // CSW_G3SG1
    
2,        // CSW_FLASHBANG
    
7,        // CSW_DEAGLE
    
30,        // CSW_SG552
    
30,        // CSW_AK47
    
-1,        // CSW_KNIFE
    
50        // CSW_P90
};

public 
plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    new 
szWeaponClass[32];
    for(new 
iId CSW_P228iId<=CSW_P90iId++)
    {
        if( ~(
1<<iId) & (NO_RELOAD SHOTGUNS ) && iId != && get_weaponname(iIdszWeaponClasscm(szWeaponClass)) )
        {
            
RegisterHam(Ham_Weapon_ReloadszWeaponClass"OnMisc_Weapon_Reload"false);
        }
    }
}

public 
OnMisc_Weapon_Reloadweapon )
{
    if( 
get_pdata_int(weaponm_fInReloadXO_CBASEPLAYERWEAPON) )
    {
        return 
HAM_IGNORED;
    }

    new 
id get_pdata_cbase(weaponm_pPlayerXO_CBASEPLAYERITEM);
    if( 
pev(idpev_button) & IN_USE )
    {
        return 
HAM_IGNORED;
    }

    new 
iId get_pdata_int(weaponm_iIdXO_CBASEPLAYERITEM);
    new 
iClip get_pdata_int(weaponm_iClipXO_CBASEPLAYERWEAPON);
    new 
iMaxClip g_iMaxClip[iId];
    if( 
iClip == iMaxClip )
    {
        return 
HAM_IGNORED;
    }

    if( 
iClip && float(iClip) / float(iMaxClip) > 0.3 )
    {
        if( 
get_pdata_int(idm_afButtonPressed) & IN_RELOAD )
        {
            
engclient_print(idengprint_center"^n^nYou don't need to reload^n^nPress +use and +reload^n^nto force reload process^n");
        }
        
ExecuteHam(Ham_CS_Weapon_SendWeaponAnimweapon00);
        return 
HAM_SUPERCEDE;
    }
    return 
HAM_IGNORED;

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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