Advertisement
Guest User

KKashimia

a guest
Dec 4th, 2009
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 KB | None | 0 0
  1. #include <a_samp>
  2. new burnout[MAX_PLAYERS],timer;
  3.  
  4. public OnFilterScriptInit()
  5. {
  6.     timer = SetTimer("BOtimer",100,true);
  7.     return 1;
  8. }
  9.  
  10. public OnFilterScriptExit()
  11. {
  12.     KillTimer(timer);
  13.     return 1;
  14. }
  15.  
  16. public OnPlayerConnect(playerid)
  17. {
  18.     burnout[playerid]=0;
  19.     return 1;
  20. }
  21.  
  22. forward BOtimer();
  23. public BOtimer()
  24. {
  25.     for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
  26.     {
  27.         if(IsPlayerConnected(playerid) && GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
  28.         {
  29.             new keys,leftright,updown;
  30.             GetPlayerKeys(playerid,keys,updown,leftright);
  31.             if(keys == 40)
  32.             {
  33.                 burnout[playerid]++;
  34.             }else if(burnout[playerid]>10 && keys == 8){
  35.                 if(burnout[playerid]>35) burnout[playerid]=35;
  36.                 new Float:speed[2],vehicleid=GetPlayerVehicleID(playerid);
  37.                 GetXYInFrontOfVehicle(vehicleid,speed[0],speed[1],0.007*burnout[playerid]);
  38.                 AccelerateTowardsAPoint(vehicleid,speed[0],speed[1]);
  39.                 burnout[playerid]=0;
  40.             }
  41.         }
  42.     }
  43. }
  44.  
  45. stock GetXYInFrontOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
  46. {       // Created by Y_Less
  47.  
  48.         new Float:a;
  49.         GetVehiclePos(vehicleid, x, y, a);
  50.         GetVehicleZAngle(vehicleid, a);
  51.  
  52.         x += (distance * floatsin(-a, degrees));
  53.         y += (distance * floatcos(-a, degrees));
  54. }
  55.  
  56. stock AccelerateTowardsAPoint(vehicleid,Float:x,Float:y)
  57. {
  58.     new Float:pos[6];
  59.     GetVehicleVelocity(vehicleid,pos[4],pos[5],pos[2]);
  60.     GetVehiclePos(vehicleid,pos[0],pos[1],pos[3]);
  61.     if(GivesSpeed(pos[4],pos[5],pos[2],x-pos[0],y-pos[1],pos[2]))
  62.         SetVehicleVelocity(vehicleid,x-pos[0],y-pos[1],pos[2]);
  63. }
  64.  
  65. stock GivesSpeed(Float:x,Float:y,Float:z,Float:newx,Float:newy,Float:newz) // Checks if one velocity is bigger than another.
  66. {
  67.     if(floatsqroot(floatpower(floatabs(x),2)+floatpower(floatabs(y),2)+floatpower(floatabs(z),2))<floatsqroot(floatpower(floatabs(newx),2)+floatpower(floatabs(newy),2)+floatpower(floatabs(newz),2))) return true;
  68.     return false;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement