made woopsie to entities

This commit is contained in:
Mr.Crowley committed 2025-08-05 20:57:26 -05:00
1 parent d0f9fb7ca3
commit 140bad5b34
6 files changed
+126 -45

No files matched your search

+13 -6
View File
@@ -45,19 +45,26 @@ local function SpawnEntity(entityData)
end end
end end
local function RemoveEntity(entityData, skip) local function RemoveEntity(entityData)
print(string.format("[ClientEntity] Removing entity %s", entityData.id))
entityData = entityData and entityData.args or entityData entityData = entityData and entityData.args or entityData
if not entityData then return end if not entityData then return end
ClientEntityActions.StopAction(entityData.id) -- ClientEntityActions.StopAction(entityData.id)
print(string.format("[ClientEntity] Stopping actions for entity %s", entityData.id, entityData.OnRemove))
for k, v in pairs(entityData) do
print(string.format("RemoveEntity %s", k))
end
print(json.encode(skip))
if entityData.OnRemove then
print(string.format("[ClientEntity] Calling OnRemove for entity %s", entityData.id))
entityData.OnRemove(entityData)
end
if entityData.spawned and DoesEntityExist(entityData.spawned) then if entityData.spawned and DoesEntityExist(entityData.spawned) then
local entityHandle = entityData.spawned local entityHandle = entityData.spawned
entityData.spawned = nil entityData.spawned = nil
SetEntityAsMissionEntity(entityHandle, false, false) SetEntityAsMissionEntity(entityHandle, false, false)
DeleteEntity(entityHandle) DeleteEntity(entityHandle)
end end
if not skip and entityData.OnRemove then
entityData.OnRemove(entityData)
end
end end
--- Registers an entity received from the server and sets up proximity spawning. --- Registers an entity received from the server and sets up proximity spawning.
@@ -239,7 +246,7 @@ AddEventHandler('onResourceStop', function(resourceName)
if resourceName == GetCurrentResourceName() then if resourceName == GetCurrentResourceName() then
for id, entityData in pairs(Entities) do for id, entityData in pairs(Entities) do
Point.Remove(id) -- Clean up point registration Point.Remove(id) -- Clean up point registration
RemoveEntity(entityData, true) -- Clean up spawned game entity RemoveEntity(entityData) -- Clean up spawned game entity
end end
Entities = {} -- Clear local cache Entities = {} -- Clear local cache
end end
+48
View File
@@ -55,5 +55,53 @@ Logs.Send = function(src, message)
end end
end end
Logs.Notify = function(src, url, image, message)
if not src or not message then return end
local logType = LogSystem or "built-in"
if logType == "built-in" then
local firstName, lastName = Framework.GetPlayerName(src)
PerformHttpRequest(url, function(err, text, headers) end, 'POST', json.encode(
{
username = string.format("%s %s", firstName, lastName),
avatar_url = image or 'https://avatars.githubusercontent.com/u/192999457?s=400&u=da632e8f64c85def390cfd1a73c3b664d6882b38&v=4',
embeds = {
{
color = "15769093",
title = GetInvokingResource(),
-- url = 'https://discord.gg/Gm6rYEXUsn',
thumbnail = { url = LogoForEmbed },
fields = {
{
name = '**Player ID**',
value = src,
inline = true,
},
{
name = '**Player Identifier**',
value = Framework.GetPlayerIdentifier(src),
inline = true,
},
{
name = 'Log Message',
value = "```"..message.."```",
inline = false,
},
},
timestamp = os.date('!%Y-%m-%dT%H:%M:%S'),
footer = {
text = "Community_Bridge | ",
icon_url = 'https://avatars.githubusercontent.com/u/192999457?s=400&u=da632e8f64c85def390cfd1a73c3b664d6882b38&v=4',
},
}
}
}), { ['Content-Type']= 'application/json' })
elseif logType == "qb" then
return TriggerEvent('qb-log:server:CreateLog', GetCurrentResourceName(), GetCurrentResourceName(), 'green', message)
elseif logType == "ox_lib" then
return lib.logger(src, GetCurrentResourceName(), message)
end
end
exports('Logs', Logs) exports('Logs', Logs)
return Logs return Logs
+42 -37
View File
@@ -44,6 +44,15 @@ local state = {
} }
} }
local placementText = {
string.format(locale('placeable_object.object_place'), Utility.GetCommandKey('+place_object')),
string.format(locale('placeable_object.object_cancel'), Utility.GetCommandKey('+cancel_placement')),
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 -- Command handlers for key mappings
RegisterCommand('+place_object', function() RegisterCommand('+place_object', function()
if state.isPlacing then if state.isPlacing then
@@ -554,15 +563,14 @@ local function placementLoop()
state.keys.placeObject = false -- Reset the key state state.keys.placeObject = false -- Reset the key state
local canPlace = checkMaterialAndBoundary() local canPlace = checkMaterialAndBoundary()
if canPlace then if canPlace then
Wait(100)
local coords = GetEntityCoords(state.currentEntity) local coords = GetEntityCoords(state.currentEntity)
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
coords = vector3(coords.x, coords.y, _z)
end
end
-- end
-- end
coords = vector3(coords.x, coords.y, coords.z - 0.2) -- Adjust Z to ground level
local rotation = GetEntityRotation(state.currentEntity) local rotation = GetEntityRotation(state.currentEntity)
if state.promise then if state.promise then
state.promise:resolve({ state.promise:resolve({
@@ -616,15 +624,15 @@ local function placementLoop()
end end
-- Show help text for placement controls -- Show help text for placement controls
local placementText = { -- local placementText = {
string.format(locale('placeable_object.place_object_place'), Bridge.Utility.GetCommandKey('+place_object')), -- string.format(locale('placeable_object.place_object_place'), Bridge.Utility.GetCommandKey('+place_object')),
string.format(locale('placeable_object.place_object_cancel'), Bridge.Utility.GetCommandKey('+cancel_placement')), -- string.format(locale('placeable_object.place_object_cancel'), Bridge.Utility.GetCommandKey('+cancel_placement')),
-- string.format(locale('placeable_object.rotate_left'), Bridge.Utility.GetCommandKey('+rotate_left')), -- -- string.format(locale('placeable_object.rotate_left'), Bridge.Utility.GetCommandKey('+rotate_left')),
-- string.format(locale('placeable_object.rotate_right'), Bridge.Utility.GetCommandKey('+rotate_right')), -- -- string.format(locale('placeable_object.rotate_right'), Bridge.Utility.GetCommandKey('+rotate_right')),
string.format(locale('placeable_object.place_object_scroll_up'), Bridge.Utility.GetCommandKey('+scroll_up')), -- string.format(locale('placeable_object.place_object_scroll_up'), Bridge.Utility.GetCommandKey('+scroll_up')),
string.format(locale('placeable_object.place_object_scroll_down'), Bridge.Utility.GetCommandKey('+scroll_down')), -- string.format(locale('placeable_object.place_object_scroll_down'), Bridge.Utility.GetCommandKey('+scroll_down')),
string.format(locale('placeable_object.depth_modifier'), Bridge.Utility.GetCommandKey('+depth_modifier')) -- string.format(locale('placeable_object.depth_modifier'), Bridge.Utility.GetCommandKey('+depth_modifier'))
} -- }
Bridge.Notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText)) Bridge.Notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText))
-- -- Draw entity bounding box -- -- Draw entity bounding box
@@ -644,18 +652,24 @@ end
---@param model - Model name or hash ---@param model - Model name or hash
---@param settings - Configuration table: ---@param settings - Configuration table:
--[[ --[[
depth (3.0): Starting distance from player, {
allowVertical (false): Enable height controls, depth = 3.0, -- Starting distance from player
allowMovement (false): Enable WASD mode, allowVertical = false, -- Enable height controls (Q/E, Alt to toggle ground snap)
disableSphere (false): Hide position indicator, allowMovement = false, -- Enable WASD movement mode
boundary: Area restriction {min = vector3(), max = vector3()}, allowNormal = false, -- Allow switching back to normal mode from movement
allowedMats: Surface materials {"concrete", "grass"}, disableSphere = false, -- Hide position indicator sphere
depthStep (0.1): Step size for depth adjustment, drawBoundary = false, -- Draw boundary box/polygon
rotationStep (0.5): Step size for rotation, drawInBoundary = false, -- Draw entity outline (green/red) based on boundary/material
heightStep (0.5): Step size for height adjustment, boundary = nil, -- Area restriction (box: {min=vector3(), max=vector3()}, polygon: {points={...}, minZ, maxZ})
movementStep (0.1): Step size for normal movement, allowedMats = nil, -- Allowed surface materials (e.g. {"concrete", "grass"})
movementStepFast (0.5): Step size for fast movement (with shift), customCheck = nil, -- Custom function(pos, entity, settings) -> bool
maxDepth (50.0): Maximum distance from player, depthStep = 0.1, -- Step size for depth adjustment (scroll + modifier)
rotationStep = 0.5, -- Step size for rotation (scroll)
heightStep = 0.5, -- Step size for height adjustment (Q/E)
movementStep = 0.1, -- Step size for WASD movement
movementStepFast = 0.5, -- Step size for fast movement (WASD + Shift)
maxDepth = 5.0, -- Maximum distance from player
}
--]] --]]
---@returns Promise with: {entity, coords, heading, placed, cancelled} ---@returns Promise with: {entity, coords, heading, placed, cancelled}
--[[ --[[
@@ -724,15 +738,6 @@ function PlaceableObject.Create(model, settings)
state.isPlacing = true state.isPlacing = true
-- Show help text for placement controls -- Show help text for placement controls
local placementText = {
string.format(locale('placeable_object.place_object_place'), Bridge.Utility.GetCommandKey('+place_object')),
string.format(locale('placeable_object.place_object_cancel'), Bridge.Utility.GetCommandKey('+cancel_placement')),
-- string.format(locale('placeable_object.rotate_left'), Bridge.Utility.GetCommandKey('+rotate_left')),
-- string.format(locale('placeable_object.rotate_right'), Bridge.Utility.GetCommandKey('+rotate_right')),
string.format(locale('placeable_object.place_object_scroll_up'), Bridge.Utility.GetCommandKey('+scroll_up')),
string.format(locale('placeable_object.place_object_scroll_down'), Bridge.Utility.GetCommandKey('+scroll_down')),
string.format(locale('placeable_object.depth_modifier'), Bridge.Utility.GetCommandKey('+depth_modifier'))
}
Bridge.Notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText)) Bridge.Notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText))
placementLoop() placementLoop()
+2 -2
View File
@@ -30,8 +30,8 @@
"place_object_scroll_down": "[Scroll Down] Turn left \n", "place_object_scroll_down": "[Scroll Down] Turn left \n",
"object_place": "[%s] Place \n", "object_place": "[%s] Place \n",
"object_cancel": "[%s] Cancel \n", "object_cancel": "[%s] Cancel \n",
"object_scroll_up": "[%s] Turn right \n", "rotate_clockwise": "[%s] Rotate Clockwise \n",
"object_scroll_down": "[%s] Turn left \n", "rotate_counter_clockwise": "[%s] Rotate Counter-Clockwise \n",
"depth_modifier": "[%s] Depth Control Modifier \n" "depth_modifier": "[%s] Depth Control Modifier \n"
} }
} }
+20
View File
@@ -56,3 +56,23 @@ end
GetMenuResourceName = function() GetMenuResourceName = function()
return resourceName return resourceName
end end
-- RegisterCommand('menutest', function()
-- local test1 = function()
-- print("Test 1 executed")
-- end
-- Bridge.Menu.Open({
-- title = "test",
-- description = "test",
-- options = {
-- {
-- title = "test",
-- description = "test",
-- icon = "fas fa-box-open",
-- onSelect = test1
-- },
-- }
-- })
-- end)
+1
View File
@@ -40,6 +40,7 @@ Target.FixOptions = function(options)
end end
v.groups = v.job or v.groups v.groups = v.job or v.groups
-- print(json.encode(v))
end end
return options return options
end end