Put in check to prevent Trying to Reference a Nil error in Apply_Modifier.

This commit is contained in:
Michieal 2023-12-08 20:38:07 -05:00 committed by the-real-herowl
parent 4f3f59f4bc
commit 2f8389d3f5

View file

@ -74,9 +74,11 @@ function mcl_fovapi.apply_modifier(player, modifier_name)
if mcl_fovapi.registered_modifiers[modifier_name] == nil then if mcl_fovapi.registered_modifiers[modifier_name] == nil then
return return
end end
if mcl_fovapi.applied_modifiers ~= nil and mcl_fovapi.applied_modifiers[player] ~= nil and mcl_fovapi.applied_modifiers[player][modifier_name] ~= nil then
if mcl_fovapi.applied_modifiers[player][modifier_name] and mcl_fovapi.applied_modifiers[player][modifier_name] == true then if mcl_fovapi.applied_modifiers[player][modifier_name] and mcl_fovapi.applied_modifiers[player][modifier_name] == true then
return return
end end
end
local modifier = mcl_fovapi.registered_modifiers[modifier_name] local modifier = mcl_fovapi.registered_modifiers[modifier_name]
if modifier.on_start ~= nil then if modifier.on_start ~= nil then
@ -113,7 +115,9 @@ function mcl_fovapi.remove_modifier(player, modifier_name)
return return
end end
if mcl_fovapi.applied_modifiers[player][modifier_name] == nil then return end if mcl_fovapi.applied_modifiers[player][modifier_name] == nil then
return
end
if DEBUG then if DEBUG then
local name = player:get_player_name() local name = player:get_player_name()