Bux fixes and cleanup

placeable_objects cleaned up white space and removed commented out code

points: issue with teleporting outside of a cell. Does not fire onremove event functions. Fixed

utility: Implemented fix for special characters for blips.

dialogue: upped wait time on close. This allows use to reopen the menu right away without firing the animation to close
This commit is contained in:
Mr.Crowley committed 2025-11-14 18:36:35 -06:00
1 parent 5791f89598
commit a1901fc400
4 files changed
+25 -106

No files matched your search

+3 -95
View File
@@ -12,7 +12,7 @@ RegisterKeyMapping('+rotate_left', locale('placeable_object.rotate_left'), 'keyb
RegisterKeyMapping('+rotate_right', locale('placeable_object.rotate_right'), 'keyboard', 'RIGHT')
RegisterKeyMapping('+scroll_up', locale('placeable_object.object_scroll_up'), 'mouse_wheel', 'IOM_WHEEL_UP')
RegisterKeyMapping('+scroll_down', locale('placeable_object.object_scroll_down'), 'mouse_wheel', 'IOM_WHEEL_DOWN')
RegisterKeyMapping('+depth_modifier', locale('placeable_object.depth_modifier'), 'keyboard', 'LCONTROL')
RegisterKeyMapping('+depth_modifier', locale('placeable_object.depth_modifier'), 'keyboard', 'LCONTROL')
local state = {
isPlacing = false,
@@ -50,7 +50,7 @@ local placementText = {
string.format(locale('placeable_object.rotate_clockwise'), Utility.GetCommandKey('+scroll_up')),
string.format(locale('placeable_object.rotate_counter_clockwise'), Utility.GetCommandKey('+scroll_down')),
string.format(locale('placeable_object.depth_modifier'), Utility.GetCommandKey('+depth_modifier'))
}
-- Command handlers for key mappings
@@ -134,63 +134,6 @@ local function getMouseWorldPos(depth)
return playerPos + normal * depth
end
-- local function isInBoundary(pos, boundary)
-- if not boundary then return true end
-- local x, y, z = table.unpack(pos)
-- -- Handle legacy min/max boundary format for backwards compatibility
-- if boundary.min and boundary.max then
-- local minX, minY, minZ = table.unpack(boundary.min)
-- local maxX, maxY, maxZ = table.unpack(boundary.max)
-- return x >= minX and x <= maxX and y >= minY and y <= maxY and z >= minZ and z <= maxZ
-- end
-- -- Handle list of points (polygon boundary)
-- if boundary.points and #boundary.points > 0 then
-- local points = boundary.points
-- local minZ = boundary.minZ or -math.huge
-- local maxZ = boundary.maxZ or math.huge
-- -- Check Z bounds first
-- if z < minZ or z > maxZ then
-- return false
-- end
-- -- Point-in-polygon test using ray casting algorithm (improved version)
-- local inside = false
-- local n = #points
-- for i = 1, n do
-- local j = i == n and 1 or i + 1 -- Next point (wrap around)
-- local xi, yi = points[i].x or points[i][1], points[i].y or points[i][2]
-- local xj, yj = points[j].x or points[j][1], points[j].y or points[j][2]
-- -- Ensure xi, yi, xj, yj are numbers
-- if not (xi and yi and xj and yj) then
-- goto continue
-- end
-- -- Ray casting test
-- if ((yi > y) ~= (yj > y)) then
-- -- Calculate intersection point
-- local intersect = (xj - xi) * (y - yi) / (yj - yi) + xi
-- if x < intersect then
-- inside = not inside
-- end
-- end
-- ::continue::
-- end
-- return inside
-- end
-- -- Fallback to true if boundary format is not recognized
-- return true
-- end
local function checkMaterialAndBoundary()
if not state.currentEntity then return true end
@@ -260,41 +203,6 @@ local function checkMaterialAndBoundaryDetailed()
return inBounds, inBounds, customCheckPassed
end
-- local function setupInstructionalButtons()
-- local buttons = {}
-- -- Common buttons
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = state.settings.config?.place_object?.name or 'Place Object:', keyIndex = state.settings.config?.place_object?.key or {223}, int = 5})
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = state.settings.config?.cancel_placement?.name or 'Cancel:', keyIndex = state.settings.config?.cancel_placement?.key or {25}, int = 4})
-- if state.mode == 'normal' then
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Rotate:', keyIndex = {241, 242}, int = 3})
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Depth:', keyIndex = {224}, int = 2})
-- if state.settings.allowVertical then
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Height:', keyIndex = {16, 17}, int = 1})
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Toggle Ground Snap:', keyIndex = {19}, int = 0})
-- end
-- if state.settings.allowMovement then
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Movement Mode:', keyIndex = {38}, int = 6})
-- end
-- elseif state.mode == 'movement' then
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Move:', keyIndex = {32, 33, 34, 35}, int = 3})
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Rotate:', keyIndex = {174, 175}, int = 2})
-- if state.settings.allowVertical then
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Up/Down:', keyIndex = {85, 48}, int = 1})
-- end
-- if state.settings.allowNormal then
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Normal Mode:', keyIndex = {38}, int = 0})
-- end
-- end
-- table.insert(buttons, {type = "DRAW_INSTRUCTIONAL_BUTTONS"})
-- table.insert(buttons, {type = "SET_BACKGROUND_COLOUR"})
-- -- return Scaleform.SetupInstructionalButtons(buttons)
-- return nil -- Scaleform disabled for now
-- end
local function drawBoundaryBox(boundary)
if not boundary then return end
@@ -567,7 +475,7 @@ local function placementLoop()
-- if not state.settings.allowVertical or state.snapToGround then
-- local groundZ, _z = GetGroundZFor_3dCoord(coords.x, coords.y, coords.z + 50, false)
-- if groundZ then
-- end
-- end
coords = vector3(coords.x, coords.y, coords.z - 0.2) -- Adjust Z to ground level
+10 -1
View File
@@ -7,6 +7,7 @@ Grid.Generated = false
local Grids = {}
Point = {}
Point.All = {}
Point.LastInside = nil
function Grid.Generate()
if Grid.Generated then return end
@@ -39,13 +40,21 @@ Points.Started = false
function Point.StartLoop()
if Points.Started then return end
Points.Started = true
CreateThread(function()
while Points.Started do
local playerPed = PlayerPedId()
if playerPed ~= -1 then
local coords = GetEntityCoords(playerPed)
local cell = Grid.GetCellByCoords(coords)
if Point.LastInside ~= cell then
for _, point in pairs(Point.LastInside or {}) do
if point.inside then
point.inside = false
point.args = point?.onExit(point, point.args) or point.args
end
end
Point.LastInside = cell
end
for _, point in pairs(cell or {}) do
local entity = point.target
local targetCoords = point.isEntity and DoesEntityExist(entity) and GetEntityCoords(entity) or point.coords
+10 -8
View File
@@ -120,12 +120,14 @@ end
function Utility.CreateBlip(coords, sprite, color, scale, label, shortRange, displayType)
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
SetBlipSprite(blip, sprite or 8)
SetBlipColour(blip, color or 3)
SetBlipScale(blip, scale or 0.8)
SetTextFont(0)
SetBlipDisplay(blip, displayType or 2)
SetBlipScale(blip, scale or 0.8)
SetBlipColour(blip, color or 3)
SetBlipAsShortRange(blip, shortRange)
AddTextEntry(label, label)
BeginTextCommandSetBlipName(label)
BeginTextCommandSetBlipName("STRING")
--AddTextComponentSubstringPlayerName(label) -- switch to this if below line doesnt show da chinese
AddTextComponentString(label)
EndTextCommandSetBlipName(blip)
blipIDs[tostring(blip)] = blip
return blip
@@ -290,9 +292,9 @@ local doingstuff = false
---@param text string The text to show
---@param coords table The coords to show the message at
---@return nil
function Utility.FloatingHelpText(text, coords)
function Utility.FloatingHelpText(text, coords)
AddTextEntry("community_bridge_"..text, text)
SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z)
SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z)
SetFloatingHelpTextStyle(1, 1, 2, -1, 3, 0)
BeginTextCommandDisplayHelp("community_bridge_"..text)
EndTextCommandDisplayHelp(2, false, false, 100)
@@ -313,7 +315,7 @@ function Utility.Draw3DHelpText(coords, text, scale)
end
local widthFactor = maxLineLen * 0.012 * scale
local height = 0.06 * scale * lineCount
-- Set text properties
SetTextScale(scale or 0.35, scale or 0.35)
SetTextFont(4)
@@ -323,7 +325,7 @@ function Utility.Draw3DHelpText(coords, text, scale)
SetTextCentre(true)
AddTextComponentString(text)
DrawText(x, y)
-- Draw background rectangle
DrawRect(x, y + height / 2, widthFactor + 0.015 + 0.006, height + 0.015 + 0.006, 10, 25, 47, 200)
DrawRect(x, y + height / 2, widthFactor + 0.015, height + 0.015, 17, 45, 78, 50)
+2 -2
View File
@@ -22,7 +22,7 @@ function Dialogue.Close(name)
-- Wait brief moment to see if new dialogue opens
CreateThread(function()
Wait(50) -- Small delay to allow new dialogue to open
Wait(200) -- Small delay to allow new dialogue to open
if pendingCameraDestroy and not activeDialogue then
-- No new dialogue opened, safe to destroy camera
RenderScriptCams(false, 1, 1000, 1, 0)
@@ -56,7 +56,7 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel
-- camera magic!
if entity then
Wait(500)
local endLocation = GetOffsetFromEntityInWorldCoords(entity, offset.x, offset.y + 2.0, offset.z + 0.5)
local endLocation = GetOffsetFr omEntityInWorldCoords(entity, offset.x, offset.y + 2.0, offset.z)
local pedHeading = GetEntityHeading(entity)
-- Get position in front of ped based on their heading