first commit

This commit is contained in:
2026-03-29 21:41:17 +03:00
commit f1a0200a88
32514 changed files with 2129132 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
Config = Config or {}
Config.ConfigFormatEnabled = false
-- Default Format
-- Name: TestBox | 2022-04-13T22:46:17Z
-- BoxZone:Create(vector3(-344.16, -103.25, 39.02), 1, 1, {
-- name = "TestBox",
-- heading = 0,
-- --debugPoly = true
-- })
-- Name: TestCircle | 2022-04-13T22:46:39Z
-- CircleZone:Create(vector3(-344.16, -103.25, 39.02), 1.0, {
-- name = "TestCircle",
-- useZ = false,
-- --debugPoly = true
-- })
-- Name: TestPoly | 2022-04-13T22:46:55Z
-- PolyZone:Create({
-- vector2(-344.15713500977, -103.24993896484),
-- vector2(-343.69491577148, -100.99839019775),
-- vector2(-345.53350830078, -102.00588226318)
-- }, {
-- name = "TestPoly",
-- minZ = 39.015644073486,
-- maxZ = 39.015865325928
-- })
-- Config Format
-- Name: TestBox | 2022-04-13T22:34:48Z
-- coords = vector3(-342.92, -102.09, 39.02),
-- length = 1,
-- width = 1,
-- name = "TestBox",
-- heading = 0,
-- debugPoly = true
-- Name: TestCircle | 2022-04-13T22:35:09Z
-- coords = vector3(-342.92, -102.09, 39.02),
-- radius = 1.0,
-- name = "TestCircle",
-- useZ = false,
-- debugPoly = true
-- Name: TestPoly | 2022-04-13T22:35:43Z
-- points = {
-- vector2(-342.91537475586, -102.09281158447),
-- vector2(-344.09732055664, -104.0821762085),
-- vector2(-342.01580810547, -105.60903167725)
-- },
-- name = "TestPoly",
-- minZ = 39.015701293945,
-- maxZ = 39.015705108643,
-- debugPoly = true

View File

@@ -0,0 +1,109 @@
RegisterNetEvent("polyzone:printPoly")
AddEventHandler("polyzone:printPoly", function(zone)
local created_zones = LoadResourceFile(GetCurrentResourceName(), "polyzone_created_zones.txt") or ""
local output = created_zones .. parsePoly(zone)
SaveResourceFile(GetCurrentResourceName(), "polyzone_created_zones.txt", output, -1)
end)
RegisterNetEvent("polyzone:printCircle")
AddEventHandler("polyzone:printCircle", function(zone)
local created_zones = LoadResourceFile(GetCurrentResourceName(), "polyzone_created_zones.txt") or ""
local output = created_zones .. parseCircle(zone)
SaveResourceFile(GetCurrentResourceName(), "polyzone_created_zones.txt", output, -1)
end)
RegisterNetEvent("polyzone:printBox")
AddEventHandler("polyzone:printBox", function(zone)
local created_zones = LoadResourceFile(GetCurrentResourceName(), "polyzone_created_zones.txt") or ""
local output = created_zones .. parseBox(zone)
SaveResourceFile(GetCurrentResourceName(), "polyzone_created_zones.txt", output, -1)
end)
function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function printoutHeader(name)
return "-- Name: " .. name .. " | " .. os.date("!%Y-%m-%dT%H:%M:%SZ\n")
end
function parsePoly(zone)
if Config.ConfigFormatEnabled then
local printout = printoutHeader(zone.name)
printout = printout .. "points = {\n"
for i = 1, #zone.points do
if i ~= #zone.points then
printout = printout .. " vector2(" .. tostring(zone.points[i].x) .. ", " .. tostring(zone.points[i].y) .."),\n"
else
printout = printout .. " vector2(" .. tostring(zone.points[i].x) .. ", " .. tostring(zone.points[i].y) ..")\n"
end
end
printout = printout .. "},\nname = \"" .. zone.name .. "\",\n--minZ = " .. zone.minZ .. ",\n--maxZ = " .. zone.maxZ .. ",\n--debugPoly = true\n\n"
return printout
else
local printout = printoutHeader(zone.name)
printout = printout .. "PolyZone:Create({\n"
for i = 1, #zone.points do
if i ~= #zone.points then
printout = printout .. " vector2(" .. tostring(zone.points[i].x) .. ", " .. tostring(zone.points[i].y) .."),\n"
else
printout = printout .. " vector2(" .. tostring(zone.points[i].x) .. ", " .. tostring(zone.points[i].y) ..")\n"
end
end
printout = printout .. "}, {\n name = \"" .. zone.name .. "\",\n --minZ = " .. zone.minZ .. ",\n --maxZ = " .. zone.maxZ .. "\n})\n\n"
return printout
end
end
function parseCircle(zone)
if Config.ConfigFormatEnabled then
local printout = printoutHeader(zone.name)
printout = printout .. "coords = "
printout = printout .. "vector3(" .. tostring(round(zone.center.x, 2)) .. ", " .. tostring(round(zone.center.y, 2)) .. ", " .. tostring(round(zone.center.z, 2)) .."),\n"
printout = printout .. "radius = " .. tostring(zone.radius) .. ",\n"
printout = printout .. "name = \"" .. zone.name .. "\",\nuseZ = " .. tostring(zone.useZ) .. ",\n--debugPoly = true\n\n"
return printout
else
local printout = printoutHeader(zone.name)
printout = printout .. "CircleZone:Create("
printout = printout .. "vector3(" .. tostring(round(zone.center.x, 2)) .. ", " .. tostring(round(zone.center.y, 2)) .. ", " .. tostring(round(zone.center.z, 2)) .."), "
printout = printout .. tostring(zone.radius) .. ", "
printout = printout .. "{\n name = \"" .. zone.name .. "\",\n useZ = " .. tostring(zone.useZ) .. ",\n --debugPoly = true\n})\n\n"
return printout
end
end
function parseBox(zone)
if Config.ConfigFormatEnabled then
local printout = printoutHeader(zone.name)
printout = printout .. "coords = "
printout = printout .. "vector3(" .. tostring(round(zone.center.x, 2)) .. ", " .. tostring(round(zone.center.y, 2)) .. ", " .. tostring(round(zone.center.z, 2)) .."),\n"
printout = printout .. "length = " .. tostring(zone.length) .. ",\n"
printout = printout .. "width = " .. tostring(zone.width) .. ",\n"
printout = printout .. "name = \"" .. zone.name .. "\",\nheading = " .. zone.heading .. ",\n--debugPoly = true"
if zone.minZ then
printout = printout .. ",\nminZ = " .. tostring(round(zone.minZ, 2))
end
if zone.maxZ then
printout = printout .. ",\nmaxZ = " .. tostring(round(zone.maxZ, 2))
end
printout = printout .. "\n\n"
return printout
else
local printout = printoutHeader(zone.name)
printout = printout .. "BoxZone:Create("
printout = printout .. "vector3(" .. tostring(round(zone.center.x, 2)) .. ", " .. tostring(round(zone.center.y, 2)) .. ", " .. tostring(round(zone.center.z, 2)) .."), "
printout = printout .. tostring(zone.length) .. ", "
printout = printout .. tostring(zone.width) .. ", "
printout = printout .. "{\n name = \"" .. zone.name .. "\",\n heading = " .. zone.heading .. ",\n --debugPoly = true"
if zone.minZ then
printout = printout .. ",\n minZ = " .. tostring(round(zone.minZ, 2))
end
if zone.maxZ then
printout = printout .. ",\n maxZ = " .. tostring(round(zone.maxZ, 2))
end
printout = printout .. "\n})\n\n"
return printout
end
end