Hi, can someboy help me with the next code:
PHP Code:
#include AMXMODX
#include ENGINE
new bool:g_bInvertYaw;
public plugin_init()
{
register_clcmd("__weapon__", "__give_weapon__");
register_clcmd("invert_angle", "invert_angle");
}
public invert_angle() g_bInvertYaw = !g_bInvertYaw;
public __give_weapon__(const iPlayer)
{
// It's only for testing purpose; code can be improved a lot, I know :)...
new Float:fCoords[3];
entity_get_vector(iPlayer, EV_VEC_origin, fCoords);
fCoords[2] += 35.0;
new iWeapon = create_entity("info_target");
{
entity_set_origin(iWeapon, fCoords);
entity_set_model(iWeapon, "models/v_ak47.mdl");
entity_set_string(iWeapon, EV_SZ_classname, "__custom_weapon__");
entity_set_edict(iWeapon, EV_ENT_owner, iPlayer);
entity_set_float(iWeapon, EV_FL_nextthink, 0.001);
set_rendering(iWeapon, kRenderFxGlowShell, 255, 0, 255, kRenderNormal, 5);
// I think doesn't necessary explain what it does..
attach_view(iPlayer, iWeapon);
register_think("__custom_weapon__", "__think_custom_weapon__");
}
}
public __think_custom_weapon__(const iEnt)
{
new iOwner = entity_get_edict(iEnt, EV_ENT_owner);
static Float:fCoords[3];
entity_get_vector(iOwner, EV_VEC_origin, fCoords);
entity_set_origin(iEnt, fCoords);
/*
Here I set custom-weapon's angles to the player's view-angles
However even if I reverse they (more precisely the yaw-angle), the up/down view will be reverse "again"
I can't explain better this, so when you test code you will see what i've saying
*/
static Float:fViewAngles[3];
entity_get_vector(iOwner, EV_VEC_v_angle, fViewAngles);
// What I'm doing here is reverse the up/down angle (for testing) but doesn't not have effect
if (g_bInvertYaw)
fViewAngles[0] = -fViewAngles[0];
entity_set_vector(iEnt, EV_VEC_angles, fViewAngles);
entity_set_float(iEnt, EV_FL_nextthink, 0.001);
}
What I was looking for is trying to make a "fake-weapon" for testing purpouse, but I've a problem with weapon-angles
Sorry for my bad english, I really hope somebody helpme with this