Скриптер
Участник
Пользователь
- Сообщения
- 673
- Реакции
- 242
- Помог
- 11 раз(а)
Добрый день!
Реализовал функцию позволяющую менять оружие при помощи var_body
вроде все работает, но столкнулся со следующей проблемой... не работает Бинд Атаки (ПКМ и ЛКМ)
Грешу что виновник
Реализовал функцию позволяющую менять оружие при помощи var_body
вроде все работает, но столкнулся со следующей проблемой... не работает Бинд Атаки (ПКМ и ЛКМ)
Код:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <jbe_core>
#include <hamsandwich>
#include <reapi>
#include <cstrike>
#include <engine>
new g_iGlobalDebug;
#include <util_saytext>
const m_pActiveItem = 373;
#define m_pPlayer 41
#define m_flNextAttack 83
#define linux_diff_weapon 4
#define jbe_is_user_valid(%0) (%0 && %0 <= MaxClients)
#define FormatMain(%0) (iLen = formatex(szMenu, charsmax(szMenu), %0))
#define FormatItem(%0) (iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, %0))
native jbe_get_user_ranks(pId);
native jbe_iduel_status();
new g_iMenuPosition[MAX_PLAYERS + 1];
new g_iPlayerSkins[MAX_PLAYERS + 1];
enum _:DATA_SKIN_INFO
{
SKIN_NAME[32],
V_MODEL[64],
P_MODEL[64],
BODY_NUM[2],
WEAPON_LEVEL[2],
WEAPON_DAMAGE[2]
};
new Array:g_aWeaponSkins, g_iWeaponSkinsCount;
public plugin_init()
{
register_forward(FM_UpdateClientData, "FM_Hook_UpdateClientData_Post", 1);
register_menucmd(register_menuid("Show_WeaponsGuardMenu"), (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9), "Handle_WeaponsGuardMenu");
register_clcmd("say /knife", "openmenu");
RegisterHam(Ham_Item_Deploy, "weapon_knife", "Ham_KnifeDeploy_Post", true);
}
public openmenu(pId) return Cmd_WeaponsGuardMenu(pId);
public plugin_precache()
{
new szCfgDir[64], szCfgFile[128];
get_localinfo("amxx_configsdir", szCfgDir, charsmax(szCfgDir));
formatex(szCfgFile, charsmax(szCfgFile), "%s/jb_engine/knife_systems.ini", szCfgDir);
new file = fopen(szCfgFile, "rt");
if(!file)
{
new error[100];
formatex(error, charsmax(error), "[JBE] Отсутсвтует: %s!", szCfgFile);
set_fail_state(error);
return;
}
g_aWeaponSkins = ArrayCreate(DATA_SKIN_INFO, 1);
new szBuffer[512], aDataSkinInfo[DATA_SKIN_INFO];
while(!feof(file))
{
fgets(file, szBuffer, charsmax(szBuffer));
if(!szBuffer[0] || szBuffer[0] == ';' || szBuffer[0] == '#') continue;
parse(szBuffer,
aDataSkinInfo[SKIN_NAME], charsmax(aDataSkinInfo[SKIN_NAME]),
aDataSkinInfo[V_MODEL], charsmax(aDataSkinInfo[V_MODEL]),
aDataSkinInfo[P_MODEL], charsmax(aDataSkinInfo[P_MODEL]),
aDataSkinInfo[BODY_NUM], charsmax(aDataSkinInfo[BODY_NUM]),
aDataSkinInfo[WEAPON_LEVEL], charsmax(aDataSkinInfo[WEAPON_LEVEL]),
aDataSkinInfo[WEAPON_DAMAGE], charsmax(aDataSkinInfo[WEAPON_DAMAGE])
);
if(file_exists(aDataSkinInfo[V_MODEL])) { precache_model(aDataSkinInfo[V_MODEL]); aDataSkinInfo[V_MODEL] = engfunc(EngFunc_AllocString, aDataSkinInfo[V_MODEL]); }
if(file_exists(aDataSkinInfo[P_MODEL])) { precache_model(aDataSkinInfo[P_MODEL]); aDataSkinInfo[P_MODEL] = engfunc(EngFunc_AllocString, aDataSkinInfo[P_MODEL]); }
//server_print("%s | %s", aDataSkinInfo[SKIN_NAME], aDataSkinInfo[WEAPON_LEVEL]);
ArrayPushArray(g_aWeaponSkins, aDataSkinInfo);
aDataSkinInfo[V_MODEL] = 0;
aDataSkinInfo[P_MODEL] = 0;
}
fclose(file);
g_iWeaponSkinsCount = ArraySize( g_aWeaponSkins );
if(!g_iWeaponSkinsCount /*|| g_iWeaponSkinsCount > 9*/)
{
ArrayDestroy(g_aWeaponSkins);
set_fail_state("[JBE] ERROR. g_iWeaponSkinsCount is empty!");
}
}
public FakeMeta_UpdateClientData_Post(id, iSendWeapons, CD_Handle)
{
set_cd(CD_Handle, CD_ID, 0)
}
Cmd_WeaponsGuardMenu(id) return Show_WeaponsGuardMenu(id, g_iMenuPosition[id] = 0);
Show_WeaponsGuardMenu(id, iPos)
{
if(iPos < 0) return PLUGIN_HANDLED;
new szMenu[512], iLen;
new iKeys = (1<<9), b;
iLen = formatex(szMenu, charsmax(szMenu), "\yВыбора перчаток^n^n");
new aDataSkinInfo[DATA_SKIN_INFO];
for(new a; a < g_iWeaponSkinsCount; a++)
{
ArrayGetArray(g_aWeaponSkins, a, aDataSkinInfo);
if(jbe_get_user_ranks(id) >= str_to_num(aDataSkinInfo[WEAPON_LEVEL]))
{
iKeys |= (1<<b);
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%d. \w%s^n", ++b, aDataSkinInfo[SKIN_NAME]);
}else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%d. \d%s \rНужен %s уровень^n", ++b, aDataSkinInfo[SKIN_NAME], aDataSkinInfo[WEAPON_LEVEL]);
}
for(new i = b; i < 9; i++) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n");
formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n%L \w%L", id, "JBE_KEY", 0, id, "JBE_MENU_EXIT");
return show_menu(id, iKeys, szMenu, -1, "Show_WeaponsGuardMenu");
}
public Handle_WeaponsGuardMenu(pId, iKey)
{
switch(iKey)
{
case 9: return PLUGIN_HANDLED;
default:
{
new aDataSkinInfo[DATA_SKIN_INFO];
ArrayGetArray(g_aWeaponSkins, iKey, aDataSkinInfo);
g_iPlayerSkins[pId] = iKey;
if(has_knife_in_hand(pId))
{
new iActiveItem = get_member(pId, m_pActiveItem);
ExecuteHamB(Ham_Item_Deploy, iActiveItem);
//if(aDataSkinInfo[BODY_NUM]) UTIL_WeaponAnimation(pId, 3, str_to_num(aDataSkinInfo[BODY_NUM]));
}
}
}
return PLUGIN_HANDLED;
}
/*stock UTIL_WeaponAnimation(pPlayer, iAnimation, body = 0)
{
set_entvar(pPlayer, var_weaponanim, iAnimation);
engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0.0, 0.0, 0.0}, pPlayer);
write_byte(iAnimation);
write_byte(body);
server_print("body: %d", body);
message_end();
}*/
stock bool:has_knife_in_hand(id){
if(!jbe_is_user_alive(id)) return false;
new iEnt = get_member(id, m_pActiveItem);
if(!is_entity(iEnt)) return false;
return (get_member(iEnt, m_iId) == WEAPON_KNIFE) ? true : false;
}
public Ham_KnifeDeploy_Post(iEntity)
{
new pId = get_pdata_cbase(iEntity, m_pPlayer, linux_diff_weapon);
if(!jbe_is_user_connected(pId))
return;
new aDataSkinInfo[DATA_SKIN_INFO];
ArrayGetArray(g_aWeaponSkins, g_iPlayerSkins[pId], aDataSkinInfo);
if(aDataSkinInfo[V_MODEL]) set_pev(pId, pev_viewmodel, aDataSkinInfo[V_MODEL]);
if(aDataSkinInfo[P_MODEL]) set_pev(pId, pev_weaponmodel, aDataSkinInfo[P_MODEL]);
set_member( iEntity, m_flLastEventCheck, get_gametime( ) + 0.2 );
}
public FM_Hook_UpdateClientData_Post( iPlayer, SendWeapons, CD_Handle )
{
enum
{
SPEC_MODE,
SPEC_TARGET,
SPEC_END
}; static aSpecInfo[ 33 ][ SPEC_END ];
static Float: flGameTime;
static Float: flLastEventCheck;
static iTarget;
static iSpecMode;
static iActiveItem;
static iId;
iTarget = ( iSpecMode = get_entvar( iPlayer, var_iuser1 ) ) ? get_entvar( iPlayer, var_iuser2 ) : iPlayer;
iActiveItem = get_member( iTarget, m_pActiveItem );
if( iActiveItem == NULLENT )
return FMRES_IGNORED;
iId = get_member( iActiveItem, m_iId );
flGameTime = get_gametime( );
flLastEventCheck = get_member( iActiveItem, m_flLastEventCheck );
if( iId == CSW_KNIFE )
{
new aDataSkinInfo[DATA_SKIN_INFO];
ArrayGetArray(g_aWeaponSkins, g_iPlayerSkins[iPlayer], aDataSkinInfo);
if( iSpecMode )
{
if( aSpecInfo[ iPlayer ][ SPEC_MODE ] != iSpecMode )
{
aSpecInfo[ iPlayer ][ SPEC_MODE ] = iSpecMode;
aSpecInfo[ iPlayer ][ SPEC_TARGET ] = 0;
}
if( iSpecMode == OBS_IN_EYE && aSpecInfo[ iPlayer ][ SPEC_TARGET ] != iTarget )
{
aSpecInfo[ iPlayer ][ SPEC_TARGET ] = iTarget;
SendWeaponAnim( iPlayer, 3, aDataSkinInfo[BODY_NUM] );
}
}
if( !flLastEventCheck )
{
set_cd( CD_Handle, CD_flNextAttack, flGameTime + 0.001 );
set_cd( CD_Handle, CD_WeaponAnim, 3 );
return FMRES_IGNORED;
}
if( flLastEventCheck <= flGameTime )
{
SendWeaponAnim( iTarget, 3, aDataSkinInfo[BODY_NUM]);
set_member( iActiveItem, m_flLastEventCheck, 0.0 );
}
}
return FMRES_IGNORED;
}
stock SendWeaponAnim( iPlayer, iAnim, iBody )
{
static i, iCount, iSpectator, iszSpectators[ MAX_PLAYERS ];
set_entvar( iPlayer, var_weaponanim, iAnim );
message_begin( MSG_ONE, SVC_WEAPONANIM, _, iPlayer );
write_byte( iAnim );
write_byte( iBody );
message_end( );
if( get_entvar( iPlayer, var_iuser1 ) )
return;
get_players( iszSpectators, iCount, "bch" );
for( i = 0; i < iCount; i++ )
{
iSpectator = iszSpectators[ i ];
if( get_entvar( iSpectator, var_iuser1 ) != OBS_IN_EYE )
continue;
if( get_entvar( iSpectator, var_iuser2 ) != iPlayer )
continue;
set_entvar( iSpectator, var_weaponanim, iAnim );
message_begin( MSG_ONE, SVC_WEAPONANIM, _, iSpectator );
write_byte( iAnim );
write_byte( iBody );
message_end( );
}
}
FM_UpdateClientData
, возможно что-то блочит, но без понятия что именно... прошу вашего содействия
Последнее редактирование модератором: