For instance a basic function to move a entity on a flat ground :
PHP Code:
stock npc_MoveToTarget( const npc, const Float: originNpc[ 3 ], const Float: originTarget[ 3 ], const Float: speed )
{
new Float: velocityNpc[ 3 ], Float: length[ 2 ], Float: distance;
length[ 0 ] = originTarget[ 0 ] - originNpc[ 0 ];
length[ 1 ] = originTarget[ 1 ] - originNpc[ 1 ];
distance = floatsqroot( length[ 0 ] * length[ 0 ] + length[ 1 ] * length[ 1 ] );
pev( npc, pev_velocity, velocityNpc );
velocityNpc[ 0 ] = length[ 0 ] * ( speed / distance );
velocityNpc[ 1 ] = length[ 1 ] * ( speed / distance );
set_pev( npc, pev_velocity, velocityNpc );
return ( velocityNpc[ 0 ] || velocityNpc[ 1 ] || velocityNpc[ 2 ] );
}
__________________