Thread: Vehicle script
View Single Post
  #1  
Old 08-18-2006, 07:57 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Vehicle script

currently working on a vehicle script that will be able to move in any direction, using cosine and sine.
I have a little something made up, but it turns strange.
I'm not sure how to change this, or what I'm doing wrong. I've never played with cos and sin
PHP Code:
//#CLIENTSIDE
function onKeypressed()
{
  if(
params[1]=="D")
  {
    if(
this.inuse==0)
    {
      
this.speed=0;
      
this.angle=0;
      
this.friction=0;
      
this.inuse=1;
      
onTimeout();
    }
    else
    {
      
this.inuse=0;
      
setani("idle",NULL);
      
freezeplayer(0);
      
settimer(0);
    }
  }
}
function 
onTimeout()
{
  if(
this.speed>0)
  {
    
player.x+=this.speed*cos(this.angle);
    
player.y+=-this.speed*sin(this.angle);
  }
  if(
this.friction==3)
  {
    if(
this.speed>0)
    {
      
this.speed-=.05;
    }
    
this.friction=0;
  }
  
this.friction++;
  
player.chat="Your: Speed: " this.speed " Angle: " this.angle " X: " abs(cos(this.angle)) @ " Y: " abs(sin(this.angle));
  
freezeplayer(.05);
  if(
keydown(0))
  {
    if(
this.speed<0)
    {
      
this.speed=0;
    }
    if(
this.speed<3)
    {
      
this.speed+=.25;
    }
  }
  if(
keydown(1))
  {
    
this.angle-=.05;
  }
  if(
keydown(2))
  {
    
this.speed--;
    
this.speed=int(this.speed);
  }
  if(
keydown(3))
  {
    
this.angle+=.05;
  }
  
degtorad(this.angle);
  
settimer(.05);

Reply With Quote