| View previous topic :: View next topic |
| Author |
Message |
TitusHM How do I cheat?
Reputation: 0
Joined: 27 Jul 2021 Posts: 5
|
Posted: Wed Aug 18, 2021 4:43 pm Post subject: lua help with error |
|
|
Hi, I have this code that multiplies your velocity every second but it uses pointers, so when the pointers are ?? it gives me this lua error "attempt to compare nil with number" is there any way to fix this
Note: the velocities are negative or positive because of how the game does velocities. So -1 would be subtracting a coordinate and +1 could be adding the coordinate.
| Code: |
{$lua}
local al = getAddressList()
local lpvx1 = al.getMemoryRecordByDescription("LPVelX1")
local lpvz1 = al.getMemoryRecordByDescription("LPVelZ1")
local mp = 1.5
[ENABLE]
function enable(timer)
if lpvx1.Value ~= nil then
if tonumber(lpvx1.Value) < -1 then
lpvx1.Value = -1.663
elseif tonumber(lpvx1.Value) > 1 then
lpvx1.Value = 1.663
end
end
if lpvz1.Value ~= nil then
if tonumber(lpvz1.Value) < -1 then
lpvz1.Value = -1.663
elseif tonumber(lpvz1.Value) > 1 then
lpvz1.Value = 1.663
end
end
lpvx1.Value = lpvx1.Value * mp
lpvz1.Value = lpvz1.Value * mp
end
t=createTimer(0)
timer_setInterval(t, 1000)
timer_onTimer(t, enable)
timer_setEnabled(t, true)
[DISABLE]
timer_onTimer(t, disable) |
|
|
| Back to top |
|
 |
Frouk Grandmaster Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 510
|
Posted: Thu Aug 19, 2021 1:02 am Post subject: |
|
|
| Code: | PlayerPTR = '[[[game.exe] + 0x4C] + 0x16] + 0x0' --Example of pointer
if PlayerPTR ~= nil then
--Paste your code here
end
|
or
| Code: |
PlayerPTR = '[[[game.exe] + 0x4C] + 0x16] + 0x0' --Example of pointer
if readPointer(PlayerPTR) ~= nil then
--Paste your code here
end
|
|
|
| Back to top |
|
 |
TheyCallMeTim13 Wiki Contributor
Reputation: 51
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Thu Aug 19, 2021 4:00 pm Post subject: |
|
|
Because you're reading the value multiple times, it's likely changing after you check for nil. So I'd read the value to a variable and check that.
| Frouk wrote: | | Code: | PlayerPTR = '[[[game.exe] + 0x4C] + 0x16] + 0x0' --Example of pointer
if PlayerPTR ~= nil then
--Paste your code here
end
|
... |
In this example you're setting the variable to a string then checking for nil, so this will always equate to TRUE. You should use "getAddressSafe" to check if the address is good.
_________________
|
|
| Back to top |
|
 |
Frouk Grandmaster Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 510
|
Posted: Fri Aug 20, 2021 10:10 am Post subject: |
|
|
| TheyCallMeTim13 wrote: |
Because you're reading the value multiple times, it's likely changing after you check for nil. So I'd read the value to a variable and check that.
| Frouk wrote: | | Code: | PlayerPTR = '[[[game.exe] + 0x4C] + 0x16] + 0x0' --Example of pointer
if PlayerPTR ~= nil then
--Paste your code here
end
|
... |
In this example you're setting the variable to a string then checking for nil, so this will always equate to TRUE. You should use "getAddressSafe" to check if the address is good. |
well, i was using my code in many cases
|
|
| Back to top |
|
 |
|