Raised This Month: $ Target: $400
 0% 

Register "+command" from client?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
mlar98
Junior Member
Join Date: Mar 2012
Location: Lima, Peru
Old 01-27-2014 , 20:59   Re: Register "+command" from client?
Reply With Quote #12

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
 



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:39.


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