Riddick94

NFS U2 nitro bar

Sep 8th, 2013
1,774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.66 KB | None | 0 0
  1. // --- Script has been created by Riddick ---
  2. #include    <a_samp>
  3.  
  4. #define HOLDING(%0)  ((newkeys & (%0)) == (%0))
  5. #define RELEASED(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  6.  
  7. new Float:NITRO_MAX = -180.0;
  8. new Float:VehCurrentNOS[MAX_VEHICLES];
  9.  
  10. new PlayerText:E_PLAYER_NITRO_BAR_TD[3];
  11. new bool:PlayerUsingNitro[MAX_PLAYERS];
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     for(new i = 0; i != MAX_VEHICLES; i++)
  16.     {
  17.         VehCurrentNOS[i] = NITRO_MAX;
  18.     }
  19.     return true;
  20. }
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24.     E_PLAYER_NITRO_BAR_TD[0] = CreatePlayerTextDraw(playerid, 25.937042, 263.416564, "OUTLINE");
  25.     PlayerTextDrawLetterSize(playerid, E_PLAYER_NITRO_BAR_TD[0], 0.0, 17.266113);
  26.     PlayerTextDrawTextSize(playerid, E_PLAYER_NITRO_BAR_TD[0], 4.500000, 0.0);
  27.     PlayerTextDrawAlignment(playerid, E_PLAYER_NITRO_BAR_TD[0], 1);
  28.     PlayerTextDrawColor(playerid, E_PLAYER_NITRO_BAR_TD[0], 0);
  29.     PlayerTextDrawUseBox(playerid, E_PLAYER_NITRO_BAR_TD[0], true);
  30.     PlayerTextDrawBoxColor(playerid, E_PLAYER_NITRO_BAR_TD[0], 255);
  31.     PlayerTextDrawSetShadow(playerid, E_PLAYER_NITRO_BAR_TD[0], 0);
  32.     PlayerTextDrawSetOutline(playerid, E_PLAYER_NITRO_BAR_TD[0], 0);
  33.     PlayerTextDrawFont(playerid, E_PLAYER_NITRO_BAR_TD[0], 0);
  34.  
  35.     E_PLAYER_NITRO_BAR_TD[1] = CreatePlayerTextDraw(playerid, 24.437034, 422.083190, "BLUE_BAR");
  36.     PlayerTextDrawLetterSize(playerid, E_PLAYER_NITRO_BAR_TD[1], 0.0, -18.0);
  37.     PlayerTextDrawTextSize(playerid, E_PLAYER_NITRO_BAR_TD[1], 5.999989, 0.0);
  38.     PlayerTextDrawAlignment(playerid, E_PLAYER_NITRO_BAR_TD[1], 1);
  39.     PlayerTextDrawColor(playerid, E_PLAYER_NITRO_BAR_TD[1], 0);
  40.     PlayerTextDrawUseBox(playerid, E_PLAYER_NITRO_BAR_TD[1], true);
  41.     PlayerTextDrawBoxColor(playerid, E_PLAYER_NITRO_BAR_TD[1], 1085196799);
  42.     PlayerTextDrawSetShadow(playerid, E_PLAYER_NITRO_BAR_TD[1], 0);
  43.     PlayerTextDrawSetOutline(playerid, E_PLAYER_NITRO_BAR_TD[1], 0);
  44.     PlayerTextDrawFont(playerid, E_PLAYER_NITRO_BAR_TD[1], 0);
  45.  
  46.     E_PLAYER_NITRO_BAR_TD[2] = CreatePlayerTextDraw(playerid, 9.0, 261.916931, "N~n~2~n~O");
  47.     PlayerTextDrawLetterSize(playerid, E_PLAYER_NITRO_BAR_TD[2], 0.449999, 1.600000);
  48.     PlayerTextDrawAlignment(playerid, E_PLAYER_NITRO_BAR_TD[2], 1);
  49.     PlayerTextDrawColor(playerid, E_PLAYER_NITRO_BAR_TD[2], 255);
  50.     PlayerTextDrawSetShadow(playerid, E_PLAYER_NITRO_BAR_TD[2], 0);
  51.     PlayerTextDrawSetOutline(playerid, E_PLAYER_NITRO_BAR_TD[2], 0);
  52.     PlayerTextDrawBackgroundColor(playerid, E_PLAYER_NITRO_BAR_TD[2], 51);
  53.     PlayerTextDrawFont(playerid, E_PLAYER_NITRO_BAR_TD[2], 1);
  54.     PlayerTextDrawSetProportional(playerid, E_PLAYER_NITRO_BAR_TD[2], 1);
  55.     return true;
  56. }
  57.  
  58. public OnPlayerStateChange(playerid, newstate, oldstate)
  59. {
  60.     if(newstate == PLAYER_STATE_DRIVER)
  61.     {
  62.         for(new i = 0; i != 3; i++)
  63.         {
  64.             PlayerTextDrawShow(playerid, E_PLAYER_NITRO_BAR_TD[i]);
  65.         }
  66.     }
  67.    
  68.     else
  69.     {
  70.         for(new i = 0; i != 3; i++)
  71.         {
  72.             PlayerTextDrawHide(playerid, E_PLAYER_NITRO_BAR_TD[i]);
  73.         }
  74.     }
  75.     return true;
  76. }
  77.  
  78. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  79. {
  80.     if(HOLDING(KEY_ACTION))PlayerUsingNitro[playerid] = true;
  81.     else if(RELEASED(KEY_ACTION))PlayerUsingNitro[playerid] = false; RemoveVehicleComponent(GetPlayerVehicleID(playerid), 1010);
  82.     return true;
  83. }
  84.  
  85. public OnPlayerUpdate(playerid)
  86. {
  87.     if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  88.     {
  89.         if(PlayerUsingNitro[playerid])
  90.         {
  91.             NITRO_BAR(playerid);
  92.         }
  93.  
  94.         else
  95.         {
  96.             new Float:ST[4];
  97.             new vehicleid = GetPlayerVehicleID(playerid);
  98.             GetVehicleVelocity(vehicleid, ST[0], ST[1], ST[2]);
  99.             ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 179.28625;
  100.  
  101.             if(ST[3] >= 80)
  102.             {
  103.                 if(VehCurrentNOS[vehicleid] >= NITRO_MAX)
  104.                 {
  105.                     VehCurrentNOS[vehicleid] -= 0.5;
  106.                     PlayerTextDrawLetterSize(playerid, E_PLAYER_NITRO_BAR_TD[1], 0.0, VehCurrentNOS[vehicleid] / 10);
  107.                     PlayerTextDrawShow(playerid, E_PLAYER_NITRO_BAR_TD[1]);
  108.                 }
  109.             }
  110.         }
  111.     }
  112.     return true;
  113. }
  114.    
  115. forward NITRO_BAR(playerid);
  116. public  NITRO_BAR(playerid)
  117. {
  118.     new vehicleid = GetPlayerVehicleID(playerid);
  119.     if(VehCurrentNOS[vehicleid] <= -3.5)
  120.     {
  121.         VehCurrentNOS[vehicleid] += 1.0;
  122.         if(!GetVehicleComponentInSlot(vehicleid, GetVehicleComponentType(1010)))
  123.         {
  124.             AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
  125.         }
  126.     }
  127.    
  128.     else
  129.     {
  130.         VehCurrentNOS[vehicleid] = -1.0;
  131.         if(GetVehicleComponentInSlot(vehicleid, GetVehicleComponentType(1010)))
  132.             RemoveVehicleComponent(GetPlayerVehicleID(playerid), 1010);
  133.     }
  134.    
  135.     PlayerTextDrawLetterSize(playerid, E_PLAYER_NITRO_BAR_TD[1], 0.0, VehCurrentNOS[vehicleid] / 10);
  136.     PlayerTextDrawShow(playerid, E_PLAYER_NITRO_BAR_TD[1]);
  137.     return true;
  138. }
Add Comment
Please, Sign In to add comment