I don't know why this won't toggle, I've been stumped for a few hours now trying to fix it.
Code:
HackName["SpeedHack"] = CreateClientConVar("HackName_SpeedHack", 0, true, false)
TS = GetConVar("host_timescale")
CH = GetConVar("sv_cheats")
local function speedon()
CH:SetValue(1.0)
TS:SetValue(5.0)
end
function speedoff()
TS:SetValue(1.0)
end
if HackName["SpeedHack"] == 0 then
speedoff()
else
speedon()
end
I honestly have no idea why this won't work properly. I can get it to work by doing:
Code:
CH = GetConVar("sv_cheats")
TS = GetConVar("host_timescale")
function speedon()
CH:SetValue(1)
TS:SetValue(5)
end
function speedoff()
TS:SetValue(1)
end
concommand.Add("+HackName_SpeedHack", speedon)
concommand.Add("-HackName_SpeedHack", speedoff)
But doing it this way causes quite a bit of hassle whilst trying to implement it into a menu. Any help at all would be appreciated.
Originally Posted by Moosicorn
I don't know why this won't toggle, I've been stumped for a few hours now trying to fix it.
Code:
HackName["SpeedHack"] = CreateClientConVar("HackName_SpeedHack", 0, true, false)
TS = GetConVar("host_timescale")
CH = GetConVar("sv_cheats")
local function speedon()
CH:SetValue(1.0)
TS:SetValue(5.0)
end
function speedoff()
TS:SetValue(1.0)
end
if HackName["SpeedHack"] == 0 then
speedoff()
else
speedon()
end
I honestly have no idea why this won't work properly. I can get it to work by doing:
Code:
CH = GetConVar("sv_cheats")
TS = GetConVar("host_timescale")
function speedon()
CH:SetValue(1)
TS:SetValue(5)
end
function speedoff()
TS:SetValue(1)
end
concommand.Add("+HackName_SpeedHack", speedon)
concommand.Add("-HackName_SpeedHack", speedoff)
But doing it this way causes quite a bit of hassle whilst trying to implement it into a menu. Any help at all would be appreciated.
of course if you put it in global space it will only run once.
run your if statement in a hook (or in a timer, but it's a bad idea.)
Originally Posted by Kyouko
of course if you put it in global space it will only run once.
run your if statement in a hook (or in a timer, but it's a bad idea.)
he couldn't hear you over my royalhack dude
Originally Posted by Kyouko
of course if you put it in global space it will only run once.
run your if statement in a hook (or in a timer, but it's a bad idea.)
Tried and failed.
Code:
CH = ("sv_cheats")
FB = ("mat_fullbright")
HackName["FullBright"] = CreateClientConVar("HackName_FullBright", 0, true, false)
function brighton()
CH:SetValue(1)
FB:SetValue(1)
end
function brightoff()
FB:SetValue(0)
CH:SetValue(0)
end
local function CheckFullBright()
if HackName["FullBright"] == 0 then
brightoff()
else
brighton()
end
end
hook.Add( "Think", "FullBrightCheck", CheckFullBright )
Yes I know this is a fullbright thingy and not a speedhack thingy but they use the same principle, the point is it doesnt work.
Originally Posted by Moosicorn
Tried and failed.
Code:
CH = ("sv_cheats")
FB = ("mat_fullbright")
HackName["FullBright"] = CreateClientConVar("HackName_FullBright", 0, true, false)
function brighton()
CH:SetValue(1)
FB:SetValue(1)
end
function brightoff()
FB:SetValue(0)
CH:SetValue(0)
end
local function CheckFullBright()
if HackName["FullBright"] == 0 then
brightoff()
else
brighton()
end
hook.Add( "Think", "FullBrightCheck", CheckFullBright )
Yes I know this is a fullbright thingy and not a speedhack thingy but they use the same principle, the point is it doesnt work.
1. You would need a module that can force cvars (cvar3 is one)
2. If statements need an end
3. GetConVar("sv_cheats"):SetValue( numberhere ) to force cvars using cvar3
Originally Posted by Friendly101
1. You would need a module that can force cvars (cvar3 is one)
2. If statements need an end
3. GetConVar("sv_cheats"):SetValue( numberhere ) to force cvars using cvar3
1. I already have/use the cvar 3 module.
2. The if statement did have an end I just forgot to put that in my [CODE].
3. I already am doing that, just in a more organised way.
Originally Posted by Moosicorn
1. I already have/use the cvar 3 module.
2. The if statement did have an end I just forgot to put that in my [CODE].
3. I already am doing that, just in a more organised way.
also use GetConVarNumber("HackName_FullBright") or HackName["FullBright"]:GetInt()
Originally Posted by Friendly101
also use GetConVarNumber("HackName_FullBright") or HackName["FullBright"]:GetInt()
Thanks. Got everything working now.
Code:
CH = ("sv_cheats")
FB = ("mat_fullbright")
HackName["FullBright"] = CreateClientConVar("HackName_FullBright", 0, true, false)
function brighton()
CH:SetValue(1)
FB:SetValue(1)
end
function brightoff()
FB:SetValue(0)
CH:SetValue(0)
end
local function CheckFullBright()
if HackName["FullBright"]:GetInt == 0 then
brightoff()
else
brighton()
end
end
hook.Add( "Think", "FullBrightCheck", CheckFullBright )
Originally Posted by Moosicorn
Thanks. Got everything working now.
Code:
CH = ("sv_cheats")
FB = ("mat_fullbright")
HackName["FullBright"] = CreateClientConVar("HackName_FullBright", 0, true, false)
function brighton()
CH:SetValue(1)
FB:SetValue(1)
end
function brightoff()
FB:SetValue(0)
CH:SetValue(0)
end
local function CheckFullBright()
if HackName["FullBright"]:GetInt == 0 then
brightoff()
else
brighton()
end
end
hook.Add( "Think", "FullBrightCheck", CheckFullBright )
GetInt is a function, that code you posted won't work since you don't call it