Facebook
From ff, 4 Years ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 333
  1. const names = [
  2.     "avant droite",
  3.     "arrière gauche",
  4.     "arrière droite",
  5. ];
  6.  
  7. const names2 = [
  8.     "avant droit",
  9.     "arrière gauche",
  10.     "arrière droite",
  11. ];
  12.  
  13. HelpText = function(msg)
  14. {
  15.     if (!IsHelpMessageOnScreen())
  16.     {
  17.         // SetTextComponentFormat('STRING')
  18.         // AddTextComponentString(msg)
  19.         // DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  20.     }
  21. }
  22.  
  23. MyClosestVehicle = function(x, y, z, radius)
  24. {
  25.     for (let i = 1; i < 72; i++)
  26.     {
  27.         const angle = (i * 5) * Math.PI / 180;
  28.  
  29.         const sx = (50.0 * Math.cos(angle)) + x;
  30.         const sy = (50.0 * Math.sin(angle)) + y;
  31.  
  32.         const ex = x - (sx - x);
  33.         const ey = y - (sy - y);
  34.  
  35.         const rayHandle = StartShapeTestCapsule(sx, sy, z, ex, ey, z, radius, 10, PlayerPedId(), 1000);
  36.  
  37.         const ent = GetShapeTestResult(rayHandle, false)[4];
  38.  
  39.         return ent;
  40.     }
  41. }
  42.  
  43. setTick(() => {
  44.     let ped = PlayerPedId();
  45.     let pco = GetEntityCoords(ped);
  46.  
  47.     let veh = MyClosestVehicle(pco[0], pco[1], pco[2], 5.0);
  48.  
  49.     if (DoesEntityExist(veh))
  50.     {
  51.         for (let i = 1; i < GetNumberOfVehicleDoors(veh); i++)
  52.         {
  53.             let coord = GetEntryPositionOfDoor(veh, i);
  54.  
  55.             if (Vdist2(pco[0], pco[1], pco[2], coord[0], coord[1], coord[2]) < 0.75 && !DoesEntityExist(GetPedInVehicleSeat(veh, i - 1)) && GetVehicleDoorLockStatus(veh) !== 2)
  56.             {
  57.                 if (names[i - 1] && !IsThisModelABike(GetEntityModel(veh)) && !IsThisModelABoat(GetEntityModel(veh)))
  58.                     HelpText("Appuyez sur ~INPUT_CONTEXT~ pour rentrer par la porte " + names[i - 1]);
  59.                 else if (names2[i - 1] && IsThisModelABike(GetEntityModel(veh)) && IsThisModelABoat(GetEntityModel(veh)))
  60.                     HelpText("Appuyez sur ~INPUT_CONTEXT~ pour rentrer sur le siège " + names2[i - 1]);
  61.                 else
  62.                     HelpText("Appuyez sur ~INPUT_CONTEXT~ pour rentrer par cette porte");
  63.  
  64.                 if (IsControlJustPressed(1, 23))
  65.                 {
  66.                     TaskEnterVehicle(ped, veh, 10000, i - 1, 1.0, 1, 0);
  67.                 }
  68.             }
  69.         }
  70.     }
  71. });
  72.