Skip to content

Instantly share code, notes, and snippets.

@ExtReMLapin
Last active November 19, 2022 13:33
Show Gist options
  • Save ExtReMLapin/e546224d58cd246169f1b4e00507b2ae to your computer and use it in GitHub Desktop.
Save ExtReMLapin/e546224d58cd246169f1b4e00507b2ae to your computer and use it in GitHub Desktop.
in gta online with stand mod menu, find players in parties
local hardcodedLocations = {MUSIC_LOCKER = 281089}
local locationsHashtable = {}
for k, v in pairs(hardcodedLocations) do locationsHashtable[v] = k end
local unsortex_bbox = {{4945.39453125, -4923.5698242188 ,100},
{4851.3471679688, -4903.8276367188 ,-100},
{4858.2309570312, -4964.6494140625 ,0},
{4942.537109375, -4876.8325195312 ,0}}
local min_cayo_bbox = {math.min(unsortex_bbox[1][1], unsortex_bbox[2][1], unsortex_bbox[3][1], unsortex_bbox[4][1]), math.min(unsortex_bbox[1][2], unsortex_bbox[2][2], unsortex_bbox[3][2], unsortex_bbox[4][2]), math.min(unsortex_bbox[1][3], unsortex_bbox[2][3], unsortex_bbox[3][3], unsortex_bbox[4][3])}
local max_cayo_bbox = {math.max(unsortex_bbox[1][1], unsortex_bbox[2][1], unsortex_bbox[3][1], unsortex_bbox[4][1]), math.max(unsortex_bbox[1][2], unsortex_bbox[2][2], unsortex_bbox[3][2], unsortex_bbox[4][2]), math.max(unsortex_bbox[1][3], unsortex_bbox[2][3], unsortex_bbox[3][3], unsortex_bbox[4][3])}
local CAYO_BBOX = {min_cayo_bbox, max_cayo_bbox}
local function is_vec3_in_cayo_party(vec3)
return vec3.x > CAYO_BBOX[1][1] and vec3.x < CAYO_BBOX[2][1] and vec3.y > CAYO_BBOX[1][2] and vec3.y < CAYO_BBOX[2][2] and vec3.z > CAYO_BBOX[1][3] and vec3.z < CAYO_BBOX[2][3]
end
local function detectParties()
ret = {}
for k, v in pairs(players.list(true, true, true)) do
local pos = players.get_position(v)
local interior = INTERIOR.GET_INTERIOR_AT_COORDS(pos.x, pos.y, pos.z)
if locationsHashtable[interior] ~= nil or
(interior == 0 and is_vec3_in_cayo_party(pos)) then
if locationsHashtable[interior] ~= nil then
ret[v] = locationsHashtable[interior]
else
ret[v] = "CAYO_PERICO_PARTY"
end
end
end
return ret
end
menu.action(menu.my_root(), "detect interior location", {}, "", function()
-- print local player location id
local playerPos = players.get_position(players.user())
print(
"position " .. tostring(playerPos.x) .. " " .. tostring(playerPos.y) ..
" " .. tostring(playerPos.z))
local playerInterior = INTERIOR.GET_INTERIOR_FROM_ENTITY(players.user())
print("player interior: " .. playerInterior)
end)
local searching = false
local menuLoopSearch
menuLoopSearch = menu.my_root():toggle_loop("Search for lobby with party", {}, "", function(on)
print("LoopSearch...")
if not util.is_session_started() then
util.yield(100)
return
end
local coolPlayers = detectParties()
if next(coolPlayers) == nil then
--change session run command "go online"
print("no cool players found")
for k, v in pairs(players.list(true, true, true)) do
local pos = players.get_position(v)
local interior = INTERIOR.GET_INTERIOR_AT_COORDS(pos.x, pos.y, pos.z)
print("player " .. players.get_name(v) .. " interior: " .. interior)
end
util.yield(100)
print("aborting lobby join, nothing to see in there")
menu.trigger_commands("unstuck")
util.yield(5000)
print("starting a new search")
menu.trigger_commands("go public")
print("waiting to leave cur session 7 secs...")
util.yield(7000)
print("done")
return
else
for k, v in pairs(coolPlayers) do
print("cool player found: " .. players.get_name(k) .. " " .. v)
end
menu.set_value(menuLoopSearch, false)
end
end)
menu.set_value(menuLoopSearch, false)
util.create_tick_handler(function()
if not util.is_session_started() then
util.draw_debug_text("session not started")
return true
end
local coolPlayers = detectParties()
for k, v in pairs(coolPlayers) do
util.draw_debug_text(players.get_name(k) .. " is in " .. v)
end
return true
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment