为什么它说尝试索引 'pac' 全局变量(一个 nil 值)

我的朋友给我发了这个脚本,我得到的错误是

[ERROR] gamemodes/santosrp/gamemode/sh_pacmodels.lua:137:尝试索引全局变量 'pac'(一个 nil 值) 1.PlayerSwitchWeapon - gamemodes/santosrp/gamemode/sh_pacmodels.lua:137 2.UpdatePlayers - gamemodes/santosrp/gamemode/sh_pacmodels.lua:169 3. 未知 - gamemodes/santosrp/gamemode/cl_init.lua:105

sh_pacmodels 的 137 是这样的

function GM.PacModels:PlayerSwitchWeapon( pPlayer, entOldWep, entNewWep )
    if not pPlayer.AttachPACPart then
        pac.SetupENT( pPlayer ) --行 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_pacmodels 的 169 是这样的

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
        --跟踪活动武器
        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() ) --行 169
                v.m_entLastActiveWeapon = v:GetActiveWeapon()
            end
        end
点赞
用户3979429
用户3979429

pac未被定义。

是的,就是这么简单。

2016-02-17 22:42:43