Advertisement
Guest User

Untitled

a guest
Mar 29th, 2024
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global.entity = null;
  2. global.nearestObject = null;
  3. global.boosted = false;
  4. import { TogglePlayerCameraSide, SetCameraLook, camera_hand_player_active } from './lefthandpeek.js';
  5.  
  6. var lastEntCheck = 0;
  7. var checkInterval = 200;
  8.  
  9. var backlightColor = [196, 17, 21];
  10.  
  11. global.cuffed = false;
  12.  
  13. global.isInSafeZone = false;
  14. global.isInCity = false;
  15.  
  16. var lastCuffUpdate = new Date().getTime();
  17. var lastTyreUpdate = new Date().getTime();
  18.  
  19. gm.events.add('CUFFED', function (argument) {
  20.     try
  21.     {
  22.         global.cuffed = argument;
  23.     }
  24.     catch (e)
  25.     {
  26.         mp.events.callRemote("client_trycatch", "player/render", "CUFFED", e.toString());
  27.     }
  28. });
  29. /*
  30. var safezonetimeout = null;
  31.  
  32. gm.events.add('safeZone', function (argument) {
  33.     try
  34.     {
  35.         global.isInSafeZone = argument;
  36.         mp.gui.emmit(`window.hudStore.greenZone (${argument})`);
  37.         if(global.isAdmin === true) return;
  38.         if(!argument)
  39.         {
  40.             if(safezonetimeout != null)
  41.             {
  42.                 clearTimeout(safezonetimeout);
  43.                 safezonetimeout = null;
  44.             }
  45.             global.localplayer.setInvincible(false);
  46.             mp.events.callRemote('IsSafeZone', false);
  47.             return;
  48.         }
  49.         else
  50.         {
  51.             if(safezonetimeout == null)
  52.             {
  53.                 safezonetimeout = setTimeout(function ()
  54.                 {
  55.                     if(global.isInSafeZone) {
  56.                         global.localplayer.setInvincible(true);
  57.                         mp.events.callRemote('IsSafeZone', true);
  58.                     }
  59.                     if(safezonetimeout != null)
  60.                     {
  61.                         clearTimeout(safezonetimeout);
  62.                         safezonetimeout = null;
  63.                     }
  64.                 },  15000);
  65.             }
  66.         }
  67.     }
  68.     catch (e)
  69.     {
  70.         mp.events.callRemote("client_trycatch", "player/render", "safeZone", e.toString());
  71.     }
  72. });*/
  73.  
  74. gm.events.add('insideCity', function (argument) {
  75.     global.isInCity = argument;
  76. });
  77.  
  78. global.binderFunctions.openCircleMenu = () => {// G key
  79.     try
  80.     {
  81.         if (global.menuCheck() || global.isDemorgan == true || global.attachedtotrunk || global.isDeath == true || (global.inAirsoftLobby !== undefined && global.inAirsoftLobby >= 0) || new Date().getTime() - global.lastCheck < 1000) return;
  82.  
  83.         if (global.localplayer.vehicle) {
  84.             global.entity = global.localplayer.vehicle;
  85.             global.OpenCircle(translateText("В машине"), 0, global.entity);
  86.             return;
  87.         }
  88.  
  89.         global.entity = GetLooking (false, true);
  90.  
  91.         if (!global.loggedin || global.chatActive || global.entity == null || !global.entity.doesExist()) {
  92.             //global.OpenCircle(translateText("Я"), 0);
  93.             return;
  94.         }
  95.  
  96.         global.lastCheck = new Date().getTime();
  97.  
  98.         switch (global.entity.type) {
  99.             case "object":
  100.                 if (global.entity != null && global.entity.doesExist() && global.entity.isAnObject() && global.entity['dropData'] && global.entity['dropData'].pId !== undefined) {
  101.                    
  102.                     switch (global.entity['dropData'].ItemId) {
  103.                         case 249:
  104.                             global.OpenCircle(translateText("Кальян"), 0, global.entity);
  105.                             break;
  106.                         default:
  107.                             mp.gui.cursor.visible = true;
  108.                             break;
  109.                     }
  110.                 }
  111.                 return;
  112.             case "player":
  113.                 if(global.GetGender (global.entity) !== -1) {
  114.                     mp.gui.cursor.visible = true;
  115.                     global.OpenCircle(translateText("Игрок"), 0, global.entity);
  116.                 }
  117.                 return;
  118.             case "vehicle":
  119.                 mp.gui.cursor.visible = true;
  120.                 global.OpenCircle(translateText("Машина"), 0, global.entity);
  121.                 return;
  122.             default:
  123.                 //global.OpenCircle(translateText("Я"), 0);
  124.                 return;
  125.         }
  126.     }
  127.     catch (e)
  128.     {
  129.         mp.events.callRemote("client_trycatch", "player/render", "global.binderFunctions.openCircleMenu", e.toString());
  130.     }
  131. };
  132.  
  133. global.binderFunctions.dropObject = () => {// F2 key
  134.     try
  135.     {
  136.         if (global.menuCheck() || global.isDeath == true || global.isDemorgan == true || global.attachedtotrunk)
  137.             return;
  138.         // player
  139.         if (global.circleOpen) {
  140.             global.CloseCircle();
  141.             return;
  142.         }
  143.        
  144.         global.entity = GetLooking (true, true);
  145.  
  146.         if (!global.loggedin || global.chatActive || global.entity == null || new Date().getTime() - global.lastCheck < 1000)
  147.             return;
  148.  
  149.         global.lastCheck = new Date().getTime();
  150.         if (global.entity != null && global.entity.doesExist() && global.entity.type == 'object' && global.entity.isAnObject()) {              
  151.             if (global.entity['furniture'])
  152.                 mp.events.callRemote('oSelected', global.entity.remoteId);
  153.             else if (global.entity['dropData'] && global.entity['dropData'].pId === undefined)
  154.                 mp.events.callRemote('server.raise', global.entity);
  155.         } /*else if (global.entity && mp.players.exists(global.entity)) {
  156.             if(global.GetGender (global.entity) !== -1) {
  157.                 mp.gui.cursor.visible = true;
  158.                 global.OpenCircle(translateText("Игрок"), 0, global.entity);
  159.             }
  160.         }*/
  161.     }
  162.     catch (e)
  163.     {
  164.         mp.events.callRemote("client_trycatch", "player/render", "global.binderFunctions.dropObject", e.toString());
  165.     }
  166. };
  167.  
  168. var engpm = 0;
  169. var engtm = 1;
  170. gm.events.add('svem', (pm, tm) =>
  171. {
  172.     engpm = pm;
  173.     engtm = tm;
  174. });
  175.  
  176.  
  177.  
  178. /*
  179. const systemdata = mp.system;
  180. systemdata.isFocused
  181. */
  182.  
  183. const WEAPON_STUNGAN = mp.game.joaat("weapon_stungun");
  184.  
  185. const isNotAttack = () => {
  186.     if ([7, 9].includes (global.fractionId) && [911657153].includes (global.weaponData.weapon))
  187.         return false;
  188.     else if ([600439132, 126349499, WEAPON_STUNGAN].includes (global.weaponData.weapon))
  189.         return false;
  190.     else if (global.isInSafeZone)
  191.         return true;
  192.     else if (global.isDemorgan == true)
  193.         return true;
  194.     else if (global.attachedtotrunk)
  195.         return true;
  196.     else if (global.dmgdisabled)
  197.         return true;
  198.    
  199.     return false;
  200. }
  201.  
  202. gm.events.add("render", () => {
  203.     if (!global.loggedin) return;
  204.     mp.game.invoke('0x9E4CFFF989258472'); // void _INVALIDATE_VEHICLE_IDLE_CAM();
  205.     mp.game.invoke('0xF4F2C0D4EE209E20'); // void INVALIDATE_IDLE_CAM();
  206.     mp.events.call("SetCorrectChatStates", 0);
  207.     setInterval(() => {
  208.         mp.game.invoke('0x9E4CFFF989258472'); // void _INVALIDATE_VEHICLE_IDLE_CAM();
  209.         mp.game.invoke('0xF4F2C0D4EE209E20'); // void INVALIDATE_IDLE_CAM();
  210.       }, 25000);
  211.     if (global.freeze) {
  212.         global.ToggleFightControls();
  213.         global.ToggleMovementControls();
  214.     }
  215.  
  216.     mp.game.player.restoreStamina(100);
  217.     global.localplayer.setRagdollFlag(2);
  218.     global.localplayer.setAccuracy(0);
  219.     mp.game.player.setHealthRechargeMultiplier(0.0);
  220.     mp.game.player.setLockonRangeOverride(1.5);
  221.     mp.game.controls.disableControlAction(1, 7, true); // SlowMo в машине
  222.  
  223.     //thanks to kemperrr
  224.     if (mp.game.invoke(getNative('IS_CUTSCENE_ACTIVE')))
  225.         mp.game.invoke(getNative('STOP_CUTSCENE_IMMEDIATELY'));
  226.     if (mp.game.invoke(getNative('GET_RANDOM_EVENT_FLAG')))
  227.         mp.game.invoke(getNative('SET_RANDOM_EVENT_FLAG'), false);
  228.     if (mp.game.invoke(getNative('GET_MISSION_FLAG')))
  229.         mp.game.invoke(getNative('SET_MISSION_FLAG'), false);
  230.  
  231.     if (pocketEnabled)
  232.         mp.game.controls.disableControlAction(2, 0, true);
  233.  
  234.     if (isNotAttack ())
  235.     {
  236.         mp.game.controls.disableControlAction(2, 24, true);
  237.         mp.game.controls.disableControlAction(2, 69, true);
  238.         mp.game.controls.disableControlAction(2, 70, true);
  239.         mp.game.controls.disableControlAction(2, 92, true);
  240.         mp.game.controls.disableControlAction(2, 114, true);
  241.         mp.game.controls.disableControlAction(2, 121, true);
  242.         mp.game.controls.disableControlAction(2, 140, true);
  243.         mp.game.controls.disableControlAction(2, 141, true);
  244.         mp.game.controls.disableControlAction(2, 142, true);
  245.         mp.game.controls.disableControlAction(2, 257, true);
  246.         mp.game.controls.disableControlAction(2, 263, true);
  247.         mp.game.controls.disableControlAction(2, 264, true);
  248.         mp.game.controls.disableControlAction(2, 331, true);
  249.         mp.game.player.disableFiring(true);
  250.     }
  251.     if (global.localplayer.isInAnyVehicle(false) && global.localplayer.vehicle)
  252.     {
  253.         let mvs = global.localplayer.vehicle;
  254.         if(mvs.getPedInSeat(-1) == global.localplayer.handle)
  255.         {
  256.             let mvsclass = mvs.getClass();
  257.             mvs.setTyresCanBurst(true);
  258.             if(engtm != 1) mvs.setEngineTorqueMultiplier(engtm);
  259.             if(engpm == 0)
  260.             {
  261.                 if (new Date().getTime() - lastTyreUpdate >= 1000)
  262.                 {
  263.                     lastTyreUpdate = new Date().getTime();
  264.                     if(mvsclass != 8 && mvsclass != 13 && (mvs.isTyreBurst(4, true) || mvs.isTyreBurst(5, true))) mvs.setEnginePowerMultiplier(-90);
  265.                     else
  266.                     {
  267.                         if(global.isInCity) mvs.setEnginePowerMultiplier(-40);
  268.                         else if(global.boosted) mvs.setEnginePowerMultiplier(20);
  269.                         else mvs.setEnginePowerMultiplier(0);
  270.                     }
  271.                 }
  272.             } else mvs.setEnginePowerMultiplier(engpm);
  273.             if(mvs.isInAir() && global.localplayer.isInAnyPlane()) mp.game.controls.disableControlAction(0, global.Inputs.VEH_FLY_THROTTLE_DOWN, true);
  274.         }
  275.     } else if (global.cuffed && !global.localplayer.vehicle && new Date().getTime() - lastCuffUpdate >= 3000) {
  276.         mp.events.callRemote("cuffUpdate");
  277.         lastCuffUpdate = new Date().getTime();
  278.     }
  279.  
  280.     if (global.afkStatus) {
  281.         mp.game.graphics.drawText(translateText("Вам установлен статус AFK"), [0.5, 0.9], {
  282.             font: 4,
  283.             color: [255, 255, 255, 255],
  284.             scale: [0.4, 0.4],
  285.             centre: true,
  286.         });
  287.     }
  288. });
  289.  
  290.  
  291. //*************************************************************** */
  292.  
  293. const activeResolution = mp.game.graphics.getScreenActiveResolution(1, 1);
  294.  
  295. const getEntityPointToPoint = (flags) => {
  296.     const getBoneCoords = mp.players.local.getBoneCoords(12844, 0.5, 0, 0);
  297.  
  298.     const screen2dToWorld3d = mp.game.graphics.screen2dToWorld3d([
  299.         activeResolution.x / 2,
  300.         activeResolution.y / 2,
  301.         2 | 4 | 8
  302.     ]);
  303.  
  304.     if (!screen2dToWorld3d)
  305.         return null;
  306.  
  307.     getBoneCoords.z -= 0.3;
  308.  
  309.     const testPointToPoint = mp.raycasting.testPointToPoint(getBoneCoords, screen2dToWorld3d, mp.players.local, flags);
  310.  
  311.     if (testPointToPoint) {        
  312.         if (testPointToPoint.entity.type === void(0))
  313.             return null;
  314.            
  315.         return testPointToPoint.entity;
  316.     }
  317.     return null;
  318. }
  319.  
  320. const getLookingAtEntity = () => {
  321.     try {
  322.         const testPointToPoint = getEntityPointToPoint (global.RAYCASTING_FLAGS.vehicles | global.RAYCASTING_FLAGS.players | global.RAYCASTING_FLAGS.players2 | global.RAYCASTING_FLAGS.objects);
  323.  
  324.         if (testPointToPoint) {        
  325.             if (testPointToPoint.type !== "player" && testPointToPoint.type !== "vehicle")
  326.                 return null;
  327.  
  328.             const ePosition = testPointToPoint.position;
  329.             const pPosition = localplayer.position;
  330.    
  331.             if (mp.game.gameplay.getDistanceBetweenCoords(ePosition.x, ePosition.y, ePosition.z, pPosition.x, pPosition.y, pPosition.z, true) > 6.0)
  332.                 return null;
  333.    
  334.             return testPointToPoint;
  335.         }
  336.     }
  337.     catch (e)
  338.     {
  339.         mp.events.callRemote("client_trycatch", "player/render", "getLookingAtEntity", e.toString());
  340.     }
  341.    
  342.     return null;
  343. }
  344.  
  345. global.clearScript = (entity) => {
  346.     if (typeof(entity) === 'number' && entity !== 0/* && mp.game.entity.isAnObject(entity)*/)
  347.         mp.game.shapetest.releaseScriptGuidFromEntity(entity);
  348. }
  349.  
  350. const getNearestLookingObject = () => {
  351.     try {
  352.         let getBoneCoords = localplayer.getBoneCoords(12844, 0.5, 0, 0);
  353.  
  354.         const screen2dToWorld3d = mp.game.graphics.screen2dToWorld3d([
  355.             activeResolution.x / 2,
  356.             activeResolution.y / 2,
  357.             2 | 4 | 8
  358.         ]);
  359.  
  360.         if (!screen2dToWorld3d)
  361.             return null;   
  362.            
  363.         getBoneCoords.z -= 0.3;
  364.    
  365.         const testPointToPoint = mp.raycasting.testPointToPoint(getBoneCoords, screen2dToWorld3d, global.localplayer, -1);
  366.         if (!testPointToPoint)
  367.             return null;
  368.  
  369.         const
  370.             position = testPointToPoint.position,
  371.             objects = [];
  372.  
  373.         //global.clearScript (testPointToPoint.entity);
  374.  
  375.         mp.objects.forEachInStreamRangeItems(object => {
  376.             const getCoords = object.getCoords(true),
  377.                 objectDist = global.vdist2(position, getCoords),
  378.                 playerDist = global.vdist2(global.localplayer.position, getCoords);
  379.             if (objectDist <= 2.2 && playerDist <= 3.0) {
  380.                 objects.push({
  381.                     'distance': objectDist,
  382.                     'entity': object
  383.                 });
  384.             }
  385.         });
  386.         const object = objects.sort((object1, object2) => object1.distance - object2.distance)[0];
  387.        
  388.         return object ? object.entity : null;
  389.     }
  390.     catch (e)
  391.     {
  392.         mp.events.callRemote("client_trycatch", "player/render", "getNearestLookingObject", e.toString());
  393.     }
  394. }
  395.  
  396.  
  397. gm.events.add(global.renderName ["500ms"], () => {
  398.     if (!global.loggedin) return;
  399.     GetLooking ();
  400. });
  401.  
  402. gm.events.add(global.renderName ["2.5ms"], () => {
  403.     if (!global.loggedin) return;
  404.     GetLooking (true);
  405. });
  406.  
  407. let antiFloodLooking = 0;
  408.  
  409. const GetLooking = (isObj = false, isBtn = false) => {
  410.     try {
  411.         if (!global.loggedin)
  412.             return null;
  413.         else if (antiFloodLooking > new Date().getTime())
  414.             return global.entity;
  415.  
  416.         /*if (!isBtn && global.entity !== null && global.entity.doesExist()) {
  417.  
  418.             const ePosition = global.entity.position;
  419.             const pPosition = localplayer.position;
  420.    
  421.             //if (mp.game.gameplay.getDistanceBetweenCoords(ePosition.x, ePosition.y, ePosition.z, pPosition.x, pPosition.y, pPosition.z, true) <= 3.0) return global.entity;
  422.         }
  423.         */
  424.  
  425.  
  426.         antiFloodLooking = new Date().getTime() + 250;
  427.  
  428.         if (!global.localplayer.vehicle) {
  429.             let getEntity = null;
  430.  
  431.             if (!isObj)
  432.                 getEntity = getLookingAtEntity();
  433.            
  434.             if ((getEntity || ((isObj || isBtn) && (getEntity = getNearestLookingObject()))) && getEntity && getEntity.type && [
  435.                 "vehicle",
  436.                 "object",
  437.                 "player"
  438.             ].includes(getEntity.type)) {
  439.                 if (getEntity === global.entity)
  440.                     return getEntity;
  441.                 if ("player" === getEntity.type && !global.localplayer.hasClearLosTo(getEntity.handle, 17)) {
  442.                     global.entity = null;
  443.                     return null;
  444.                 }
  445.                 if ("vehicle" === getEntity.type && getEntity.getVariable("isDrone")) {
  446.                     global.entity = null;
  447.                     return null;
  448.                 }
  449.                 if ("player" === getEntity.type && (getEntity['INVISIBLE'] || global.GetGender (getEntity) === -1)) {
  450.                     global.entity = null;
  451.                     return null;
  452.                 }
  453.  
  454.                 global.entity = getEntity;
  455.                
  456.                 return getEntity;
  457.             }
  458.         }/* else {
  459.             mp.players.forEachInStreamRange(player => {
  460.                 if(player !== global.localplayer && global.localplayer.vehicle == )
  461.             });
  462.         }*/
  463.         global.entity = null;
  464.     }
  465.     catch (e)
  466.     {
  467.         if(new Date().getTime() - global.trycatchtime["player/render1"] < 60000) return;
  468.         global.trycatchtime["player/render1"] = new Date().getTime();
  469.         mp.events.callRemote("client_trycatch", "player/render", "time.5s", e.toString());
  470.     }
  471.     return null;
  472. };
  473.  
  474.  
  475. const colorsData = [
  476.     [255, 255, 255]
  477. ];
  478.  
  479. let markerToPlayer = null;
  480. let markerRotation = 360;
  481.  
  482. let focusObject = null;
  483.  
  484. gm.events.add("render", () => {
  485.     if (!global.loggedin) return;
  486.     //else if (!global.showhud) return;
  487.  
  488.     if (markerToPlayer)
  489.         markerToPlayer.destroy(),
  490.         markerToPlayer = null;
  491.  
  492.     if (global.entity && (!global.entity.doesExist() || global.entity['INVISIBLE'] || mp.game.gameplay.getDistanceBetweenCoords(global.entity.position.x, global.entity.position.y, global.entity.position.z, localplayer.position.x, localplayer.position.y, localplayer.position.z, true) > 6.0)) {
  493.         //global.entity = null;
  494.  
  495.         GetLooking ();
  496.         return;
  497.     }
  498.  
  499.     if (!camera_hand_player_active) return;
  500.     mp.console.logInfo('render: ' +  camera_hand_player_active);
  501.     if (mp.game.invoke('0x8D4D46230B2C353A') == 4 || mp.game.invoke('0x2E397FD2ECD37C87', mp.players.local) == 0) {
  502.         TogglePlayerCameraSide();
  503.         mp.console.logInfo('render if');
  504.         return;
  505.     }
  506.     SetCameraLook();
  507.  
  508.     //
  509.  
  510.     /*
  511.     if (global.circleOpen) {
  512.         global.UpdateCircle (global.entity);
  513.         return;
  514.     }
  515.     */
  516.  
  517.     if (global.entity) {
  518.         const type = global.entity.type;
  519.         const position = global.entity.position;
  520.  
  521.         if (type == "player") {
  522.             if (global.localplayer.isInAnyVehicle(false)) {
  523.                 mp.game.graphics.drawText(global.Keys[global.userBinder[32].keyCode], [position.x, position.y, position.z], {
  524.                     font: 0,
  525.                     color: [255, 255, 255, 185],
  526.                     scale: [0.4, 0.4],
  527.                     outline: true
  528.                 });
  529.             } else {
  530.                 const fractionID = 0;
  531.                 if (--markerRotation < 0) markerRotation = 380;
  532.  
  533.                 markerToPlayer = mp.markers.new(27, new mp.Vector3(position.x, position.y, position.z - 0.975), 1, {
  534.                     'rotation': new mp.Vector3(0, 0, markerRotation),
  535.                     'color': [
  536.                         colorsData[fractionID][0],
  537.                         colorsData[fractionID][1],
  538.                         colorsData[fractionID][2],
  539.                         185
  540.                     ],
  541.                     'visible': true,
  542.                     'dimension': global.localplayer.dimension
  543.                 });
  544.  
  545.                 mp.game.graphics.drawText(global.Keys[global.userBinder[31].keyCode], [position.x, position.y, position.z], {
  546.                     font: 0,
  547.                     color: [255, 255, 255, 185],
  548.                     scale: [0.4, 0.4],
  549.                     outline: true
  550.                 });
  551.             }
  552.         } else if(global.entity.type == "vehicle" && global.entity != localplayer.vehicle) {
  553.             mp.game.graphics.drawText(global.Keys[global.userBinder[31].keyCode], [position.x, position.y, position.z], {
  554.                 font: 0,
  555.                 color: [255, 255, 255, 185],
  556.                 scale: [0.4, 0.4],
  557.                 outline: true
  558.             });
  559.         } else if(global.entity.type == "object") {
  560.             if (global.entity !== focusObject) {
  561.                 global.GetItemData (global.entity);
  562.                 focusObject = global.entity;
  563.             } else {
  564.                 mp.gui.emmit(`window.hudItem.dropFocus ()`);
  565.             }
  566.  
  567.             if (global.entity['dropData'] && (global.entity['dropData'].pId != undefined || global.entity['dropData'].fId != undefined)) {
  568.                 let textKey = global.Keys[global.userBinder[31].keyCode];
  569.  
  570.                 if (global.isAdmin && global.entity['dropData'].pId != undefined) {
  571.                     const player = mp.players.atRemoteId(global.entity['dropData'].pId);
  572.                     if (player) {
  573.                         textKey += `\n(( ${player.name} ))`
  574.                     }
  575.                 }
  576.  
  577.                 mp.game.graphics.drawText(textKey, [position.x, position.y, position.z], {
  578.                     font: 0,
  579.                     color: [255, 255, 255, 185],
  580.                     scale: [0.4, 0.4],
  581.                     outline: true
  582.                 });
  583.             } else {
  584.                 mp.game.graphics.drawText(global.Keys[global.userBinder[32].keyCode], [position.x, position.y, position.z], {
  585.                     font: 0,
  586.                     color: [255, 255, 255, 185],
  587.                     scale: [0.4, 0.4],
  588.                     outline: true
  589.                 });
  590.             }
  591.         }
  592.     }
  593. });
  594.  
  595.  
  596.  
  597. //
  598. /*
  599. gm.interaction = new class {
  600.     constructor() {
  601.         this.interactionDistance = 2.5;
  602.  
  603.         gm.events.add("ready", () => {
  604.             //mp.game.graphics.hasStreamedTextureDictLoaded("commonmenu") || mp.game.graphics.requestStreamedTextureDict("commonmenu", !0);
  605.             this.load();
  606.         });
  607.  
  608.         gm.events.add("render", () => {
  609.             if (global.cameraManager.gameplayCam()) {
  610.                 if (this.entityWorldPosition) {
  611.                     const position = mp.game.graphics.world3dToScreen2d(this.entityWorldPosition);
  612.                     if (position) {
  613.                         const ratio = mp.game.graphics.getScreenAspectRatio(true);
  614.                         mp.game.graphics.drawSprite("commonmenu", "common_medal", position.x, position.y, 0.01, 0.01 * ratio, 0, 256, 256, 256, 128);
  615.                     }
  616.                 } else if (mp.players.local.vehicle && mp.game.controls.isControlJustPressed(0, 86))
  617.                     this.processHornAction();
  618.             }
  619.         });
  620.  
  621.     }
  622.     load() {
  623.         gm.timers.setInterval(() => {
  624.             delete this.entityWorldPosition;
  625.             delete this.entity;
  626.             if (!global.cameraManager.gameplayCam()) return;
  627.             if (!this.isAvailable()) return;
  628.             const e = this.getRaycastData(),
  629.                 r = this.getEntityFromRaycastData(e);
  630.             r && this.isInteractionEntity(r) && this.isEntityInInteractionDistance(r) && ((this.entity = r), this.updateEntityWorldPosition());
  631.         }, 200);
  632.     }
  633.     getRaycastData() {
  634.         const getDirection = gm.player.camera.gameplayCamera.getDirection();
  635.         const getBoneCoords = mp.players.local.vehicle ?
  636.             mp.players.local.getBoneCoords(31086, 0.2, 0, 0) :
  637.             mp.players.local.getBoneCoords(11816, -0.2, 0, 0);
  638.  
  639.         const a = getDirection.multiply(this.interactionDistance).add(getBoneCoords);
  640.         return mp.raycasting.testPointToPoint(getBoneCoords, a, mp.players.local, RAYCASTING_FLAGS.vehicles | RAYCASTING_FLAGS.players);
  641.     }
  642.     getEntityFromRaycastData(e) {
  643.         if (!e) return null;
  644.         let r = null;
  645.         if ("number" == typeof e.entity) {
  646.             const a = gm.player.peds.get({ handle: e.entity });
  647.             a && a.props && a.props.interaction && (r = this.getPedEntity(a.props));
  648.         } else t.y.IS_ENTITY_VISIBLE(e.entity.handle) && (r = e.entity);
  649.         return r;
  650.     }
  651.     isInteractionEntity(e) {
  652.         return ["vehicle", "player", "ped"].includes(e.type);
  653.     }
  654.     updateEntityWorldPosition() {
  655.         const e = new mp.Vector3(0, 0, 1);
  656.         if ("vehicle" === this.entity.type) {
  657.             const r = mp.game.gameplay.getModelDimensions(this.entity.model);
  658.             e.z = r.max.z;
  659.         }
  660.         this.entityWorldPosition = utils.makeVector3(this.entity.position).add(e);
  661.     }
  662.     isAvailable() {
  663.         return (
  664.             !mp.players.local.isFaint &&
  665.             !gm.player.actions.isPlayerInvisible(mp.players.local) &&
  666.             !!gm.player.actions.isVisible(mp.players.local) &&
  667.             !gm.vehicleShove.isShovedInTrunk() &&
  668.             !(!gm.competitions || gm.competitions.isOnCompetition()) &&
  669.             !gm.inventories.isInteractionDisabled()
  670.         );
  671.     }
  672.     isEntityInInteractionDistance(e) {
  673.         const r = 2 * this.interactionDistance,
  674.             a = 3 * this.interactionDistance;
  675.         let t = r;
  676.         if (mp.vehicles.exists(e)) {
  677.             const o = mp.game.gameplay.getModelDimensions(e.model),
  678.                 i = Math.abs(o.min.y) + o.max.y;
  679.             (t = r), i > t && (t = i), t > a && (t = a);
  680.         }
  681.         return utils.isPositionsInRadius(e.position, mp.players.local.position, t);
  682.     }
  683.     processHornAction() {
  684.         gm.player.peds
  685.             .filter((e) => !1 !== gm.player.peds.getProps({ index: e.index }).hornInteraction)
  686.             .some((e) => {
  687.                 const r = gm.player.peds.getProps({ index: e.index });
  688.                 return !!utils.isPositionsInRadius(mp.players.local.position, r.position, r.hornInteraction) && ((this.entity = this.getPedEntity(r)), !0);
  689.             });
  690.     }
  691.     getPedEntity(e) {
  692.         return { ...e, type: "ped", isPed: !0 };
  693.     }
  694. }
  695.  
  696.  
  697.  
  698. */
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement