Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions SSV2/includes/backend.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end
---@enum eAPIVersion
Enums.eAPIVersion = {
V1 = 1, -- YimMenu V1 (Lua54)
V2 = 2, -- YimMenu V2 (LuaJIT) // placeholder
V2 = 2, -- YimLuaAPI (Lua 54)
L54 = 99, -- Mock environment (Lua54)
}

Expand Down Expand Up @@ -113,7 +113,7 @@ function Backend:GetAPIVersion()
end

if (type(script["run_in_callback"]) == "function") then
error("YmMenu V2 is not supported. If you want to run this script in GTA V Enhanced, download YimLuaAPI.")
error("YimMenuV2 is not supported. If you want to run this script in GTA V Enhanced, download YimLuaAPI.")
end

if (not menu_event or not menu_event.Wndproc) then
Expand Down Expand Up @@ -480,9 +480,7 @@ function Backend:RegisterHandlers()
PAD.DISABLE_CONTROL_ACTION(0, control, true)
end
end)
end

if (self:GetAPIVersion() == Enums.eAPIVersion.V1) then
ThreadManager:RegisterLooped("SS_BACKEND", function()
self:OnPlayerSwitch()
self:OnSessionSwitch()
Expand Down
14 changes: 14 additions & 0 deletions SSV2/includes/data/globals_locals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -892,5 +892,19 @@ return {
}
}
}
},
request_services_global = {
description = "Request Services Global.",
file = "am_prostitute.c", -- definitely the right file to use I'm sure of it
LEGACY = {
value = 2733002,
pattern = [[Global_(\d{7})\.f_4 = 0;]],
capture_group = 1
},
ENHANCED = {
value = 2733138,
pattern = [[Global_(\d{7})\.f_4 = 0;]],
capture_group = 1
}
}
}
4 changes: 2 additions & 2 deletions SSV2/includes/features/CasinoPacino.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ end

---@return boolean
function CasinoPacino:CanAccess()
return (Backend:GetAPIVersion() == Enums.eAPIVersion.V1)
and Backend:IsUpToDate()
return Backend:IsUpToDate()
and Game.IsOnline()
and not Backend:IsMockEnv()
and not script.is_active("maintransition")
and not NETWORK.NETWORK_IS_ACTIVITY_SESSION()
end
Expand Down
11 changes: 11 additions & 0 deletions SSV2/includes/features/YimHeistsV1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,15 @@ function YimHeists:HasSubmarine()
return self.m_properties.submarine
end

-- ---@return vec3?
-- function YimHeists:GetSubmarineLocation()
-- local sub = self:HasSubmarine()
-- if (not sub) then
-- return
-- end

-- sub.coords = Game.Ensure3DCoords(760)
-- return sub.coords
-- end

return YimHeists
3 changes: 1 addition & 2 deletions SSV2/includes/features/YimResupplierV3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,7 @@ function YRV3:MCT()
end

TaskWait(Game.RequestScript, "appArcadeBusinessHub")
---@diagnostic disable-next-line: undefined-global
self.m_bhub_script_handle = (SYSTEM or BUILTIN).START_NEW_SCRIPT("appArcadeBusinessHub", 1424) -- STACK_SIZE_DEFAULT
self.m_bhub_script_handle = SYSTEM.START_NEW_SCRIPT("appArcadeBusinessHub", 1424) -- STACK_SIZE_DEFAULT
SCRIPT.SET_SCRIPT_AS_NO_LONGER_NEEDED("appArcadeBusinessHub")
sleep(100)

Expand Down
21 changes: 7 additions & 14 deletions SSV2/includes/frontend/casino_ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,12 @@ local function drawGamblingTab()
GVars.features.dunk.set_dealers_poker_cards
)

-- TODO: Fix crashing on Enhanced
if (Backend:GetAPIVersion() == Enums.eAPIVersion.V1) then
GUI:HeaderText(_T("CP_BLACKJACK_SETTINGS"), { separator = true, spacing = true })
ImGui.BulletText(_T "CP_BLACKJACK_DEALER_FACE_DOWN_CARD")
ImGui.SameLine()
ImGui.Text(CasinoPacino:GetBJDealerCard())
if GUI:Button(_T "CP_BLACKJACK_FORCE_DEALER_BUST") then
CasinoPacino:ForceDealerBust()
end
GUI:HeaderText(_T("CP_BLACKJACK_SETTINGS"), { separator = true, spacing = true })
ImGui.BulletText(_T "CP_BLACKJACK_DEALER_FACE_DOWN_CARD")
ImGui.SameLine()
ImGui.Text(CasinoPacino:GetBJDealerCard())
if GUI:Button(_T "CP_BLACKJACK_FORCE_DEALER_BUST") then
CasinoPacino:ForceDealerBust()
end

GUI:HeaderText(_T("CP_ROULETTE_SETTINGS"), { separator = true, spacing = true })
Expand Down Expand Up @@ -408,11 +405,7 @@ local function DrawDunk()

if (ImGui.BeginTabBar("##dunkBar")) then
if ImGui.BeginTabItem(_T("CASINO_GAMBLING_TAB")) then
if (Backend:GetAPIVersion() == Enums.eAPIVersion.V1) then
drawGamblingTab()
else
ImGui.Text(_T("CP_FEATURE_DISABLED"))
end
drawGamblingTab()
ImGui.EndTabItem()
end

Expand Down
34 changes: 30 additions & 4 deletions SSV2/includes/frontend/yhv1_ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


local YHV1 = require("includes.features.YimHeistsV1"):init()
local SGSL = require("includes.services.SGSL")
local setTranslations = require("SSV2.includes.frontend.helpers.set_translations")
local heistNames <const> = {
"AWT_1026", -- The Cluckin' Bell Farm Raid
Expand Down Expand Up @@ -79,7 +80,7 @@ local function drawBasicTab()
local heist_name = heist.get_name()
ImGui.BulletText(heist_name)

local location = heist.get_coords()
local location = heist.get_coords() or vec3:zero()
ImGui.BeginDisabled(not location)
if (GUI:Button(_T("GENERIC_TELEPORT"))) then
LocalPlayer:Teleport(location, false)
Expand Down Expand Up @@ -116,18 +117,43 @@ local function drawCayoTab()
return
end

ImGui.BeginDisabled(sub.coords:is_zero())
-- This is shitty, and only properly works when not near the sub. No idea what happens if multiple subs in session
-- TODO: Find and use the correct globals/offsets
local subBlip = Game.Ensure3DCoords(760)
local requestKosatka = SGSL:Get(SGSL.data.request_services_global):AsGlobal():At(613)
local subRequested = requestKosatka:ReadInt() == 1
local subSpawned = not sub.coords:is_zero() and subBlip ~= nil

if (subBlip or not subRequested) then
sub.coords = subBlip or vec3:zero()
end

ImGui.BeginDisabled(not subSpawned)
if (GUI:Button(_T("GENERIC_TELEPORT"))) then
LocalPlayer:Teleport(sub.coords)
LocalPlayer:Teleport(sub.coords + vec3:new(0, 0, -9.8)) -- Teleport under Kosatka
end

ImGui.SameLine()

if (GUI:Button(_T("GENERIC_SET_WAYPOINT"))) then
Game.SetWaypointCoords(sub.coords)
end
ImGui.EndDisabled()

local btn_label = (subRequested)
and ImGui.TextSpinner()
or _T("YH_CAYO_REQUEST_SUB")

ImGui.SameLine()
ImGui.BeginDisabled(subRequested or subSpawned)
if (GUI:Button(btn_label)) then
if (not LocalPlayer:IsOutside()) then
Notifier:ShowError("YHV1", _T("GENERIC_TP_INTERIOR_ERR"))
else
requestKosatka:WriteInt(1)
end
end
ImGui.EndDisabled()

-- https://www.unknowncheats.me/forum/grand-theft-auto-v/695454-edit-cayo-perico-primary-target-stat-yimmenu-v2.html
-- https://www.unknowncheats.me/forum/grand-theft-auto-v/431801-cayo-perico-heist-click.html
local cayo_heist_primary = stats.get_int("MPX_H4CNF_TARGET")
Expand Down
2 changes: 1 addition & 1 deletion SSV2/includes/frontend/yrv3/nightclub.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ return function()
)

ImGui.SetCursorPosX((ImGui.GetCursorPosX() + 40) * 0.5)
-- TODO: Fix glitchy behavior + session disconnect on Enhanced/YLAPI(?)
-- TODO: Fix glitchy behavior + session disconnect on Enhanced
ImGui.BeginDisabled(Game.IsEnhanced())
ImGui.BeginDisabled(prod >= max_units)
this.fast_prod_enabled, _ = GUI:CustomToggle("##fast_prod", this.fast_prod_enabled)
Expand Down
50 changes: 50 additions & 0 deletions SSV2/includes/lib/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,56 @@ local commandRegistry <const> = {
description = "Spawns a vehicle from JSON."
}
},
["teleport"] = {
callback = function(args)
local notifE = function()
Notifier:ShowError(
"CommandExecutor",
"Missing or incorrect parameter. Usage: teleport [X] [Y] [Z]",
true,
5
)
end

if (type(args) ~= "table") then
notifE()
return
end

local x = args[1]
local y = args[2]
local z = args[3]

if (#args < 2) then
local wpc = Game.GetWaypointCoords()
if (not wpc) then
Notifier:ShowError(
"CommandExecutor",
"No waypoint active!",
true,
3
)
return
end

x, y, _ = wpc:unpack()
end

if (type(x) ~= "number" or type(y) ~= "number") then
notifE()
return
end

local coords = vec3:new(x, y, z or 0)
LocalPlayer:Teleport(coords, false, z == nil)
end,
opts = {
description =
"Teleports to given coordinates or waypoint if none given. Will try to teleport to top level if no Z argument given.\nUsage Example:\n - teleport 69 420 69\n - tp 123.456 789.1011",
args = { "X<number>", "Y<number>", "Optional: Z<number>" },
alias = { "tp" }
}
},
}

return commandRegistry
1 change: 1 addition & 0 deletions SSV2/includes/lib/translations/en-US.lua
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ return {
["YH_CAYO_TAB"] = "Cayo Perico",
["YH_SUBMARINE_NOT_OWNED"] = "Purchase a Kosatka to access the Cayo Perico Heist.", -- HIF_SUB_HELP
["YH_PREP_SKIP_NOTIF"] = "All preparation missions have been skipped. You can now start the final mission.",
["YH_CAYO_REQUEST_SUB"] = "Request Submarine",
["YH_CAYO_TARGET_PRIMARY"] = "Primary Target",
["YH_CAYO_TARGET_SECONDARY_I"] = "Secondary Target (Island)",
["YH_CAYO_TARGET_SECONDARY_C"] = "Secondary Target (Compound)",
Expand Down
2 changes: 1 addition & 1 deletion SSV2/includes/modules/Player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ function Player.new(player_id)

local ped_handle = PLAYER.GET_PLAYER_PED_SCRIPT_INDEX(player_id)
---@type Player
---@diagnostic disable-next-line: assign-type-mismatch
local instance = setmetatable({
m_pid = player_id,
m_handle = ped_handle,
---@diagnostic disable-next-line: param-type-mismatch
}, Player)

instance.m_internal = instance:Resolve()
Expand Down
67 changes: 40 additions & 27 deletions SSV2/includes/modules/businesses/Warehouse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,48 @@ local function GetCEOCratesValue(crates)
return 0
end

if (crates == 1) then
return tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD1")
local val
if crates <= 3 then
val = tostring(crates)
elseif crates <= 5 then
val = "4"
elseif crates <= 7 then
val = "5"
elseif crates <= 9 then
val = "6"
elseif crates <= 14 then
val = "7"
elseif crates <= 19 then
val = "8"
elseif crates <= 24 then
val = "9"
elseif crates <= 29 then
val = "10"
elseif crates <= 34 then
val = "11"
elseif crates <= 39 then
val = "12"
elseif crates <= 44 then
val = "13"
elseif crates <= 49 then
val = "14"
elseif crates <= 59 then
val = "15"
elseif crates <= 69 then
val = "16"
elseif crates <= 79 then
val = "17"
elseif crates <= 89 then
val = "18"
elseif crates <= 99 then
val = "19"
elseif crates <= 110 then
val = "20"
elseif crates == 111 then
val = "21"
end

if (crates == 2) then
return tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD2") * 2 -- +1
end

if (crates == 3) then
return tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD3") * 3 -- +1
end

if (crates == 4 or crates == 5) then
return tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD4") * crates -- +1
end

if (crates >= 6 and crates <= 9) then
return (tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD4") + math.floor((crates - 4) / 2)) * crates -- +0
end

if (crates >= 10 and crates <= 110) then
return (tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD7") + math.floor((crates - 10) / 5)) * crates -- +3
end

if (crates == 111) then
return tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD21") * 111 -- + 14
end

return 0
return val and (tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD" .. val) * crates) or 0
end

---@enum eWarehouseType
Expand Down
3 changes: 2 additions & 1 deletion SSV2/includes/services/GUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ end

---@return float
function GUI:GetMaxTopBarHeight()
return Game.GetScreenResolution().y * 0.115
-- return Game.GetScreenResolution().y * 0.115 -- Incorrect sizing on anything not 1080p
return 124.2 -- 1080 * 0.115
end

---@param align? number -- 0: top center | 1: bottom center | 2: left center | 3: right center | 4: center
Expand Down
2 changes: 1 addition & 1 deletion dev/scripts/offsets/update_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def serialize_lua(v, indent=1):

parts = []
for k, vv in v.items():
if k == "pattern":
if (k == "pattern") or ((k == "description") and ("\n" in vv)):
vv = f"[[{vv}]]"
parts.append(f"{sp}{k} = {vv}")
else:
Expand Down