So, first I tried to rip out the missle code to another plugin, this is what I got:
PHP Code:
#include <amxmodx>
#include <engine>
new user_controll[33];
public plugin_init()
{
register_plugin("test", "1.0", "Sebxx");
register_touch("predator", "*", "touchedpredator");
register_clcmd("say /test", "CreatePredator");
}
public plugin_precache()
{
precache_model("models/cod_predator.mdl");
}
public CreatePredator(id)
{
new Float:Origin[3], Float:Angle[3], Float:Velocity[3], ent;
velocity_by_aim(id, 700, Velocity);
if ( !is_valid_ent(id) )
return;
entity_get_vector(id, EV_VEC_origin, Origin);
entity_get_vector(id, EV_VEC_v_angle, Angle);
Angle[0] *= -1.0;
ent = create_entity("func_breakable");
DispatchKeyValue(ent, "health", 1);
DispatchKeyValue(ent, "material", "6");
entity_set_string(ent, EV_SZ_classname, "predator");
entity_set_model(ent, "models/cod_predator.mdl");
entity_set_float(ent, EV_FL_takedamage, DAMAGE_YES);
entity_set_int(ent, EV_INT_solid, SOLID_SLIDEBOX);
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS);
entity_set_edict(ent, EV_ENT_owner, id);
entity_set_origin(ent, Origin);
entity_set_vector(ent, EV_VEC_velocity, Velocity);
entity_set_vector(ent, EV_VEC_angles, Angle);
attach_view(id, ent);
user_controll[id] = ent;
}
public touchedpredator(ent, id)
{
new owner = entity_get_edict(ent, EV_ENT_owner);
attach_view(owner, owner);
user_controll[owner] = 0;
return PLUGIN_CONTINUE;
}
public client_PreThink(id)
{
if(user_controll[id])
{
new ent2 = user_controll[id];
if(is_valid_ent(ent2))
{
new Float:Velocity[3], Float:Angle[3];
velocity_by_aim(id, 500, Velocity);
if ( !is_valid_ent(id) )
return PLUGIN_CONTINUE;
entity_get_vector(id, EV_VEC_v_angle, Angle);
entity_set_vector(ent2, EV_VEC_velocity, Velocity);
entity_set_vector(ent2, EV_VEC_angles, Angle);
}
else
attach_view(id, id);
}
return PLUGIN_CONTINUE;
}
It basicly works, I can control the missle and view is attached back to player after collision with something. I tried to change a few things, set it's HP to 1, but still cannot shoot this missle down :/
Could somebody have a look at it?