Mapoutfit improvements (#1249)

Improve pac map spawn and error proof it
This commit is contained in:
Redox 2022-10-29 19:50:23 +02:00 committed by CapsAdmin
parent b45c718495
commit f459b2e423
2 changed files with 9 additions and 10 deletions

View File

@ -3,6 +3,7 @@ pace = pace or {}
-- for the default models
resource.AddWorkshop("104691717")
pace.luadata = include("pac3/libraries/luadata.lua")
pace.Parts = pace.Parts or {}
pace.Errors = {}

View File

@ -133,23 +133,21 @@ end
concommand.Add("pac_spawn_map", function(ply, _, args)
if not ply:IsAdmin() then return end
for k,v in pairs(pacx.SpawnedMapEntities) do
if not args[1] then
return ply:PrintMessage(HUD_PRINTCONSOLE, "Please enter a pac name")
end
for _,v in pairs(pacx.SpawnedMapEntities) do
SafeRemoveEntity(v)
end
pacx.SpawnedMapEntities = {}
local data = file.Read("pac3/" .. args[1] .. ".txt", "DATA")
local data = pace.luadata.ReadFile("pac3/" .. args[1] .. ".txt")
if data then
data = CompileString("return {" .. data .. "}", "luadata", true)
if isfunction(data) then
pacx.SpawnMapOutfit(data())
else
pac.Message(data)
end
pacx.SpawnMapOutfit(data)
else
pac.Message(data)
end
end)
end)