Advertisement
kemperrs

Untitled

Feb 17th, 2020
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const localPlayer = mp.players.local;
  2. const gameplayCam = mp.cameras.new('gameplay');
  3.  
  4. const requestAnimDict = (string) => {
  5.   mp.game.streaming.requestAnimDict(string);
  6.  
  7.   return new Promise(r => {
  8.     const render = new mp.Event('render', () => {
  9.       if (mp.game.streaming.hasAnimDictLoaded(string)) {
  10.         render.destroy();
  11.         r(true);
  12.       }
  13.     });
  14.   });
  15. };
  16.  
  17. const randomPositionInCircle = (position, radius) => {
  18.   const a = Math.random() * 2 * Math.PI
  19.   const r = radius * Math.sqrt(Math.random());
  20.  
  21.   const x = r * Math.cos(a);
  22.   const y = r * Math.sin(a);
  23.  
  24.   return new mp.Vector3(
  25.     position.x + x,
  26.     position.y + y,
  27.     position.z
  28.   );
  29. };
  30.  
  31. mp.events.add('entityStreamIn', async (entity) => {
  32.   if (entity.type === 'ped' || entity.type === 'player') {
  33.     await requestAnimDict('anim@mp_point');
  34.  
  35.     entity.setConfigFlag(36, true);
  36.     entity.taskMoveNetwork('task_mp_pointing', 0.5, false, 'anim@mp_point', 24);
  37.   }
  38. });
  39.  
  40. mp.peds.new(mp.game.joaat('ig_andreas'), randomPositionInCircle(localPlayer.position, 5), 0, localPlayer.dimension);
  41.  
  42. mp.keys.bind(0x20, false, async () => {
  43.   await requestAnimDict('anim@mp_point');
  44.  
  45.   localPlayer.setConfigFlag(36, true);
  46.   localPlayer.taskMoveNetwork('task_mp_pointing', 0.5, false, 'anim@mp_point', 24);
  47. });
  48.  
  49. mp.events.add('render', () => {
  50.   if (!mp.game.invoke('0x921CE12C489C4C41', localPlayer.handle)) {
  51.     return false;
  52.   }
  53.  
  54.   let camPitch = mp.game.invokeFloat('0x3A6867B4845BEDA2');
  55.  
  56.   if (camPitch < -70.0) {
  57.     camPitch = -70.0;
  58.   } else if (camPitch > 41.9) {
  59.     camPitch = 41.9;
  60.   }
  61.  
  62.   camPitch = (camPitch + 70.0) / 112.0;
  63.  
  64.   let camHeading = mp.game.cam.getGameplayCamRelativeHeading();
  65.  
  66.   const cosCamHeading = Math.cos(camHeading);
  67.   const sinCamHeading = Math.sin(camHeading);
  68.  
  69.   if (camHeading < -180.0) {
  70.     camHeading = -180.0;
  71.   } else if (camHeading > 180.0) {
  72.     camHeading = 180.0;
  73.   }
  74.  
  75.   camHeading = (camHeading + 180) / 360.0;
  76.  
  77.   const coords = localPlayer.getOffsetFromInWorldCoords((cosCamHeading * -0.2) - (sinCamHeading * (0.4 * camHeading + 0.3)), (sinCamHeading * -0.2) + (cosCamHeading * (0.4 * camHeading + 0.3)), 0.6);
  78.   const resultRayCast = mp.raycasting.testPointToPoint(new mp.Vector3(coords.x, coords.y, coords.z - 0.2), new mp.Vector3(coords.x, coords.y, coords.z + 0.2), localPlayer);
  79.  
  80.   const calculateCamHeading = camHeading * -1.0 + 1.0;
  81.   const isBlocked = typeof resultRayCast !== 'undefined';
  82.   const isFirstPerson = mp.game.invoke('0x8D4D46230B2C353A') === 4;
  83.  
  84.   mp.game.invoke('0xD5BB4025AE449A4E', localPlayer.handle, 'Pitch', camPitch);
  85.   mp.game.invoke('0xD5BB4025AE449A4E', localPlayer.handle, 'Heading', calculateCamHeading);
  86.   mp.game.invoke('0xB0A6CFD2C69C1088', localPlayer.handle, 'isBlocked', isBlocked);
  87.   mp.game.invoke('0xB0A6CFD2C69C1088', localPlayer.handle, 'isFirstPerson', isFirstPerson);
  88.  
  89.   mp.peds.forEachInStreamRange(ped => {
  90.     const coords = ped.getCoords(true);
  91.  
  92.     mp.game.graphics.drawText(`${mp.game.invoke('0x921CE12C489C4C41', ped.handle)}`, [coords.x, coords.y, coords.z], {
  93.       font: 4,
  94.       color: [255, 255, 255, 255],
  95.       scale: 0.3,
  96.       outline: true
  97.     });
  98.  
  99.     if (!mp.game.invoke('0x921CE12C489C4C41', ped.handle)) {
  100.       return;
  101.     }
  102.  
  103.     mp.game.invoke('0xD5BB4025AE449A4E', ped.handle, 'Pitch', camPitch);
  104.     mp.game.invoke('0xD5BB4025AE449A4E', ped.handle, 'Heading', calculateCamHeading);
  105.     mp.game.invoke('0xB0A6CFD2C69C1088', ped.handle, 'isBlocked', isBlocked);
  106.     mp.game.invoke('0xB0A6CFD2C69C1088', ped.handle, 'isFirstPerson', isFirstPerson);
  107.   });
  108.  
  109.   mp.players.forEachInStreamRange(player => {
  110.     const coords = player.getCoords(true);
  111.  
  112.     mp.game.graphics.drawText(`${mp.game.invoke('0x921CE12C489C4C41', player.handle)}`, [coords.x, coords.y, coords.z], {
  113.       font: 4,
  114.       color: [255, 255, 255, 255],
  115.       scale: 0.3,
  116.       outline: true
  117.     });
  118.  
  119.     if (!mp.game.invoke('0x921CE12C489C4C41', player.handle)) {
  120.       return;
  121.     }
  122.  
  123.     mp.game.invoke('0xD5BB4025AE449A4E', player.handle, 'Pitch', camPitch);
  124.     mp.game.invoke('0xD5BB4025AE449A4E', player.handle, 'Heading', calculateCamHeading);
  125.     mp.game.invoke('0xB0A6CFD2C69C1088', player.handle, 'isBlocked', isBlocked);
  126.     mp.game.invoke('0xB0A6CFD2C69C1088', player.handle, 'isFirstPerson', isFirstPerson);
  127.   });
  128. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement