adding new script
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
--[[
|
||||
Scripted By: Xander1998 (X. Cross)
|
||||
--]]
|
||||
|
||||
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
|
||||
|
||||
ui_page "nui/index.html"
|
||||
files {
|
||||
"nui/index.html",
|
||||
"nui/vue.min.js",
|
||||
"nui/script.js",
|
||||
"nui/style.css",
|
||||
"nui/images/seal.png"
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
"config.lua",
|
||||
"client.lua"
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
local dashcamActive = false
|
||||
local attachedVehicle = nil
|
||||
local cameraHandle = nil
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
if dashcamActive then
|
||||
|
||||
if dashcamActive and not IsPedInAnyVehicle(GetPlayerPed(PlayerId()), false) then
|
||||
DisableDash()
|
||||
dashcamActive = false
|
||||
end
|
||||
|
||||
if IsPedInAnyVehicle(GetPlayerPed(PlayerId()), false) and dashcamActive then
|
||||
UpdateDashcam()
|
||||
end
|
||||
|
||||
end
|
||||
Citizen.Wait(1000)
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
if IsControlJustPressed(1, 81) and IsPedInAnyVehicle(GetPlayerPed(PlayerId()), false) then
|
||||
if dashcamActive then
|
||||
DisableDash()
|
||||
else
|
||||
EnableDash()
|
||||
end
|
||||
end
|
||||
|
||||
if dashcamActive then
|
||||
local bonPos = GetWorldPositionOfEntityBone(attachedVehicle, GetEntityBoneIndexByName(attachedVehicle, "windscreen"))
|
||||
local vehRot = GetEntityRotation(attachedVehicle, 0)
|
||||
SetCamCoord(cameraHandle, bonPos.x, bonPos.y, bonPos.z)
|
||||
SetCamRot(cameraHandle, vehRot.x, vehRot.y, vehRot.z, 0)
|
||||
end
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end)
|
||||
|
||||
function EnableDash()
|
||||
attachedVehicle = GetVehiclePedIsIn(GetPlayerPed(PlayerId()), false)
|
||||
if DashcamConfig.RestrictVehicles then
|
||||
if CheckVehicleRestriction() then
|
||||
SetTimecycleModifier("scanline_cam_cheap")
|
||||
SetTimecycleModifierStrength(2.2)
|
||||
local cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1)
|
||||
RenderScriptCams(1, 0, 0, 1, 1)
|
||||
SetFocusEntity(attachedVehicle)
|
||||
cameraHandle = cam
|
||||
SendNUIMessage({
|
||||
type = "enabledash"
|
||||
})
|
||||
dashcamActive = true
|
||||
end
|
||||
else
|
||||
SetTimecycleModifier("scanline_cam_cheap")
|
||||
SetTimecycleModifierStrength(2.2)
|
||||
local cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1)
|
||||
RenderScriptCams(1, 0, 0, 1, 1)
|
||||
SetFocusEntity(attachedVehicle)
|
||||
cameraHandle = cam
|
||||
SendNUIMessage({
|
||||
type = "enabledash"
|
||||
})
|
||||
dashcamActive = true
|
||||
end
|
||||
end
|
||||
|
||||
function DisableDash()
|
||||
ClearTimecycleModifier("scanline_cam_cheap")
|
||||
RenderScriptCams(0, 0, 1, 1, 1)
|
||||
DestroyCam(cameraHandle, false)
|
||||
SetFocusEntity(GetPlayerPed(PlayerId()))
|
||||
SendNUIMessage({
|
||||
type = "disabledash"
|
||||
})
|
||||
dashcamActive = false
|
||||
end
|
||||
|
||||
function UpdateDashcam()
|
||||
local gameTime = GetGameTimer()
|
||||
local year, month, day, hour, minute, second = GetLocalTime()
|
||||
local unitNumber = GetPlayerServerId(PlayerId())
|
||||
local unitName = GetPlayerName(PlayerId())
|
||||
local unitSpeed = nil
|
||||
|
||||
if DashcamConfig.useMPH then
|
||||
unitSpeed = GetEntitySpeed(attachedVehicle) * 2.23694
|
||||
else
|
||||
unitSpeed = GetEntitySpeed(attachedVehicle) * 3.6
|
||||
end
|
||||
|
||||
SendNUIMessage({
|
||||
type = "updatedash",
|
||||
info = {
|
||||
gameTime = gameTime,
|
||||
clockTime = {year = year, month = month, day = day, hour = hour, minute = minute, second = second},
|
||||
unitNumber = unitNumber,
|
||||
unitName = unitName,
|
||||
unitSpeed = unitSpeed,
|
||||
useMPH = DashcamConfig.useMPH
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
function CheckVehicleRestriction()
|
||||
if DashcamConfig.RestrictionType == "custom" then
|
||||
for a = 1, #DashcamConfig.AllowedVehicles do
|
||||
print(GetHashKey(DashcamConfig.AllowedVehicles[a]))
|
||||
print(GetEntityModel(attachedVehicle))
|
||||
if GetHashKey(DashcamConfig.AllowedVehicles[a]) == GetEntityModel(attachedVehicle) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
elseif DashcamConfig.RestrictionType == "class" then
|
||||
if GetVehicleClass(attachedVehicle) == 18 then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,40 @@
|
||||
DashcamConfig = {}
|
||||
|
||||
DashcamConfig.useMPH = true -- False will turn it to KMH
|
||||
|
||||
DashcamConfig.RestrictVehicles = true
|
||||
DashcamConfig.RestrictionType = "class" -- custom / class
|
||||
|
||||
DashcamConfig.AllowedVehicles = {
|
||||
"dps8",
|
||||
"lib111vic",
|
||||
"lib116explorer",
|
||||
"lib118taurus",
|
||||
"lib119tahoe",
|
||||
"fhp_tahoe2",
|
||||
"legacycharger",
|
||||
"21slickppv1",
|
||||
"20expk9bb",
|
||||
"353",
|
||||
"722",
|
||||
"645",
|
||||
"569",
|
||||
"505",
|
||||
"272",
|
||||
"797",
|
||||
"881",
|
||||
"919",
|
||||
"988",
|
||||
"7777",
|
||||
"7789",
|
||||
"87",
|
||||
"724",
|
||||
"544",
|
||||
"404",
|
||||
"382",
|
||||
"gt24non",
|
||||
"191",
|
||||
"181",
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 296 B |
@@ -0,0 +1,28 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Xander1998's Dashcam</title>
|
||||
<link rel="stylesheet" href="./style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="Dashcam_Body" v-show="showDash">
|
||||
<div id="Dashcam_Data">
|
||||
<div id="Dashcam_Gametime">Video: {{ gameTime }}</div>
|
||||
<div id="Dashcam_DateTime">Date: {{ clockTime.month }} / {{clockTime.day}} / {{clockTime.year}}</div>
|
||||
<div id="Dashcam_ClockTime">Time: {{clockTime.hour}} : {{clockTime.minute}} : {{clockTime.second}}</div>
|
||||
<div id="Dashcam_Unitnumber">Unit: {{ unitNumber }}</div>
|
||||
<div id="Dashcam_Unitname">Unit Name: {{ unitName }}</div>
|
||||
<div id="Dashcam_Unitspeed">Unit Speed: {{ unitSpeed }} {{ unitSpeedType }}</div>
|
||||
<div>
|
||||
<img id="Dashcam_Image" src="./images/seal.png">
|
||||
<div id="Dashcam_Info">
|
||||
<div>{{ dashMessageOne }}</div>
|
||||
<div style="color: rgb(25, 167, 255); font-size: 25px; font-weight: bold; -webkit-text-stroke-width: 1px; -webkit-text-stroke-color: black;">{{ dashLabel }}</div>
|
||||
<div>{{ dashMessageTwo }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="./vue.min.js"></script>
|
||||
<script src="./script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,65 @@
|
||||
const Dashcam = new Vue({
|
||||
el: "#Dashcam_Body",
|
||||
|
||||
data: {
|
||||
showDash: false,
|
||||
|
||||
gameTime: 0,
|
||||
clockTime: {},
|
||||
unitNumber: 0,
|
||||
unitName: "",
|
||||
unitSpeed: 0,
|
||||
unitSpeedType: "MPH",
|
||||
|
||||
dashMessageOne: "This vehicle is licensed to the",
|
||||
dashLabel: "State of Georgia",
|
||||
dashMessageTwo: "Any unauthorized use is subject to criminal charges."
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
EnableDashcam() {
|
||||
this.showDash = true;
|
||||
},
|
||||
|
||||
DisableDashcam() {
|
||||
this.showDash = false;
|
||||
},
|
||||
|
||||
UpdateDashcam(data) {
|
||||
this.gameTime = data.gameTime;
|
||||
this.clockTime = data.clockTime;
|
||||
this.unitNumber = data.unitNumber;
|
||||
this.unitName = data.unitName;
|
||||
this.unitSpeed = Math.round(data.unitSpeed);
|
||||
|
||||
if (data.useMPH) {
|
||||
this.unitSpeedType = "MPH";
|
||||
} else {
|
||||
this.unitSpeedType = "KMH";
|
||||
};
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
document.onreadystatechange = () => {
|
||||
if (document.readyState === "complete") {
|
||||
window.addEventListener('message', function(event) {
|
||||
if (event.data.type == "enabledash") {
|
||||
|
||||
Dashcam.EnableDashcam();
|
||||
|
||||
} else if (event.data.type == "disabledash") {
|
||||
|
||||
Dashcam.DisableDashcam();
|
||||
|
||||
} else if (event.data.type == "updatedash") {
|
||||
|
||||
Dashcam.UpdateDashcam(event.data.info);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
#Dashcam_Body {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
#Dashcam_Gametime {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 310px;
|
||||
color: white;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#Dashcam_Clocktime {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 360px;
|
||||
color: white;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#Dashcam_DateTime {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 410px;
|
||||
color: white;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#Dashcam_Unitnumber {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 30px;
|
||||
color: white;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#Dashcam_Unitname {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 80px;
|
||||
color: white;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#Dashcam_Unitspeed {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 130px;
|
||||
color: white;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#Dashcam_Image {
|
||||
position: absolute;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
left: 50%;
|
||||
top: calc(100% - 250px);
|
||||
transform: translateX(-50%);
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
#Dashcam_Info {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: calc(100% - 180px);
|
||||
transform: translateX(-50%);
|
||||
text-align: center;
|
||||
color: white;
|
||||
font-size: 15px;
|
||||
}
|
||||
Vendored
+6
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user