hiho when i used following codes, when i press "d" key it makes pan +5 then it makes it -5 again;

Code:
action megamerr()
{


myplayer = me;

	
	
    ph_setgravity (vector(0, 0, -386)); 
    phent_settype (myplayer, PH_RIGID, PH_BOX); 
    phent_setmass (myplayer, 80, PH_BOX); 
    phent_setfriction (myplayer, 20);
   phent_setelasticity (myplayer, 0, 100); // set the elasticity



    while (1)
    {
  
	if(key_d)
	{
		my.pan = my.pan + 5;
	}
	
    	if(key_w)
    	{
    		myplayer_speed.x = 3 ;
        myplayer_speed.y = 0 ;
        myplayer_speed.z = 0; 
        phent_addvelcentral (myplayer, myplayer_speed); 
    		ent_animate(myplayer, "walk", walk_percentage, ANM_CYCLE);
 walk_percentage += 20 * time_step; // 3 = animation speed for "walk"
 
        }

        
            	else if(key_s)
    	{
    		myplayer_speed.x = -3 ;
    		
        myplayer_speed.y = 0 ;
        myplayer_speed.z = 0; 
        phent_addvelcentral (myplayer, myplayer_speed); 
    		ent_animate(myplayer, "walk", walk_percentage, ANM_CYCLE);
 walk_percentage += 20 * time_step; // 3 = animation speed for "walk"


        }
      


      

	        else
        {
        	phent_clearvelocity(myplayer); 
}
        
        
        
        
      
        wait(1);
}



	
}