I created this plugin, but players can still briefly stand up by sending a "-duck" on the console.
I tried EngFunc_SetSize pev_mins pev_maxs pev_size pev_flags pev_button pev_oldbuttons UC_Buttons to change the entity size, but it didn't work.
I also tried hooking the "-duck" command to stop it, but it didn't work either.
Another issue is that in version 182, the bot did not squat down.
PHP Code:
/* UTF-8 func by www.DT-Club.net */
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
static const m_isCrouching;
static const m_jumpTimestamp;
public plugin_init()
{
register_plugin("Testing", "1.0.0", "偶萤蛉(Oinling)");
RegisterHam(Ham_Spawn, "player", "Player_Spawn_Post", 1);
register_forward(FM_PlayerPreThink, "Player_PreThink_Pre");
#if AMXX_VERSION_NUM < 183
SetContantValue(m_isCrouching, 2513);
SetContantValue(m_jumpTimestamp, 2532);
#else
SetContantValue(m_isCrouching, find_ent_data_info("CBot", "m_isCrouching"));
SetContantValue(m_jumpTimestamp, find_ent_data_info("CBot", "m_jumpTimestamp"));
#endif
}
public Player_Spawn_Post(playerEntId)
{
if (!is_user_alive(playerEntId)) return;
if (is_user_bot(playerEntId)) return;
client_cmd(playerEntId, "-duck");
}
public Player_PreThink_Pre(playerEntId)
{
if (!is_user_alive(playerEntId)) return;
if (is_user_bot(playerEntId))
{
set_pdata_bool(playerEntId, m_isCrouching, true);
set_pdata_float(playerEntId, m_jumpTimestamp, get_gametime());
}
else if (!pev(playerEntId, pev_bInDuck) && !(pev(playerEntId, pev_flags) & FL_DUCKING))
{
client_cmd(playerEntId, "+duck");
}
}
static SetContantValue(const &fakeConstant, newValue)
{
setarg(0, .value = newValue);
}
#if AMXX_VERSION_NUM < 183
static set_pdata_bool(ent, charBasedOffset, {_, bool}:value, intBaseLinuxDiff = 5)
{
value &= 0xFF;
new intOffsetValue = get_pdata_int(ent, charBasedOffset / 4, intBaseLinuxDiff);
new bitDecal = (charBasedOffset % 4) * 8;
intOffsetValue &= ~(0xFF << bitDecal); // clear byte
intOffsetValue |= value << bitDecal;
set_pdata_int(ent, charBasedOffset / 4, intOffsetValue, intBaseLinuxDiff);
}
#endif