forked from ZAUB1/Car_Doors
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathc.js
71 lines (58 loc) · 1.98 KB
/
c.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const names = [
"front right",
"rear left",
"rear right",
];
const names2 = [
"front right",
"rear left",
"rear right",
];
HelpText = function(msg)
{
if (!IsHelpMessageOnScreen())
{
SetTextComponentFormat('STRING')
AddTextComponentString(msg)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
}
}
MyClosestVehicle = function(x, y, z, radius)
{
for (let i = 1; i < 72; i++)
{
const angle = (i * 5) * Math.PI / 180;
const sx = (50.0 * Math.cos(angle)) + x;
const sy = (50.0 * Math.sin(angle)) + y;
const ex = x - (sx - x);
const ey = y - (sy - y);
const rayHandle = StartShapeTestCapsule(sx, sy, z, ex, ey, z, radius, 10, PlayerPedId(), 1000);
const ent = GetShapeTestResult(rayHandle, false)[4];
return ent;
}
}
setTick(() => {
let ped = PlayerPedId();
let pco = GetEntityCoords(ped);
let veh = MyClosestVehicle(pco[0], pco[1], pco[2], 5.0);
if (DoesEntityExist(veh))
{
for (let i = 1; i < GetNumberOfVehicleDoors(veh); i++)
{
let coord = GetEntryPositionOfDoor(veh, i);
if (Vdist2(pco[0], pco[1], pco[2], coord[0], coord[1], coord[2]) < 0.75 && !DoesEntityExist(GetPedInVehicleSeat(veh, i - 1)) && GetVehicleDoorLockStatus(veh) !== 2)
{
if (names[i - 1] && !IsThisModelABike(GetEntityModel(veh)) && !IsThisModelABoat(GetEntityModel(veh)))
HelpText("Press H to enter through the" + names[i - 1]);
else if (names2[i - 1] && IsThisModelABike(GetEntityModel(veh)) && IsThisModelABoat(GetEntityModel(veh)))
HelpText("Press H to return to your seat" + names2[i - 1]);
else
HelpText("Press H to enter through this door");
if (IsControlJustPressed(1, 74))
{
TaskEnterVehicle(ped, veh, 10000, i - 1, 1.0, 1, 0);
}
}
}
}
});