vgui是一个零值Gmod [英] vgui is a nil value Gmod

查看:76
本文介绍了vgui是一个零值Gmod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试为gmod做一个mod,其中包括derma面板.但是当我尝试使用这种皮肤时,会出现错误.

I've been trying to do a mod for gmod, that includes derma panel. But when I try to use that derma, error appears.

AddCSLuaFile( "shared.lua" )
include("shared.lua")

function SWEP:PrimaryAttack()   
    return false
end

function SWEP:SecondaryAttack()
    DermaPanel()
end


function SWEP:Reload()
    return false
end

SelectedPower = "Stasis"

function DermaPanel()
    local Frame = vgui.Create( "DFrame" )
    Frame:SetPos(650,500)
    Frame:SetSize( 585, 150 )
    Frame:SetTitle( "Biotic Powers" )
    Frame:SetVisible( true )
    Frame:SetDraggable( false )
    Frame:ShowCloseButton( true )
    Frame:MakePopup()

    local bpush = vgui.Create( "DButton", Frame )
    bpush:SetText( "Push" )
    bpush:SetSize(100,30)
    bpush:SetPos(25,100)

    local bpull = vgui.Create( "DButton", Frame )
    bpull:SetText( "Pull" )
    bpull:SetSize(100,30)
    bpull:SetPos(135,100)

    local bstasis = vgui.Create( "DButton", Frame )
    bstasis:SetText( "Stasis" )
    bstasis:SetSize(100,30)
    bstasis:SetPos(245,100)

    local blift = vgui.Create( "DButton", Frame )
    blift:SetText( "Lift" )
    blift:SetSize(100,30)
    blift:SetPos(355,100)

    local bbarrier = vgui.Create( "DButton", Frame )
    bbarrier:SetText( "Barrier" )
    bbarrier:SetSize(100,30)
    bbarrier:SetPos(465,100)
end

当我尝试用二次火打开皮肤面板时,出现此错误:

When I try to open up derma panel with secondary fire, this error appears:

"[ERROR] addons/mass effect biotics/lua/weapons/weapon_biotics.lua:59: attempt to index global 'vgui' (a nil value)"

推荐答案

由于您是在共享环境中调用它,因此它同时在服务器和客户端上运行.如果错误为蓝色,则是因为服务器上不存在vgui表,并且服务器实例中有错误,但在客户端运行正常.

Since you're calling it in shared it is being run on both server and client. If the error is blue it is because the vgui table doesn't exist on the server and is erroring in the server instance but it is running perfectly ok in client-side.

您可以将其放在if CLIENT语句中,一切都会好的.

You can put it in an if CLIENT statement and everything will be ok.

这篇关于vgui是一个零值Gmod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆