made woopsie to entities
This commit is contained in:
1 parent
d0f9fb7ca3
commit
140bad5b34
6 files changed
+130
-49
No files matched your search
@@ -45,19 +45,26 @@ local function SpawnEntity(entityData)
|
||||
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
|
||||
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
|
||||
local entityHandle = entityData.spawned
|
||||
entityData.spawned = nil
|
||||
SetEntityAsMissionEntity(entityHandle, false, false)
|
||||
DeleteEntity(entityHandle)
|
||||
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.
|
||||
@@ -239,7 +246,7 @@ AddEventHandler('onResourceStop', function(resourceName)
|
||||
if resourceName == GetCurrentResourceName() then
|
||||
for id, entityData in pairs(Entities) do
|
||||
Point.Remove(id) -- Clean up point registration
|
||||
RemoveEntity(entityData, true) -- Clean up spawned game entity
|
||||
RemoveEntity(entityData) -- Clean up spawned game entity
|
||||
end
|
||||
Entities = {} -- Clear local cache
|
||||
end
|
||||
|
||||
@@ -55,5 +55,53 @@ Logs.Send = function(src, message)
|
||||
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)
|
||||
return Logs
|
||||
@@ -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,
|
||||
@@ -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
|
||||
RegisterCommand('+place_object', function()
|
||||
if state.isPlacing then
|
||||
@@ -554,15 +563,14 @@ local function placementLoop()
|
||||
state.keys.placeObject = false -- Reset the key state
|
||||
local canPlace = checkMaterialAndBoundary()
|
||||
if canPlace then
|
||||
Wait(100)
|
||||
local coords = GetEntityCoords(state.currentEntity)
|
||||
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
|
||||
coords = vector3(coords.x, coords.y, _z)
|
||||
end
|
||||
end
|
||||
|
||||
-- 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
|
||||
local rotation = GetEntityRotation(state.currentEntity)
|
||||
if state.promise then
|
||||
state.promise:resolve({
|
||||
@@ -616,15 +624,15 @@ local function placementLoop()
|
||||
end
|
||||
|
||||
-- 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'))
|
||||
}
|
||||
-- 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))
|
||||
|
||||
-- -- Draw entity bounding box
|
||||
@@ -644,18 +652,24 @@ end
|
||||
---@param model - Model name or hash
|
||||
---@param settings - Configuration table:
|
||||
--[[
|
||||
depth (3.0): Starting distance from player,
|
||||
allowVertical (false): Enable height controls,
|
||||
allowMovement (false): Enable WASD mode,
|
||||
disableSphere (false): Hide position indicator,
|
||||
boundary: Area restriction {min = vector3(), max = vector3()},
|
||||
allowedMats: Surface materials {"concrete", "grass"},
|
||||
depthStep (0.1): Step size for depth adjustment,
|
||||
rotationStep (0.5): Step size for rotation,
|
||||
heightStep (0.5): Step size for height adjustment,
|
||||
movementStep (0.1): Step size for normal movement,
|
||||
movementStepFast (0.5): Step size for fast movement (with shift),
|
||||
maxDepth (50.0): Maximum distance from player,
|
||||
{
|
||||
depth = 3.0, -- Starting distance from player
|
||||
allowVertical = false, -- Enable height controls (Q/E, Alt to toggle ground snap)
|
||||
allowMovement = false, -- Enable WASD movement mode
|
||||
allowNormal = false, -- Allow switching back to normal mode from movement
|
||||
disableSphere = false, -- Hide position indicator sphere
|
||||
drawBoundary = false, -- Draw boundary box/polygon
|
||||
drawInBoundary = false, -- Draw entity outline (green/red) based on boundary/material
|
||||
boundary = nil, -- Area restriction (box: {min=vector3(), max=vector3()}, polygon: {points={...}, minZ, maxZ})
|
||||
allowedMats = nil, -- Allowed surface materials (e.g. {"concrete", "grass"})
|
||||
customCheck = nil, -- Custom function(pos, entity, settings) -> bool
|
||||
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}
|
||||
--[[
|
||||
@@ -724,15 +738,6 @@ function PlaceableObject.Create(model, settings)
|
||||
state.isPlacing = true
|
||||
|
||||
-- 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))
|
||||
|
||||
placementLoop()
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@
|
||||
"place_object_scroll_down": "[Scroll Down] Turn left \n",
|
||||
"object_place": "[%s] Place \n",
|
||||
"object_cancel": "[%s] Cancel \n",
|
||||
"object_scroll_up": "[%s] Turn right \n",
|
||||
"object_scroll_down": "[%s] Turn left \n",
|
||||
"rotate_clockwise": "[%s] Rotate Clockwise \n",
|
||||
"rotate_counter_clockwise": "[%s] Rotate Counter-Clockwise \n",
|
||||
"depth_modifier": "[%s] Depth Control Modifier \n"
|
||||
}
|
||||
}
|
||||
@@ -55,4 +55,24 @@ end
|
||||
|
||||
GetMenuResourceName = function()
|
||||
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)
|
||||
@@ -40,6 +40,7 @@ Target.FixOptions = function(options)
|
||||
|
||||
end
|
||||
v.groups = v.job or v.groups
|
||||
-- print(json.encode(v))
|
||||
end
|
||||
return options
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user