为什么说 attempt to index 'pac' global (a nil value)
Why does it say attempt to index 'pac' global (a nil value)
我的朋友发给我这个脚本,我得到的错误是
[ERROR] gamemodes/santosrp/gamemode/sh_pacmodels.lua:137: 尝试索引全局 'pac'(零值)
1. PlayerSwitchWeapon - gamemodes/santosrp/gamemode/sh_pacmodels.lua:137
2. 更新播放器 - gamemodes/santosrp/gamemode/sh_pacmodels.lua:169
3. 未知 - gamemodes/santosrp/gamemode/cl_init.lua:105
sh_pacmodels137是这个
function GM.PacModels:PlayerSwitchWeapon( pPlayer, entOldWep, entNewWep )
if not pPlayer.AttachPACPart then
pac.SetupENT( pPlayer ) --line 137
pPlayer:SetPACDrawDistance( GetConVarNumber("srp_pac_drawrange") )
end
local invalid
for slotName, _ in pairs( GAMEMODE.Inv.m_tblEquipmentSlots ) do
item = GAMEMODE.Inv:GetItem( GAMEMODE.Player:GetSharedGameVar(pPlayer, "eq_slot_".. slotName, "") )
if not item or not item.PacOutfit then continue end
if not IsValid( entOldWep ) or not IsValid( entNewWep ) then continue end
if item.EquipGiveClass == entOldWep:GetClass() or item.EquipGiveClass == entNewWep:GetClass() then
invalid = true
break
end
end
sh_pacmodels169是这个
function GM.PacModels:UpdatePlayers()
if not self.m_intLastThink then self.m_intLastThink = CurTime() +0.1 end
if self.m_intLastThink > CurTime() then return end
self.m_intLastThink = CurTime() +0.1
local ragdoll, item
for k, v in pairs( player.GetAll() ) do
--Track active weapon
if not v.m_entLastActiveWeapon then
v.m_entLastActiveWeapon = v:GetActiveWeapon()
else
if v:GetActiveWeapon() ~= v.m_entLastActiveWeapon then
self:PlayerSwitchWeapon( v, v.m_entLastActiveWeapon, v:GetActiveWeapon() ) -- line 169
v.m_entLastActiveWeapon = v:GetActiveWeapon()
end
end
pac
未定义。
是的,就这么简单。
我的朋友发给我这个脚本,我得到的错误是
[ERROR] gamemodes/santosrp/gamemode/sh_pacmodels.lua:137: 尝试索引全局 'pac'(零值) 1. PlayerSwitchWeapon - gamemodes/santosrp/gamemode/sh_pacmodels.lua:137 2. 更新播放器 - gamemodes/santosrp/gamemode/sh_pacmodels.lua:169 3. 未知 - gamemodes/santosrp/gamemode/cl_init.lua:105
sh_pacmodels137是这个
function GM.PacModels:PlayerSwitchWeapon( pPlayer, entOldWep, entNewWep )
if not pPlayer.AttachPACPart then
pac.SetupENT( pPlayer ) --line 137
pPlayer:SetPACDrawDistance( GetConVarNumber("srp_pac_drawrange") )
end
local invalid
for slotName, _ in pairs( GAMEMODE.Inv.m_tblEquipmentSlots ) do
item = GAMEMODE.Inv:GetItem( GAMEMODE.Player:GetSharedGameVar(pPlayer, "eq_slot_".. slotName, "") )
if not item or not item.PacOutfit then continue end
if not IsValid( entOldWep ) or not IsValid( entNewWep ) then continue end
if item.EquipGiveClass == entOldWep:GetClass() or item.EquipGiveClass == entNewWep:GetClass() then
invalid = true
break
end
end
sh_pacmodels169是这个
function GM.PacModels:UpdatePlayers()
if not self.m_intLastThink then self.m_intLastThink = CurTime() +0.1 end
if self.m_intLastThink > CurTime() then return end
self.m_intLastThink = CurTime() +0.1
local ragdoll, item
for k, v in pairs( player.GetAll() ) do
--Track active weapon
if not v.m_entLastActiveWeapon then
v.m_entLastActiveWeapon = v:GetActiveWeapon()
else
if v:GetActiveWeapon() ~= v.m_entLastActiveWeapon then
self:PlayerSwitchWeapon( v, v.m_entLastActiveWeapon, v:GetActiveWeapon() ) -- line 169
v.m_entLastActiveWeapon = v:GetActiveWeapon()
end
end
pac
未定义。
是的,就这么简单。