Hi again,
M having trouble with moving func_wall's, heres my current code :
PHP Code:
public DoGrab(id)
{
if(!UserGrabbing[id])
{
new Ent, EntBody
get_user_aiming(id, Ent, EntBody)
if(Ent)
{
new szClassname[32]
pev(Ent, pev_classname, szClassname, 31)
if(equal(szClassname, "func_wall"))
{
if(!IsGrabbed[Ent])
{
IsGrabbed[Ent]++
UserGrabbing[id] = Ent
set_rendering(Ent, kRenderFxNone, 255, 0, 0, kRenderTransColor, 80)
static Float:origin[2][3];
pev(id, pev_origin, origin[0]);
pev(Ent, pev_origin, origin[1]);
GrabDistance[id] = get_distance_f(origin[0], origin[1]);
}
}
}
}
}
public client_PreThink(id)
{
if(!is_user_alive(id)) return PLUGIN_CONTINUE;
if(!UserGrabbing[id]) return PLUGIN_CONTINUE;
new buttons = pev(id, pev_button);
static Float:origin[2][3], ilook[3], Float:look[3];
static Float:direction[3], Float:moveto[3], Float:grabbedorigin[3];
static Float:velocity[3], Float:length;
get_user_origin(id, ilook, 3);
IVecFVec(ilook, look);
pev(UserGrabbing[id], pev_origin, grabbedorigin);
pev(id, pev_origin, origin[0]);
pev(UserGrabbing[id], pev_origin,origin[1]);
direction[0] = look[0] - origin[0][0];
direction[1] = look[1] - origin[0][1];
direction[2] = look[2] - origin[0][2];
length = get_distance_f(look, origin[0]);
if(!length)
length = 1.0;
moveto[0] = origin[0][0] + direction[0] * GrabDistance[id];
moveto[1] = origin[0][1] + direction[1] * GrabDistance[id];
moveto[2] = origin[0][2] + direction[2] * GrabDistance[id];
velocity[0] = (moveto[0] - origin[1][0]) * 8;
velocity[1] = (moveto[1] - origin[1][1]) * 8;
velocity[2] = (moveto[2] - origin[1][2]) * 8;
set_pev(UserGrabbing[id], pev_velocity, velocity);
if(buttons & IN_ATTACK)
{
set_pev(id, pev_button, buttons & ~IN_ATTACK);
GrabDistance[id] += 7;
}
else if(buttons & IN_ATTACK2)
{
set_pev(id, pev_button, buttons & ~IN_ATTACK2);
GrabDistance[id] -= 7;
if(GrabDistance[id] < MIN_DIST)
GrabDistance[id] = MIN_DIST;
}
return PLUGIN_CONTINUE
}
The entity gets a color, but doesn't move at all. ( no error logs )
I have tried many ways and looked at many plugins like : entmover, jedi grab, grab plugins but nothing seems to work.
Greetings Grim.
__________________