【发布时间】:2017-12-26 23:12:23
【问题描述】:
因此,我目前正在尝试创建一个小脚本,用于当玩家在 GMOD 中输入“!内容”时,例如,他们将通过一个窗口呈现,该窗口将引导他们进入该服务器的 Steam 内容。对于前面的示例它有效,因此我尝试复制模板并更改函数名称等。我没有遇到与所示示例相同的结果,但似乎没有发生任何事情,我不知道为什么,因为我只有更改了函数名称和字符串。如果你能帮助我,那就太好了。提前致谢。
Steam 群聊脚本(作品)
function steamgroupCommand( ply, text)
if string.sub( text, 1, 6 ) == "!steam" then
ply:PrintMessage( 3, "It Worked!" )
ply:SendLua([[gui.OpenURL("http://steamcommunity.com/groups/PhantomNetworksCommunity")]])
for k, v in pairs(player.GetAll()) do v:ChatPrint( "Player " .. ply:Nick() .. " has used !steam to view our community Steam Group!" )
end
end
end
hook.Add( "PlayerSay", "Chat", steamgroupCommand )
Discord 聊天脚本(不起作用)
function discordCommand( ply, text)
if string.sub( text, 1, 8 ) == "!discord" then
ply:PrintMessage( 3, "It Worked!" )
ply:SendLua([[gui.OpenURL("https://discord.gg/35rQxcE")]])
for k, v in pairs(player.GetAll()) do v:ChatPrint( "Player " .. ply:Nick() .. " has used !discord to view our official Discord server!" )
end
end
end
hook.Add( "PlayerSay", "Chat", discordCommand )
【问题讨论】:
-
我忘了添加这个文件位于\garrysmod\lua\autorun
-
你有多个钩子吗?您似乎对两者都使用了相同的标识符;每个标识符只能有一个钩子函数:wiki.garrysmod.com/page/hook/Add
标签: lua garrys-mod