Skip to content
Closed
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
9 changes: 5 additions & 4 deletions lua/autorun/server/advdupe2_sv_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,19 @@ CreateConVar("AdvDupe2_MapFileName", "", {FCVAR_ARCHIVE})
local function PasteMap()
if(GetConVarString("AdvDupe2_LoadMap")=="0")then return end
local filename = GetConVarString("AdvDupe2_MapFileName")
local mapname = game.GetMap()

if(not filename or filename == "")then
print("[AdvDupe2Notify]\tInvalid file name to loap map save.")
return
end

if(not file.Exists("advdupe2/"..filename..".txt", "DATA"))then
if(not file.Exists("advdupe2/maps/"..mapname.."/"..filename..".txt", "DATA"))then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should honestly just be "advdupe2/maps/"..mapname..".txt" and have the cvar deleted.

@NovaAstral NovaAstral Jul 20, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Methinks some people might want to have multiple different saves for a single map

I think the ideal solution would be to implement some kind of save select system like the normal advdupe2 menu so you dont have to futz around with concommands, but that's out of my depth

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The we keep the cvar, its help text should be updated to specify this format.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What stops you from just setting your AdvDupe2_MapFileName to something like maps/gm_mymap/mysave.txt
Currently this change simply limits the files that can be used for map saves to the maps/ folder

@NovaAstral NovaAstral Jul 22, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not much (Other than it seems to refuse to save files with / in their name), but your change made it so it saves to a different folder than it loads from, so when I tried to use the savemap function in this addon, I thought it was simply broken until I looked at the code, you'd have to move the file to the maps/ folder anyway as it currently is

it saving to the maps/ folder also separates it from normal dupes if someone were to use it on their client for whatever reason.
And I can't think of many reasons why someone would want to use the same save on multiple maps

Maybe a better solution would've been to update the wiki and give the cvar a description, but this way is the most intuitive I feel; save map with name, load save with the same name on the same map

print("[AdvDupe2Notify]\tFile does not exist for a map save.")
return
end

local map = file.Read("advdupe2/"..filename..".txt")
local map = file.Read("advdupe2/maps/"..mapname.."/"..filename..".txt")
local success,dupe,info,moreinfo = AdvDupe2.Decode(map)
if not success then
print("[AdvDupe2Notify]\tCould not open map save "..dupe)
Expand Down Expand Up @@ -115,7 +116,7 @@ local function PasteMap()

print("[AdvDupe2Notify]\tMap save pasted.")
end
hook.Add("InitPostEntity", "AdvDupe2_PasteMap", PasteMap)
hook.Add("InitPostEntity", "AdvDupe2_PasteMap", function() timer.Simple(5,PasteMap) end)
hook.Add("PostCleanupMap", "AdvDupe2_PasteMap", PasteMap)
hook.Add("PlayerInitialSpawn","AdvDupe2_AddPlayerTable",function(ply)
ply.AdvDupe2 = {}
Expand Down