如何在 Garry's mod lua 服务器中将图像放置在玩家屏幕上

我想为我的 Garry's Mod 服务器创建自己的 F4 菜单,并且我想从 PhotoShop 设置菜单背景的图像,但是在视频课程中没有关于此的说明,只展示了如何更改矩形的颜色。希望你能帮助我

local image = vgui.Create('DImage', frame)
image:SetSize(800, 600)
image:SetPos(100, 100)
image:SetImage('menu/image.gif')

local function DisplayNotify(msg)
    local txt = msg:ReadString()
    GAMEMODE:AddNotify(txt, msg:ReadShort(), msg:ReadLong())
    surface.PlaySound("buttons/lightswitch2.wav")

    MsgC(Color(255, 20, 20, 255), "[DarkRP] ", Color(200, 200, 200, 255), txt, "\n")
end
usermessage.Hook("_Notify", DisplayNotify)

菜单文件夹在 lua/autorun 文件夹中,但是图像看起来像是错误的贴图(粉色和黑色方块)。我认为这是因为服务器找不到此图像,尽管如果我粘贴已经存在于 Garry's Mod 中的其他图像,它就能工作但是会打印出错误。 例如:

local image = vgui.Create('DImage', frame)
image:SetSize(800, 600)
image:SetPos(100, 100)
image:SetImage('icon16/bug.png')

local function DisplayNotify(msg)
    local txt = msg:ReadString()
    GAMEMODE:AddNotify(txt, msg:ReadShort(), msg:ReadLong())
    surface.PlaySound("buttons/lightswitch2.wav")

    MsgC(Color(255, 20, 20, 255), "[DarkRP] ", Color(200, 200, 200, 255), txt, "\n")
end
usermessage.Hook("_Notify", DisplayNotify)

错误信息: [ERROR] lua/autorun/noname.lua:1: attempt to index global 'vgui' (a nil value) 1. unknown - lua/autorun/noname.lua:1

点赞