【发布时间】:2016-10-09 17:42:18
【问题描述】:
local function CreateCvar(cvar, value)
CreateClientConVar(cvar, value)
end
--cvars
CreateCvar("bunnyhop_test", 0)
CreateCvar("bunnyhop_test_off", 0)
if CLIENT then
function ReallyHiughJumpoBHOP()
--concommand.Add("+bhop",function()
if GetConVarNumber("bunnyhop_test") then
hook.Add("Think","hook",function()
RunConsoleCommand(((LocalPlayer():IsOnGround() or LocalPlayer():WaterLevel() > 0) and "+" or "-").."jump")
end
end)
function ReallyHiughJumpoBHOPoff()
--concommand.Add("-bhop",function()
if GetConVarNumber("bunnyhop_test_off") then
RunConsoleCommand("-jump")
hook.Remove("Think","hook")
end)
这是为游戏“Garry's mod”制作的 lua 脚本。这应该重复跳跃。我已经编辑了有效的基本代码,现在我的代码不再有效。
尝试使用 createcvars 使其工作。我确实让它没有显示任何错误,但在游戏中当我在控制台中输入“bunnyhop_test 1”时它不起作用。
以下是我开始使用的原始代码:
if CLIENT then
concommand.Add("+bhop",function()
hook.Add("Think","hook",function()
RunConsoleCommand(((LocalPlayer():IsOnGround() or LocalPlayer():WaterLevel() > 0) and "+" or "-").."jump")
end)
end)
concommand.Add("-bhop",function()
RunConsoleCommand("-jump")
hook.Remove("Think","hook")
end)
end
【问题讨论】:
-
是的,我有点杀了它^.^
-
好的,我可以看到您想使用自己的控制台变量更改脚本。我更新了代码,以便您可以编写
bunnyhop_test 1来启用和bunnyhop_test 0来禁用脚本。当然,您需要使用+bhop启动它。
标签: lua garrys-mod