I remember when I looked through the lua of the OLD zombie survival on garrysmod.org,
there was a file called mapeditor.lua in the gamemodes\zombiesurvival\gamemode directory.
Here's a snippet from the code which can be used to remove a secret (I added comments // for what each line does):
concommand.Add("mapeditor_remove", function(sender, command, arguments) //Creates a console command called "mapeditor_remove" which calls upon a function
if not sender:IsSuperAdmin() then return end //Checks if the player who executed the command is a Super Admin
local tr = sender:TraceLine(3000) //Gets the traced aimposition WITHIN 3000 units of the person who executed the command
if tr.Entity and tr.Entity:IsValid() then //If the object the person is staring at is a entity then
for i, ent in ipairs(GAMEMODE.MapEditorEntities) do //For all the entities in the whole map
if ent == tr.Entity then //Checks if all entities in the above table are in the players traceline
table.remove(GAMEMODE.MapEditorEntities, i) //Gets the table of entities within the players traceline
ent:Remove() //Removes them
end
end
GAMEMODE:SaveMapEditorFile() //Saves the map file (not the .bsp but a .lua)
end
end)
When the map is saved, a .lua is created to execute whenever the map loads. This .lua applies all of the changes made with the mapeditor.lua .
Here is an example, zs_stormier_b1.lua from gamemodes\zombiesurvival\gamemode\maps (I added comments // once again):
hook.Add("InitPostEntity", "Adding", function() //Hook is created, which runs constantly during the game
hook.Remove("InitPostEntity", "Adding") //Removes the hook, as it only has to apply its changes once to delete the entities
for _, ent in pairs(ents.FindByClass("trigger_teleport")) do //Searches the whole map for entities that are a trigger_teleport
ent:Remove() //Removes the entities marked in the above command
end
end)
How can we apply this to our Zombie Survival?
This has to be done by an administrator who has the power to add .lua files to the zombie survival server's main gamemode files.
Let's do the work for him and make the zs_<mapname>.lua for him so the work is divided between the two parties.
Let me contribute:
[@gamemodes\zombiesurvival\gamemode\maps] zs_inversion_v3.lua
hook.Add("InitPostEntity", "Adding", function()
hook.Remove("InitPostEntity", "Adding")
for _, ent in pairs(ents.FindByClass("weapon_zs_barricadekit")) do
ent:Remove()
end
end)
[@gamemodes\zombiesurvival\gamemode\maps] zs_underpass_330.lua
hook.Add("InitPostEntity", "Adding", function()
hook.Remove("InitPostEntity", "Adding")
for _, ent in pairs(ents.FindByClass("weapon_zs_magnum")) do
ent:Remove()
end
for _, ent in pairs(ents.FindByClass("weapon_zs_shovel")) do
ent:Remove()
end
for _, ent in pairs(ents.FindByClass("item_ammo_crate")) do
ent:Remove()
end
end)
[@gamemodes\zombiesurvival\gamemode\maps] zs_cosmiclounge_final.lua
hook.Add("InitPostEntity", "Adding", function()
hook.Remove("InitPostEntity", "Adding")
for _, ent in pairs(ents.FindByClass("weapon_zs_barricadekit")) do
ent:Remove()
end
for _, ent in pairs(ents.FindByClass("item_ammo_crate")) do
ent:Remove()
end
end)
It's only a matter of time until we start removing secrets.
As for secret areas, that would require recompiling the map with changes (unless we can create solids with lua?)