Skip to content

Commit

Permalink
Fix missing data creation and Lua error with logging
Browse files Browse the repository at this point in the history
  • Loading branch information
VickyFrenzy committed Jan 12, 2025
1 parent d66d7f0 commit a5135d5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 15 additions & 1 deletion gamemodes/fnafgm/entities/entities/fnafgm_camera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,27 @@ ENT.DisableDuplicator = true
ENT.DoNotDuplicate = true
ENT.PhysgunDisabled = true

function ENT:SetupLocName(sCam)
function ENT:SetupCamName(sCam)
if GAMEMODE.CamsNames[sCam] then return end
local sLocName = self:GetLocName()
if not sLocName or sLocName == "" then return end
GAMEMODE.CamsNames[sCam] = sLocName
end

function ENT:SetupPosName()
local sMap = game.GetMap()
if not GAMEMODE.APos[sMap] then GAMEMODE.APos[sMap] = {} end
local sLocName = self:GetLocName()
if GAMEMODE.APos[sMap][sLocName] then return end
if not sLocName or sLocName == "" then return end
GAMEMODE.APos[sMap][sLocName] = self:GetCamID()
end

function ENT:SetupLocName(sCam)
self:SetupCamName(sCam)
self:SetupPosName()
end

function ENT:Initialize()
if CLIENT then return end
if self:GetCamID() ~= 0 then return end
Expand Down
8 changes: 6 additions & 2 deletions gamemodes/fnafgm/gamemode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2533,10 +2533,14 @@ function GM:SetAnimatronicPos(ply, a, apos)
net.Start("fnafgmAnimatronicsList")
net.WriteTable(GAMEMODE.Vars.Animatronics)
net.Broadcast()

local sAnimatronic = GAMEMODE.AnimatronicName[a] or "undefined"
local sCamName = GAMEMODE.CamsNames[game.GetMap() .. "_" .. apos] or "undefined"
local sLog = "Animatronic " .. sAnimatronic .. " (" .. (a or 0) .. ")" .. " moved to " .. sCamName .. " (" .. (apos or 7) .. ")"
if IsValid(ply) then
GAMEMODE:Log("Animatronic " .. ((GAMEMODE.AnimatronicName[a] .. " (" .. (a or 0) .. ")") or a or 0) .. " moved to " .. ((GAMEMODE.CamsNames[game.GetMap() .. "_" .. apos] .. " (" .. (apos or 7) .. ")") or apos or 7) .. " by " .. ply:GetName())
GAMEMODE:Log(sLog .. " by " .. ply:GetName())
else
GAMEMODE:Log("Animatronic " .. ((GAMEMODE.AnimatronicName[a] .. " (" .. (a or 0) .. ")") or a or 0) .. " moved to " .. ((GAMEMODE.CamsNames[game.GetMap() .. "_" .. apos] .. " (" .. (apos or 7) .. ")") or apos or 7) .. " by console/script", nil, true)
GAMEMODE:Log(sLog .. " by console/script", nil, true)
end
end
end
Expand Down

0 comments on commit a5135d5

Please sign in to comment.