Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const localPlayer = mp.players.local;
- const gameplayCam = mp.cameras.new('gameplay');
- const requestAnimDict = (string) => {
- mp.game.streaming.requestAnimDict(string);
- return new Promise(r => {
- const render = new mp.Event('render', () => {
- if (mp.game.streaming.hasAnimDictLoaded(string)) {
- render.destroy();
- r(true);
- }
- });
- });
- };
- const randomPositionInCircle = (position, radius) => {
- const a = Math.random() * 2 * Math.PI
- const r = radius * Math.sqrt(Math.random());
- const x = r * Math.cos(a);
- const y = r * Math.sin(a);
- return new mp.Vector3(
- position.x + x,
- position.y + y,
- position.z
- );
- };
- mp.events.add('entityStreamIn', async (entity) => {
- if (entity.type === 'ped' || entity.type === 'player') {
- await requestAnimDict('anim@mp_point');
- entity.setConfigFlag(36, true);
- entity.taskMoveNetwork('task_mp_pointing', 0.5, false, 'anim@mp_point', 24);
- }
- });
- mp.peds.new(mp.game.joaat('ig_andreas'), randomPositionInCircle(localPlayer.position, 5), 0, localPlayer.dimension);
- mp.keys.bind(0x20, false, async () => {
- await requestAnimDict('anim@mp_point');
- localPlayer.setConfigFlag(36, true);
- localPlayer.taskMoveNetwork('task_mp_pointing', 0.5, false, 'anim@mp_point', 24);
- });
- mp.events.add('render', () => {
- if (!mp.game.invoke('0x921CE12C489C4C41', localPlayer.handle)) {
- return false;
- }
- let camPitch = mp.game.invokeFloat('0x3A6867B4845BEDA2');
- if (camPitch < -70.0) {
- camPitch = -70.0;
- } else if (camPitch > 41.9) {
- camPitch = 41.9;
- }
- camPitch = (camPitch + 70.0) / 112.0;
- let camHeading = mp.game.cam.getGameplayCamRelativeHeading();
- const cosCamHeading = Math.cos(camHeading);
- const sinCamHeading = Math.sin(camHeading);
- if (camHeading < -180.0) {
- camHeading = -180.0;
- } else if (camHeading > 180.0) {
- camHeading = 180.0;
- }
- camHeading = (camHeading + 180) / 360.0;
- const coords = localPlayer.getOffsetFromInWorldCoords((cosCamHeading * -0.2) - (sinCamHeading * (0.4 * camHeading + 0.3)), (sinCamHeading * -0.2) + (cosCamHeading * (0.4 * camHeading + 0.3)), 0.6);
- 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);
- const calculateCamHeading = camHeading * -1.0 + 1.0;
- const isBlocked = typeof resultRayCast !== 'undefined';
- const isFirstPerson = mp.game.invoke('0x8D4D46230B2C353A') === 4;
- mp.game.invoke('0xD5BB4025AE449A4E', localPlayer.handle, 'Pitch', camPitch);
- mp.game.invoke('0xD5BB4025AE449A4E', localPlayer.handle, 'Heading', calculateCamHeading);
- mp.game.invoke('0xB0A6CFD2C69C1088', localPlayer.handle, 'isBlocked', isBlocked);
- mp.game.invoke('0xB0A6CFD2C69C1088', localPlayer.handle, 'isFirstPerson', isFirstPerson);
- mp.peds.forEachInStreamRange(ped => {
- const coords = ped.getCoords(true);
- mp.game.graphics.drawText(`${mp.game.invoke('0x921CE12C489C4C41', ped.handle)}`, [coords.x, coords.y, coords.z], {
- font: 4,
- color: [255, 255, 255, 255],
- scale: 0.3,
- outline: true
- });
- if (!mp.game.invoke('0x921CE12C489C4C41', ped.handle)) {
- return;
- }
- mp.game.invoke('0xD5BB4025AE449A4E', ped.handle, 'Pitch', camPitch);
- mp.game.invoke('0xD5BB4025AE449A4E', ped.handle, 'Heading', calculateCamHeading);
- mp.game.invoke('0xB0A6CFD2C69C1088', ped.handle, 'isBlocked', isBlocked);
- mp.game.invoke('0xB0A6CFD2C69C1088', ped.handle, 'isFirstPerson', isFirstPerson);
- });
- mp.players.forEachInStreamRange(player => {
- const coords = player.getCoords(true);
- mp.game.graphics.drawText(`${mp.game.invoke('0x921CE12C489C4C41', player.handle)}`, [coords.x, coords.y, coords.z], {
- font: 4,
- color: [255, 255, 255, 255],
- scale: 0.3,
- outline: true
- });
- if (!mp.game.invoke('0x921CE12C489C4C41', player.handle)) {
- return;
- }
- mp.game.invoke('0xD5BB4025AE449A4E', player.handle, 'Pitch', camPitch);
- mp.game.invoke('0xD5BB4025AE449A4E', player.handle, 'Heading', calculateCamHeading);
- mp.game.invoke('0xB0A6CFD2C69C1088', player.handle, 'isBlocked', isBlocked);
- mp.game.invoke('0xB0A6CFD2C69C1088', player.handle, 'isFirstPerson', isFirstPerson);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement