Closed USBMenus closed 6 months ago
Nice, however, owned properties use blip teleports so they generate automatically. Otherwise this is clean, thank you for contributing!
I will add these changes in v0.9.4 update, either tonight or tomorrow itll be there.
also @USBMenus i added you as a collaborator, should be able to make changes, im new to git repos lol
Nice, however, owned properties use blip teleports so they generate automatically. Otherwise this is clean, thank you for contributing!
I will add these changes in v0.9.4 update, either tonight or tomorrow itll be there.
also @USBMenus i added you as a collaborator, should be able to make changes, im new to git repos lol
ok thank you, i will try to sort out the blips but might not be till tomorrow
Improvements added and changes made!
`local Tel = Pla:add_tab("Teleports")
local locationIndex = 0 local locationTypeIndex = 0
locationTypes = {"Custom", "Owned"}
customCoords = { {"Eclipse Towers Front Door", -774.77, 312.19, 85.70}, {"Casino", 922.223938, 49.779373, 80.764793}, {"LS Customs", -370.269958, -129.910370, 38.681633}, {"Eclipse Towers", -773.640869, 305.234619, 85.705841}, {"Record A Studios", -835.250427, -226.589691, 37.267345}, {"Luxury Autos", -796.260986, -245.412369, 37.079193}, {"Suburban", -1208.171387, -782.429016, 17.157467}, {"Mask Shop", -1339.069946, -1279.114502, 4.866990}, {"Poisonby's", -719.559692, -157.998932, 36.998993}, {"Benny's", -205.040863, -1305.484009, 31.369892}, }
ownedCoords = { {"Safehouse", 40}, {"Office", 475}, {"Arena", 643}, {"Bunker", 557}, {"Arcade", 740}, {"Auto Shop", 779}, {"Agency", 826}, {"Clubhouse", 492}, {"Hangar", 569}, {"Facility", 590}, {"Night Club", 614}, {"Freakshop", 847}, {"Salvage Yard", 867}, {"Eclipse Garage", 856}, {"Yacht", 455}, {"Kosatka", 760}, }
locations = {customCoords, ownedCoords}
local function findNearestOwnedBlip(propertyId) local nearestBlipId = findNearestBlip(propertyId) if nearestBlipId then local blipCoords = HUD.GET_BLIP_COORDS(nearestBlipId) return blipCoords.x, blipCoords.y, blipCoords.z else return 0, 0, 0 end end
Tel:add_imgui(function() copyLocation = ImGui.Button("Copy Location To Clipboard") locationTypeIndex, locationTypeSelected = ImGui.Combo("Location Type", locationTypeIndex, locationTypes, #locationTypes) locationNames = {} for i, location in ipairs(locations[locationTypeIndex + 1]) do table.insert(locationNames, location[1]) end locationIndex, locationSelected = ImGui.ListBox("Locations", locationIndex, locationNames, #locationNames) if locationSelected then local coords if locationTypeIndex == 0 then -- Custom Locations coords = { x = locations[locationTypeIndex + 1][locationIndex + 1][2], y = locations[locationTypeIndex + 1][locationIndex + 1][3], z = locations[locationTypeIndex + 1][locationIndex + 1][4] } else -- Owned Locations coords = { findNearestOwnedBlip(locations[locationTypeIndex + 1][locationIndex + 1][2]) } end ENTITY.SET_ENTITY_COORDS(PLAYER.PLAYER_PED_ID(), coords.x, coords.y, coords.z - 1, true, false, false, false) end if copyLocation then coords = ENTITY.GET_ENTITY_COORDS(PLAYER.PLAYER_PED_ID(), true) coordsString = coords.x.. ", ".. coords.y.. ", ".. coords.z gui.show_message("Clipboard", "Copied ".. coordsString.. " to clipboard.") ImGui.SetClipboardText(coordsString) end end)`
nice, this is what i did
-- Teleports tab
local Tel = Pla:add_tab("Teleports")
-- Define your array with names and IDs
local properties = {
{name = "Safehouse", id = 40}, {name = "Office", id = 475}, {name = "Arena", id = 643}, {name = "Bunker", id = 557}, {name = "Arcade", id = 740},
{name = "Auto Shop", id = 779}, {name = "Agency", id = 826}, {name = "Clubhouse", id = 492}, {name = "Hangar", id = 569}, {name = "Facility", id = 590},
{name = "Night Club", id = 614}, {name = "Freakshop", id = 847}, {name = "Salvage Yard", id = 867}, {name = "Eclipse Garage", id = 856}, {name = "Yacht", id = 455},
{name = "Kosatka", id = 760},
-- Add more properties as needed
-- Cayo Drainage = 768
}
local function findNearestBlip(propertyId)
local ped = PLAYER.PLAYER_PED_ID()
local minDistanceSquared = math.huge
local nearestBlipId = nil
local iterator = propertyId
local blipId = HUD.GET_FIRST_BLIP_INFO_ID(iterator)
while blipId ~= 0 do
local blipCoords = HUD.GET_BLIP_COORDS(blipId)
local distanceSquared = MISC.GET_DISTANCE_BETWEEN_COORDS(ped, blipCoords.x, blipCoords.y, blipCoords.z, 1, 0, false)
if distanceSquared < minDistanceSquared and blipId ~= propertyId then
minDistanceSquared = distanceSquared
nearestBlipId = blipId
end
blipId = HUD.GET_NEXT_BLIP_INFO_ID(iterator)
end
return nearestBlipId
end
local function addBlips(array)
for _, property in ipairs(properties) do
local ped = PLAYER.PLAYER_PED_ID()
local nearestBlipId = findNearestBlip(property.id)
if nearestBlipId then
local blipCoords = HUD.GET_BLIP_COORDS(nearestBlipId)
if property.id == 760 then
table.insert(array, {property.name, blipCoords.x, blipCoords.y, blipCoords.z + 8})
elseif property.id == 740 then
table.insert(array, {property.name, blipCoords.x + 10, blipCoords.y - 5, blipCoords.z})
else
table.insert(array, {property.name, blipCoords.x, blipCoords.y, blipCoords.z})
end
end
end
end
local locationIndex = 0
local locationTypeIndex = 0
locationTypes = {"Custom", "Owned"}
customCoords = {
{"Eclipse Towers Front Door", -774.77, 312.19, 85.70},
{"Custom Location 2", 0, 0, 0},
{"Custom Location 3", 0, 0, 0}
}
ownedCoords = {}
locations = {customCoords, ownedCoords}
addBlips(ownedCoords)
Tel:add_imgui(function()
copyLocation = ImGui.Button("Copy Location To Clipboard")
locationTypeIndex, locationTypeSelected = ImGui.Combo("Location Type", locationTypeIndex, locationTypes, #locationTypes)
locationNames = {}
for i, location in ipairs(locations[locationTypeIndex + 1]) do
table.insert(locationNames, location[1])
end
locationIndex, locationSelected = ImGui.ListBox("Locations", locationIndex, locationNames, #locationNames)
if locationSelected then
ENTITY.SET_ENTITY_COORDS(PLAYER.PLAYER_PED_ID(), locations[locationTypeIndex + 1][locationIndex + 1][2], locations[locationTypeIndex + 1][locationIndex + 1][3], locations[locationTypeIndex + 1][locationIndex + 1][4] - 1, true, false, false, false)
end
if copyLocation then
coords = ENTITY.GET_ENTITY_COORDS(PLAYER.PLAYER_PED_ID(), true)
coordsString = coords.x.. ", ".. coords.y.. ", ".. coords.z
gui.show_message("Clipboard", "Copied ".. coordsString.. " to clipboard.")
ImGui.SetClipboardText(coordsString)
end
end)
i like the way mine is written cause its a lot easier to read, and it will work with pretty much anything, not sure what you want to do tho
but i do like that the your propeties array is shorter
i like the way mine is written cause its a lot easier to read, and it will work with pretty much anything, not sure what you want to do tho
but i do like that the your propeties array is shorter
Added yours in bc it looks much cleaner imo. Great job, credits in the addon script!
i like the way mine is written cause its a lot easier to read, and it will work with pretty much anything, not sure what you want to do tho but i do like that the your propeties array is shorter
Added yours in bc it looks much cleaner imo. Great job, credits in the addon script!
thank you my friend
this improves the usage of the teleports tab and lets the user add there own teleports and make it easily expandable, also lets you copy your coords to clipboard for easier location additions