Skip to content

Commit

Permalink
Merge pull request #16 from Maximus7474/adaptable-teleport-positions
Browse files Browse the repository at this point in the history
Adaptable teleport positions
  • Loading branch information
Maximus7474 authored Jul 25, 2024
2 parents 721a26d + 43d3120 commit 5ad6555
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions client/modules/teleport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ end
function TP.GoToNewFloor(elevator, newfloor)
local success = promise.new()
local isVehicle = Config.Elevators?[elevator].vehicle == true
local newfloor = Config.Elevators?[elevator]?.floors?[newfloor]?.position
local newfloor = Config.Elevators?[elevator]?.floors?[newfloor]

if elevator == nil or newfloor == nil or newfloor?.xyz == nil then
DebugPrint("[^2TP^7] ^1Invalid Parameters^7", elevator)
if elevator == nil or newfloor.position == nil or newfloor.position?.xyz == nil then
DebugPrint("[^2TP^7] ^1Invalid Parameters^7 for", elevator)
DebugPrint(
"^3Elevator Data:^7", Config.Elevators?[elevator] or "^1undefined^7",
"^3Floor list:^7", Config.Elevators?[elevator]?.floors or "^1undefined^7",
Expand All @@ -44,9 +44,11 @@ function TP.GoToNewFloor(elevator, newfloor)
DoScreenFadeOut(Config.Options.FadeDuration)
while not IsScreenFadedOut() do Citizen.Wait(10) end

if isVehicle and (cache.vehicle and cache.seat == -1) then
if cache.vehicle then
newfloor = newfloor?.carposition or newfloor.position
TeleportVehicle(newfloor)
elseif not cache.vehicle then
newfloor = newfloor.position
TeleportPlayer(newfloor)
end

Expand Down
9 changes: 6 additions & 3 deletions shared/elevators.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ Config.Elevators = {
floor = "-2",
label = "Garage Entrance",
panel = vector4(-82.5941, -819.1429, 36.0281, 260.1323),
position = vector4(-84.2893, -821.5383, 36.0281 - 0.98, 344.3796)
position = vector4(-82.2491, -819.4501, 36.0281 - 0.98, 352.8853),
carposition = vector4(-84.2893, -821.5383, 36.0281 - 0.98, 344.3796),
},
{
floor = "57",
label = "Interior Garage",
panel = vector4(-92.1781, -821.9614, 222.0004, 251.2057),
position = vector4(-88.2165, -821.2771, 222.0004 - 0.98, 254.0536)
position = vector4(-91.4152, -821.3260, 222.0006 - 0.98, 252.8723),
carposition = vector4(-88.2165, -821.2771, 222.0004 - 0.98, 254.0536)
},
{
floor = "65",
label = "Mod Shop",
panel = vector4(-73.5848, -809.6722, 285.0000, 163.1215),
position = vector4(-73.3622, -813.9121, 284.9999 - 0.98, 163.1935)
position = vector4(-71.4800, -810.8328, 285.0002 - 0.98, 166.4717),
carposition = vector4(-72.6307, -814.1168, 285.0003 - 0.98, 157.9103)
},
}
}
Expand Down

0 comments on commit 5ad6555

Please sign in to comment.