SHARE
TWEET

Untitled

a guest Jan 24th, 2020 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. spawnDrivableCar(model)
  2. {
  3.     if(!isDefined(self.car["spawned"]))
  4.     {
  5.         self setClientDvar("cg_thirdPersonRange",300);
  6.         self.car["carModel"] = model;
  7.         self.car["spawned"] = true;
  8.         self.car["runCar"] = true;
  9.         self.car["spawnPosition"] = self.origin + VectorScale(AnglesToForward((0,self getPlayerAngles()[1],self getPlayerAngles()[2])),100);
  10.         self.car["spawnAngles"] = (0,self getPlayerAngles()[1],self getPlayerAngles()[2]);
  11.         self.car["carEntity"] = spawn("script_model",self.car["spawnPosition"]);
  12.         self.car["carEntity"].angles = self.car["spawnAngles"];
  13.         self.car["carEntity"] setModel(self.car["carModel"]);
  14.         wait .2;
  15.         self thread Vehicle_Wait_Think();
  16.     }
  17.     else
  18.     {
  19.         self iPrintln("You Can Only Spawn One Car At A Time!");
  20.     }
  21. }
  22. Vehicle_Wait_Think()
  23. {
  24.     self endon("disconnect");
  25.     self endon("end_car");
  26.     while(self.car["runCar"])
  27.     {
  28.         if(distance(self.origin,self.car["carEntity"].origin)< 120)
  29.         {
  30.             if(self useButtonPressed())
  31.             {
  32.                 if(!self.car["inCar"])
  33.                 {
  34.                     self iPrintln("Press [{+attack}] To Accelerate");
  35.                     self iPrintln("Press [{+speed_throw}] To Reverse/Break");
  36.                     self iPrintln("Press [{+reload}] To Exit Car");
  37.                     self.car["speed"]=0;
  38.                     self.car["inCar"]=true;
  39.                     self disableWeapons();
  40.                     self detachAll();
  41.                     self setOrigin(((self.car["carEntity"].origin)+(AnglesToForward(self.car["carEntity"].angles)* 20)+(0,0,3)));
  42.                     self hide();
  43.                     //self setClientThirdPerson(true);
  44.                     self setClientDvar("camera_thirdPerson",1);
  45.                     self setClientDvar("cg_thirdPerson",1);
  46.                     self setClientDvar("scr_thirdPerson",1);
  47.                     self setPlayerAngles(self.car["carEntity"].angles +(0,0,0));
  48.                     self PlayerLinkTo(self.car["carEntity"]);
  49.                     thread Vehicle_Physics_Think();
  50.                     thread Vehicle_Death_Think();
  51.                     wait 1;
  52.                 }
  53.                 else thread Vehicle_Exit_Think();
  54.             }
  55.         }
  56.         wait .05;
  57.     }
  58. }
  59. Vehicle_Physics_Think()
  60. {
  61.     self endon("disconnect");
  62.     self endon("end_car");
  63.     carPhysics=undefined;
  64.     carTrace=undefined;
  65.     newCarAngles=undefined;
  66.     while(self.car["runCar"])
  67.     {
  68.         carPhysics =((self.car["carEntity"].origin)+((AnglesToForward(self.car["carEntity"].angles)*(self.car["speed"] * 2))+(0,0,100)));
  69.         carTrace=bulletTrace(carPhysics,((carPhysics)-(0,0,130)),false,self.car["carEntity"])["position"];
  70.         if(self attackButtonPressed())
  71.         {
  72.             if(self.car["speed"] < 0)self.car["speed"]=0;
  73.             if(self.car["speed"] < 50)self.car["speed"] += 0.4;
  74.             newCarAngles=vectorToAngles(carTrace - self.car["carEntity"].origin);
  75.             self.car["carEntity"] moveTo(carTrace,0.2);
  76.             self.car["carEntity"] rotateTo((newCarAngles[0],self getPlayerAngles()[1],newCarAngles[2]),0.2);
  77.         }
  78.         else
  79.         {
  80.             if(self.car["speed"] > 0)
  81.             {
  82.                 newCarAngles=vectorToAngles(carTrace - self.car["carEntity"].origin);
  83.                 self.car["speed"] -= 0.7;
  84.                 self.car["carEntity"] moveTo(carTrace,0.2);
  85.                 self.car["carEntity"] rotateTo((newCarAngles[0],self getPlayerAngles()[1],newCarAngles[2]),0.2);
  86.             }
  87.         }
  88.         if(self adsButtonPressed())
  89.         {
  90.             if(self.car["speed"] > -20)
  91.             {
  92.                 if(self.car["speed"] < 0)newCarAngles=vectorToAngles(self.car["carEntity"].origin - carTrace);
  93.                 self.car["speed"] -= 0.5;
  94.                 self.car["carEntity"] moveTo(carTrace,0.2);
  95.             }
  96.             else self.car["speed"] += 0.5;
  97.             self.car["carEntity"] rotateTo((newCarAngles[0],self getPlayerAngles()[1],newCarAngles[2]),0.2);
  98.         }
  99.         else
  100.         {
  101.             if(self.car["speed"] < -1)
  102.             {
  103.                 if(self.car["speed"] < 0)newCarAngles=vectorToAngles(self.car["carEntity"].origin - carTrace);
  104.                 self.car["speed"] += 0.8;
  105.                 self.car["carEntity"] moveTo(carTrace,0.2);
  106.                 self.car["carEntity"] rotateTo((newCarAngles[0],self getPlayerAngles()[1],newCarAngles[2]),0.2);
  107.             }
  108.         }
  109.         wait 0.05;
  110.     }
  111. }
  112. Vehicle_Death_Think()
  113. {
  114.     self endon("disconnect");
  115.     self endon("end_car");
  116.     self waittill("death");
  117.     if(self.car["inCar"])thread Vehicle_Exit_Think();
  118.     else self.car["carEntity"] delete();
  119.     wait 0.2;
  120. }
  121. Vehicle_Exit_Think()
  122. {
  123.     self.car["speed"]=0;
  124.     self.car["inCar"]=false;
  125.     self.car["runCar"]=false;
  126.     self.car["spawned"]=undefined;
  127.     self.car["carEntity"] delete();
  128.     self unlink();
  129.     self enableWeapons();
  130.     self show();
  131.     //self setClientThirdPerson(false);
  132.     self setClientDvar("camera_thirdPerson",0);
  133.     self setClientDvar("cg_thirdPerson",0);
  134.     self setClientDvar("scr_thirdPerson",0);
  135.     wait 0.3;
  136.     self notify("end_car");
  137. }
  138. traceBulletCar(distance)
  139. {
  140.     if(!isDefined(distance))distance=10000000;
  141.     return bulletTrace(self getEye(),self getEye()+ vectorScale(AnglesToForward(self getPlayerAngles()),distance),false,self)["position"];
  142. }
  143. vectorScale(vector,scale)
  144. {
  145.     return(vector[0]*scale,vector[1]*scale,vector[2]*scale);
  146. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top