View previous topic :: View next topic |
Author |
Message |
Greenhouse Cheater Reputation: 0
Joined: 20 Aug 2016 Posts: 44
|
Posted: Sat Jan 14, 2017 10:12 pm Post subject: Hold down key to change value |
|
|
I've been trying to make a lua script to change a value when you hold down a key, and return to original value when you stop.
But it doesn't work and I don't see what it's wrong. I'm kinda new to this.
Code: | function checkKeys(timer)
if (isKeyPressed(VK_Z)) then
local addr = "[[[HelloNeighborReborn-Win64-Shipping.exe+027A2310]+278]+D8]+0"
local function set(value)writeFloat(addr,value)end
local function test(value)return value==readFloat(addr)end
if test(-980) then
set(-100)
else
set(-980)
end
end
end
t=createTimer(nil)
timer_setInterval(t, 100)
timer_onTimer(t, checkKeys)
timer_setEnabled(t, true) |
Can anyone help me? Thanks.
Any easier way to do what I need it's helpful too.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Jan 14, 2017 10:33 pm Post subject: |
|
|
Code: | local addr = "[[[HelloNeighborReborn-Win64-Shipping.exe+027A2310]+278]+D8]+0"
local function set(value)writeFloat(addr,value)end
local function test(value)return value==readFloat(addr)end
if mytimer == nil then
mytimer = createTimer(nil, false)
end
mytimer.Interval = 100
mytimer.OnTimer = function(timer)
if not isKeyPressed(VK_Z) then
set(-980)
timer.Enabled = false
end
end
if myhotkey then
myhotkey.Destroy()
end
myhotkey = createHotkey(function()
if not mytimer.Enabled then
set(-100)
mytimer.Enabled = true
end
end, VK_Z) |
|
|
Back to top |
|
|
Greenhouse Cheater Reputation: 0
Joined: 20 Aug 2016 Posts: 44
|
Posted: Sun Jan 15, 2017 5:12 am Post subject: |
|
|
Zanzer wrote: | Code: | local addr = "[[[HelloNeighborReborn-Win64-Shipping.exe+027A2310]+278]+D8]+0"
local function set(value)writeFloat(addr,value)end
local function test(value)return value==readFloat(addr)end
if mytimer == nil then
mytimer = createTimer(nil, false)
end
mytimer.Interval = 100
mytimer.OnTimer = function(timer)
if not isKeyPressed(VK_Z) then
set(-980)
timer.Enabled = false
end
end
if myhotkey then
myhotkey.Destroy()
end
myhotkey = createHotkey(function()
if not mytimer.Enabled then
set(-100)
mytimer.Enabled = true
end
end, VK_Z) |
|
It doesn't work either. The value just doesn't change.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Jan 15, 2017 8:04 am Post subject: |
|
|
Should the address be Code: | [[HelloNeighborReborn-Win64-Shipping.exe+027A2310]+278]+D8 |
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Jan 15, 2017 8:22 am Post subject: |
|
|
You can use "toggle" version:
Code: | function theCheatTimerOnTimer(t)
local val = readFloat(addr)
if val and (val>=-981 and val<=-979) then -- change to -100 only when it is around -980
writeFloat(addr,-100)
end
end
function theCheatHotkeyOnHotkey(t)
if theCheatTimer.Enabled then
speakEnglish('disabled.')
theCheatTimer.Enabled = false
writeFloat(addr,-980)
else
speakEnglish('enabled.')
theCheatTimer.Enabled = true
end
end
if theCheatTimer==nil then theCheatTimer = createTimer(nil,false) end
theCheatTimer.Interval = 10
theCheatTimer.Enabled = false
theCheatTimer.OnTimer = theCheatTimerOnTimer
if theCheatHotkey~=nil then theCheatHotkey.destroy(); theCheatHotkey=nil end
theCheatHotkey = createHotkey(theCheatHotkeyOnHotkey,VK_Z)
addr = "[[[HelloNeighborReborn-Win64-Shipping.exe+027A2310]+278]+D8]+0"
|
_________________
|
|
Back to top |
|
|
Greenhouse Cheater Reputation: 0
Joined: 20 Aug 2016 Posts: 44
|
Posted: Sun Jan 15, 2017 8:38 am Post subject: |
|
|
mgr.inz.Player wrote: | You can use "toggle" version:
Code: | function theCheatTimerOnTimer(t)
local val = readFloat(addr)
if val and (val>=-981 and val<=-979) then -- change to -100 only when it is around -980
writeFloat(addr,-100)
end
end
function theCheatHotkeyOnHotkey(t)
if theCheatTimer.Enabled then
speakEnglish('disabled.')
theCheatTimer.Enabled = false
writeFloat(addr,-980)
else
speakEnglish('enabled.')
theCheatTimer.Enabled = true
end
end
if theCheatTimer==nil then theCheatTimer = createTimer(nil,false) end
theCheatTimer.Interval = 10
theCheatTimer.Enabled = false
theCheatTimer.OnTimer = theCheatTimerOnTimer
if theCheatHotkey~=nil then theCheatHotkey.destroy(); theCheatHotkey=nil end
theCheatHotkey = createHotkey(theCheatHotkeyOnHotkey,VK_Z)
addr = "[[[HelloNeighborReborn-Win64-Shipping.exe+027A2310]+278]+D8]+0"
|
|
It's not working either, the value just doesn't change.
The address is right, but doesn't change anything.
Image: i(dot)imgur(dot)com/UtQdojA.png
Zanzer wrote: | Should the address be Code: | [[HelloNeighborReborn-Win64-Shipping.exe+027A2310]+278]+D8 |
|
Still not working.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Jan 15, 2017 9:29 am Post subject: |
|
|
Address is not right, you have the offsets backwards. Code: | local addr = "[[[HelloNeighborReborn-Win64-Shipping.exe+027A2310]+0]+D8]+278" |
|
|
Back to top |
|
|
Greenhouse Cheater Reputation: 0
Joined: 20 Aug 2016 Posts: 44
|
Posted: Sun Jan 15, 2017 11:06 am Post subject: |
|
|
Zanzer wrote: | Address is not right, you have the offsets backwards. Code: | local addr = "[[[HelloNeighborReborn-Win64-Shipping.exe+027A2310]+0]+D8]+278" |
|
I thought that the offsets had to be in that order.
Well, that's why it wasn't working. Thanks.
|
|
Back to top |
|
|
|