Iam coding movement by WASD key combine with mouse left. It like when you play game Perfect World International. When I left_click, player will move to target point and target point will disappear. This code is Ok. But when I move player by left_click before, then I press key W or A S D, target point doesn't disappear. I had tried a lot way, but all I lose. This is my code:
Quote:

// Includes

#include <acknex.h>
#include <default.c>
ENTITY* halo;
var ketqua;
var check;
var dist_down;
var temp;
var camera_distance=500;
VECTOR vFeet;
vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
var speed_down = 0;
var walk_speed;
VECTOR pos;
ENTITY* destination;
VECTOR pos1;
VECTOR pos2;
BMAP* crosshair_pcx = "crosshair.pcx";
///////////////////////////////////////////////////////////
function set_target();
function ham_trongluc();
function ham_move_camera();
function show_target();
function hide_target(ENTITY* destination);
///////////////////////////////////////////////////////////
function hide_target(ENTITY* destination)
{
set(destination,INVISIBLE);

// destination=NULL;
//ent_remove(destination);
}
function ham_trongluc()
{
// trace_mode=IGNORE_ME;
// result=trace(vector(my.x,my.y,my.z),vector(my.x,my.y,-370));//so sanh vi tri halo toi be mat
ketqua=c_trace(vector(halo.x,halo.y,halo.z-45),vector(halo.x,halo.y,halo.z-1000),IGNORE_ME);
// draw_text(str_for_num(NULL,ketqua),0,0,vector(255,255,255));
if(ketqua>2)
{

dist_down=halo.z+vFeet.z-target.z;// khoang cach tu chan toi be mat
/* PANEL* pdisplay= {
digits(10,10,5,*,1,dist_down);
flags=VISIBLE;
} */

}
else
{

dist_down=0;
}
if (dist_down > 0) // above floor, fall down with increasing speed
dist_down = clamp(dist_down,0,accelerate(speed_down,5,0.1));// tra ve gia tri giua a va B
//accelerate: gia tang toc do
else // on or below floor, set downward speed to zero
speed_down = 0;
c_move(halo,nullvector,vector(0,0,-dist_down),GLIDE);
}
function ham_move_camera()
{
//draw_text("ngung",0,0,vector(255,255,255));
if(mouse_right)
{
camera.pan -= mouse_force.x * 12 * time_step;
camera.tilt += mouse_force.y * 8 * time_step;
}


// camera xoay trai/phai
//camera xoay len/xuong
if (key_w)
{
// check=c_trace(vector(halo.x,halo.y,halo.z-45),vector(halo.x,halo.y,halo.z-1000),IGNORE_ME);
//set(destination,INVISIBLE);
destination=NULL;
// set(destination,INVISIBLE);
// hide_target(destination);
if(ketqua < 2 && ketqua >=0)
{
c_move(my,vector(10*time_step,0,(halo.z+vFeet.z-target.z)*time_step*0.05),nullvector,GLIDE);
//draw_text("chay",0,0,vector(255,255,255));
}
else
{
c_move(my,vector(10*time_step,0,0),nullvector,GLIDE);//my.x -=10 * time_step;
//draw_text("chay",0,0,vector(255,255,255));
}
// my.x +=10 * time_step;
my.pan=camera.pan;
camera.x=my.x-400;
destination=NULL;
}
if (key_s)
{
// set(destination,INVISIBLE);
destination=NULL;
// hide_target(destination);
if(ketqua < 2 && ketqua >=0)
{
c_move(my,vector(10*time_step,0,(halo.z+vFeet.z-target.z)*time_step*0.05),nullvector,GLIDE);

}
else
c_move(my,vector(10*time_step,0,0),nullvector,GLIDE);//my.x -=10 * time_step;
// my.x -=10 * time_step;
my.pan=camera.pan-180;
camera.x=my.x-400;

}
if (key_d)
{
/// set(destination,INVISIBLE);
destination=NULL;
// hide_target(destination);
if(ketqua < 2 && ketqua >=0)
{
c_move(my,vector(10*time_step,0,(halo.z+vFeet.z-target.z)*time_step*0.05),nullvector,GLIDE);

}
else
c_move(my,vector(10*time_step,0,0),nullvector,GLIDE);

//my.y -= 10*time_step;
my.pan=camera.pan+270;

camera.y=my.y;
}
if (key_a)
{
// set(destination,INVISIBLE);
destination=NULL;
// hide_target(destination);
if(ketqua < 2 && ketqua >=0)
{
c_move(my,vector(10*time_step,0,(halo.z+vFeet.z-target.z)*time_step*0.05),nullvector,GLIDE);

}
else
c_move(my,vector(10*time_step,0,0),nullvector,GLIDE);
//my.y += 10*time_step;
my.pan=camera.pan+90;
camera.y=my.y;
}
// c_move(my,vector(10*time_step,0,0),nullvector,GLIDE);
camera_distance += mickey.z*time_step*2; // mickey.z là 1 bien cua mouse wheel có gia tri 0>>120

/////////////////////////////////////
temp = fcos(camera.tilt,-camera_distance);
// vec_set(camera.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 20 + fsin(camera.tilt,-camera_distance)));//zom sat chan
vec_set(camera.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 50 + fsin(camera.tilt,-camera_distance)));// zoom sat dau
// di chuyen camera xung quanh vat the voi 1 khoang cach
}

function show_target()
{

set(my,PASSABLE);//lite-c // my.PASSABLE = ON;c-script
while (mouse_left == 1) {wait (1);}
while (mouse_left == 0) {wait (1);}
ent_remove (me);
}
void set_target() // hien thi target
{

pos1.x = mouse_pos.x;
pos1.y = mouse_pos.y;
pos1.z = 0;
vec_for_screen (pos1, camera);
pos2.x = mouse_pos.x;
pos2.y = mouse_pos.y;
pos2.z = 20000; // use a big value here
vec_for_screen (pos2, camera);
c_trace(pos1, pos2,IGNORE_ME); // now "target" holds the coordinates of the hit point
destination = ent_create ("cyborg_h2.mdl", target, show_target);
//draw_text(str_for_num(NULL,target),0,0,vector(255,255,255));
}

action player_action()
{
//halo=ent_create("cyborg_h2.mdl",vector(20,-300,100),NULL);

halo=me;
camera.x=my.x-400;// toa do vi tri camera, cai nay ko lien quan goc do ma chi lien quan vi tri
camera.y=my.y;
camera.z=my.z+300;
//camera.pan=;// Xoay theo chieu ngang , gia tri tu 0>>360 , cai nay lien quan toi goc do ma ko lien quan vi tri
camera.tilt=my.tilt-30;
//my.pan=100;
//my=me;

set(my,SHADOW);//my.shadow= ON;

while (1)
{

ham_trongluc();
ham_move_camera();
//ent_animate(my, NULL, 0, 0); // reset all the animations
// walk_speed += 1 * time_step; // increase walk_speed; 1.5 sets the speed
// ent_animate(my, "walk", walk_speed, ANM_CYCLE); // animate the model (use "walk")
if (destination != NULL)
{

vec_set (pos.x, destination.x);// xoay nhan vat di chuyen theo huong con tro
vec_sub (pos.x, my.x);
// draw_text(str_for_num(NULL,pos.x),0,0,vector(255,255,255));
vec_to_angle (my.pan, pos);
my.tilt = 0; //ko bi keo nga laugh don't bow laugh
// check=vec_dist (my.x, destination.x);
// draw_text(str_for_num(NULL,check),0,0,vector(255,255,255));
if (vec_dist (my.x, destination.x) > 50)
{
if(ketqua < 2 && ketqua >=0)
{
c_move(my,vector(10*time_step,0,(halo.z+vFeet.z-target.z)*time_step*0.05),nullvector,GLIDE);
ent_animate(my, "walk", walk_speed, ANM_CYCLE);


}
else
{
c_move(my,vector(10*time_step,0,0),nullvector,GLIDE);//my.x -=10 * time_step;

}

}
else
{

// destination=NULL;

set(destination,INVISIBLE);//destination.INVISIBLE = ON;
// hide_target(destination);

}

}//if(destination !=NULL)

wait (1);
}
}


function main()
{
video_switch(7,0,0);
//video_screen = 1;
//video_mode = 7;

level_load("map1.wmb");
on_mouse_left=set_target;
mouse_mode = 4;
mouse_map=crosshair_pcx;

}


OK, this is full wmp, wld, and my script. I hope someone can help me. Thanks reply! ( I am very interest if someone can disscuss about my code so that I can advance my code )
http://www.mediafire.com/download.php?ooqlzmnxzj3