|
Junior Member
Join Date: Mar 2012
Location: Lima, Peru
|

01-27-2014
, 20:59
Re: Register "+command" from client?
|
#2
|
Quote:
Originally Posted by DavidJr
it's wrong, it should be like this:
PHP Code:
public fwd_Weapon_Reload(iEnt)
{
static id;
id = get_pdata_cbase(iEnt, 41, 4); //41 is m_pPlayer and obtain the owner of weapon
Message(id);
return HAM_SUPERCEDE;
}
public Message(id)
{
client_print(id, print_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
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_plugin( PLUGIN, VERSION, "ConnorMcLeod" );
new szWeaponClass[32];
for(new iId = CSW_P228; iId<=CSW_P90; iId++)
{
if( ~(1<<iId) & (NO_RELOAD | SHOTGUNS ) && iId != 2 && get_weaponname(iId, szWeaponClass, cm(szWeaponClass)) )
{
RegisterHam(Ham_Weapon_Reload, szWeaponClass, "OnMisc_Weapon_Reload", false);
}
}
}
public OnMisc_Weapon_Reload( weapon )
{
if( get_pdata_int(weapon, m_fInReload, XO_CBASEPLAYERWEAPON) )
{
return HAM_IGNORED;
}
new id = get_pdata_cbase(weapon, m_pPlayer, XO_CBASEPLAYERITEM);
if( pev(id, pev_button) & IN_USE )
{
return HAM_IGNORED;
}
new iId = get_pdata_int(weapon, m_iId, XO_CBASEPLAYERITEM);
new iClip = get_pdata_int(weapon, m_iClip, XO_CBASEPLAYERWEAPON);
new iMaxClip = g_iMaxClip[iId];
if( iClip == iMaxClip )
{
return HAM_IGNORED;
}
if( iClip > 3 && float(iClip) / float(iMaxClip) > 0.3 )
{
if( get_pdata_int(id, m_afButtonPressed) & IN_RELOAD )
{
engclient_print(id, engprint_center, "^n^nYou don't need to reload^n^nPress +use and +reload^n^nto force reload process^n");
}
ExecuteHam(Ham_CS_Weapon_SendWeaponAnim, weapon, 0, 0);
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
|
Thank you for your help but can't compile! Replaced this line:
PHP Code:
ExecuteHam(Ham_CS_Weapon_SendWeaponAnim, weapon, 0, 0);
with
PHP Code:
ExecuteHam(Ham_Weapon_SendWeaponAnim, weapon, 0, 0);
Compiled succesfully after that but then, when the plugin is running, server crashes when someone press the reload button!
|
|