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('+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_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('+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 = { local state = {
isPlacing = false, 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_clockwise'), Utility.GetCommandKey('+scroll_up')),
string.format(locale('placeable_object.rotate_counter_clockwise'), Utility.GetCommandKey('+scroll_down')), string.format(locale('placeable_object.rotate_counter_clockwise'), Utility.GetCommandKey('+scroll_down')),
string.format(locale('placeable_object.depth_modifier'), Utility.GetCommandKey('+depth_modifier')) string.format(locale('placeable_object.depth_modifier'), Utility.GetCommandKey('+depth_modifier'))
} }
-- Command handlers for key mappings -- Command handlers for key mappings
@@ -134,63 +134,6 @@ local function getMouseWorldPos(depth)
return playerPos + normal * depth return playerPos + normal * depth
end 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() local function checkMaterialAndBoundary()
if not state.currentEntity then return true end if not state.currentEntity then return true end
@@ -260,41 +203,6 @@ local function checkMaterialAndBoundaryDetailed()
return inBounds, inBounds, customCheckPassed return inBounds, inBounds, customCheckPassed
end 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) local function drawBoundaryBox(boundary)
if not boundary then return end if not boundary then return end
@@ -567,7 +475,7 @@ local function placementLoop()
-- if not state.settings.allowVertical or state.snapToGround then -- if not state.settings.allowVertical or state.snapToGround then
-- local groundZ, _z = GetGroundZFor_3dCoord(coords.x, coords.y, coords.z + 50, false) -- local groundZ, _z = GetGroundZFor_3dCoord(coords.x, coords.y, coords.z + 50, false)
-- if groundZ then -- if groundZ then
-- end -- end
-- end -- end
coords = vector3(coords.x, coords.y, coords.z - 0.2) -- Adjust Z to ground level 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 = {} local Grids = {}
Point = {} Point = {}
Point.All = {} Point.All = {}
Point.LastInside = nil
function Grid.Generate() function Grid.Generate()
if Grid.Generated then return end if Grid.Generated then return end
@@ -39,13 +40,21 @@ Points.Started = false
function Point.StartLoop() function Point.StartLoop()
if Points.Started then return end if Points.Started then return end
Points.Started = true Points.Started = true
CreateThread(function() CreateThread(function()
while Points.Started do while Points.Started do
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
if playerPed ~= -1 then if playerPed ~= -1 then
local coords = GetEntityCoords(playerPed) local coords = GetEntityCoords(playerPed)
local cell = Grid.GetCellByCoords(coords) 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 for _, point in pairs(cell or {}) do
local entity = point.target local entity = point.target
local targetCoords = point.isEntity and DoesEntityExist(entity) and GetEntityCoords(entity) or point.coords 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) function Utility.CreateBlip(coords, sprite, color, scale, label, shortRange, displayType)
local blip = AddBlipForCoord(coords.x, coords.y, coords.z) local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
SetBlipSprite(blip, sprite or 8) SetBlipSprite(blip, sprite or 8)
SetBlipColour(blip, color or 3) SetTextFont(0)
SetBlipScale(blip, scale or 0.8)
SetBlipDisplay(blip, displayType or 2) SetBlipDisplay(blip, displayType or 2)
SetBlipScale(blip, scale or 0.8)
SetBlipColour(blip, color or 3)
SetBlipAsShortRange(blip, shortRange) SetBlipAsShortRange(blip, shortRange)
AddTextEntry(label, label) BeginTextCommandSetBlipName("STRING")
BeginTextCommandSetBlipName(label) --AddTextComponentSubstringPlayerName(label) -- switch to this if below line doesnt show da chinese
AddTextComponentString(label)
EndTextCommandSetBlipName(blip) EndTextCommandSetBlipName(blip)
blipIDs[tostring(blip)] = blip blipIDs[tostring(blip)] = blip
return blip return blip
@@ -290,9 +292,9 @@ local doingstuff = false
---@param text string The text to show ---@param text string The text to show
---@param coords table The coords to show the message at ---@param coords table The coords to show the message at
---@return nil ---@return nil
function Utility.FloatingHelpText(text, coords) function Utility.FloatingHelpText(text, coords)
AddTextEntry("community_bridge_"..text, text) 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) SetFloatingHelpTextStyle(1, 1, 2, -1, 3, 0)
BeginTextCommandDisplayHelp("community_bridge_"..text) BeginTextCommandDisplayHelp("community_bridge_"..text)
EndTextCommandDisplayHelp(2, false, false, 100) EndTextCommandDisplayHelp(2, false, false, 100)
@@ -313,7 +315,7 @@ function Utility.Draw3DHelpText(coords, text, scale)
end end
local widthFactor = maxLineLen * 0.012 * scale local widthFactor = maxLineLen * 0.012 * scale
local height = 0.06 * scale * lineCount local height = 0.06 * scale * lineCount
-- Set text properties -- Set text properties
SetTextScale(scale or 0.35, scale or 0.35) SetTextScale(scale or 0.35, scale or 0.35)
SetTextFont(4) SetTextFont(4)
@@ -323,7 +325,7 @@ function Utility.Draw3DHelpText(coords, text, scale)
SetTextCentre(true) SetTextCentre(true)
AddTextComponentString(text) AddTextComponentString(text)
DrawText(x, y) DrawText(x, y)
-- Draw background rectangle -- 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 + 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) 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 -- Wait brief moment to see if new dialogue opens
CreateThread(function() 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 if pendingCameraDestroy and not activeDialogue then
-- No new dialogue opened, safe to destroy camera -- No new dialogue opened, safe to destroy camera
RenderScriptCams(false, 1, 1000, 1, 0) RenderScriptCams(false, 1, 1000, 1, 0)
@@ -56,7 +56,7 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel
-- camera magic! -- camera magic!
if entity then if entity then
Wait(500) 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) local pedHeading = GetEntityHeading(entity)
-- Get position in front of ped based on their heading -- Get position in front of ped based on their heading