Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing file and folder fix #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create BoxZone.lua
Added missing file
  • Loading branch information
Infernalz92 authored Sep 30, 2023
commit 16ad5a6bb90fd618d76b292347631d6c4492b781
106 changes: 106 additions & 0 deletions creation/client/BoxZone.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
local function handleInput(useZ, heading, length, width, center)
if not useZ then
local scaleDelta, headingDelta = 0.2, 5
if IsDisabledControlPressed(2, Keys["CTRL"]) then -- ctrl held down
scaleDelta, headingDelta = 0.05, 1
end

if IsDisabledControlJustReleased(2, Keys["MWDOWN"]) then
if IsDisabledControlPressed(2, Keys["LALT"]) then -- alt held down
return heading, length, math.max(0.0, width - scaleDelta), center
end
if IsDisabledControlPressed(2, Keys["SHIFT"]) then -- shift held down
return heading, math.max(0.0, length - scaleDelta), width, center
end
return (heading - headingDelta) % 360, length, width, center
end

if IsDisabledControlJustReleased(2, Keys["MWUP"]) then
if IsDisabledControlPressed(2, Keys["LALT"]) then -- alt held down
return heading, length, math.max(0.0, width + scaleDelta), center
end
if IsDisabledControlPressed(2, Keys["SHIFT"]) then -- shift held down
return heading, math.max(0.0, length + scaleDelta), width, center
end
return (heading + headingDelta) % 360, length, width, center
end
end

local rot = GetGameplayCamRot(2)
center = handleArrowInput(center, rot.z)

return heading, length, width, center
end

function handleZ(minZ, maxZ)
local delta = 0.2
if IsDisabledControlPressed(2, Keys["CTRL"]) then -- ctrl held down
delta = 0.05
end

if IsDisabledControlJustReleased(2, Keys["MWDOWN"]) then
if IsDisabledControlPressed(2, Keys["LALT"]) then -- alt held down
return minZ - delta, maxZ
end
if IsDisabledControlPressed(2, Keys["SHIFT"]) then -- shift held down
return minZ, maxZ - delta
end
return minZ - delta, maxZ - delta
end

if IsDisabledControlJustReleased(2, Keys["MWUP"]) then
if IsDisabledControlPressed(2, Keys["LALT"]) then -- alt held down
return minZ + delta, maxZ
end
if IsDisabledControlPressed(2, Keys["SHIFT"]) then -- shift held down
return minZ, maxZ + delta
end
return minZ + delta, maxZ + delta
end
return minZ, maxZ
end

function boxStart(name, heading, length, width, minHeight, maxHeight)
local center = GetEntityCoords(PlayerPedId())
createdZone = BoxZone:Create(center, length, width, {name = tostring(name)})
local useZ, minZ, maxZ = false, center.z - 1.0, center.z + 3.0
if minHeight then
minZ = center.z - minHeight
createdZone.minZ = minZ
end
if maxHeight then
maxZ = center.z + maxHeight
createdZone.maxZ = maxZ
end
Citizen.CreateThread(function()
LocalPlayer.state:set("PolyZoneCreation", true, true)
while createdZone do
DisableControls()
if IsControlJustPressed(2, Keys["Z"]) then -- Z pressed
useZ = not useZ
if useZ then
createdZone.debugColors.walls = {255, 0, 0}
else
createdZone.debugColors.walls = {0, 255, 0}
end
end
heading, length, width, center = handleInput(useZ, heading, length, width, center)
if useZ then
minZ, maxZ = handleZ(minZ, maxZ)
createdZone.minZ = minZ
createdZone.maxZ = maxZ
end
createdZone:setLength(length)
createdZone:setWidth(width)
createdZone:setHeading(heading)
createdZone:setCenter(center)
Wait(0)
end
LocalPlayer.state:set("PolyZoneCreation", false, true)
end)
end

function boxFinish()
TriggerServerEvent("polyzone:printBox",
{name=createdZone.name, center=createdZone.center, length=createdZone.length, width=createdZone.width, heading=createdZone.offsetRot, minZ=createdZone.minZ, maxZ=createdZone.maxZ})
end