Unfortunately set_pev(id, pev_movetype, MOVETYPE_FLY) will not work for some reason so i can offer quite ugly workaround.
Code:
#include <amxmodx>
#include <fakemeta>
public plugin_init() {
register_clcmd("test", "func")
}
public func(id) {
static funcid0, funcid1
if (funcid0) {
unregister_forward(FM_PlayerPreThink, funcid0, 0)
unregister_forward(FM_PlayerPreThink, funcid1, 1)
set_pev(id, pev_movetype, MOVETYPE_WALK)
}
else {
funcid0 = register_forward(FM_PlayerPreThink, "PlayerPreThink", 0)
funcid1 = register_forward(FM_PlayerPreThink, "PlayerPreThink", 1)
set_pev(id, pev_movetype, MOVETYPE_NOCLIP)
}
return PLUGIN_HANDLED
}
public PlayerPreThink(id) {
static Float:origin[3], Float:origin2[3]
origin2 = origin
pev(id, pev_origin, origin)
engfunc(EngFunc_TraceHull, origin, origin, DONT_IGNORE_MONSTERS, HULL_HUMAN, id, 0)
if (!(!get_tr2(0, TR_StartSolid) && !get_tr2(0, TR_AllSolid) && get_tr2(0, TR_InOpen)))
engfunc(EngFunc_SetOrigin, id, origin2)
}
It will allow to fly without noclip effect but in turn it will effect in twitching/blocking of player while in touch.