 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Fovoc37 How do I cheat?
Reputation: 0
Joined: 30 Sep 2018 Posts: 9
|
Posted: Sun Sep 30, 2018 9:27 am Post subject: Why lua script not working? |
|
|
Hello everyone, I'm just learning to write on lua
I wrote a script, but when I press a key, nothing in the game changes
| Code: | {$lua}
[ENABLE]
function ChangeValue()
Main = readInteger("[gta_sa.exe+00D91078]+2FC")
Main2 = readInteger("[[[[gta_sa.exe+00DA8CC4]+C]+14]+F4]+4")
if isKeyPressed(VK_F1) then
getData()
if (Main == 0) or (Main2 ==0) then
writeInteger("[gta_sa.exe+00D91078]+2FC", 5)
writeInteger("[[[[gta_sa.exe+00DA8CC4]+C]+14]+F4]+4",5)
elseif (Main == 1) or (Main2 == 1) then
writeInteger("[gta_sa.exe+00D91078]+2FC", 4)
writeInteger("[[[[gta_sa.exe+00DA8CC4]+C]+14]+F4]+4", 4)
end
end
end
function getData()
Main = readInteger("[gta_sa.exe+00D91078]+2FC")
Main2 = readInteger("[[[[gta_sa.exe+00DA8CC4]+C]+14]+F4]+4")
end
[DISABLE] |
Can you help me, where did I make a mistake?
Last edited by Fovoc37 on Sun Sep 30, 2018 4:16 pm; edited 1 time in total |
|
| Back to top |
|
 |
FreeER Grandmaster Cheater Supreme
Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Sun Sep 30, 2018 9:39 am Post subject: |
|
|
changeValue isn't called, let alone often enough to detect you pressing a key at exactly the same time that you are actually pressing it.
CE has a hotkey object for this purpose | Code: | {$lua}
[ENABLE]
global_main_hk = createHotkey(function()
local mainAddr = "[gta_sa.exe+00D91078]+2FC"
local mainAddr2 = "[[[[gta_sa.exe+00DA8CC4]+C]+14]+F4]+4"
local Main = readInteger(mainAddr)
local Main2 = readInteger(mainAddr2)
print("Main/Main2 before: ", Main, "/", Main2)
if (Main == 1) or (Main2 == 1) then
writeInteger(mainAddr, 2)
writeInteger(mainAddr2, 2)
elseif (Main == 2) or (Main2 == 2) then
writeInteger(mainAddr, 1)
writeInteger(mainAddr2, 1)
end
print("Main/Main2 after: ", Main, "/", Main2)
end, VK_F1)
[DISABLE]
if global_main_hk then global_main_hk.destroy() end |
_________________
|
|
| Back to top |
|
 |
Fovoc37 How do I cheat?
Reputation: 0
Joined: 30 Sep 2018 Posts: 9
|
Posted: Sun Sep 30, 2018 10:04 am Post subject: |
|
|
| FreeER wrote: | changeValue isn't called, let alone often enough to detect you pressing a key at exactly the same time that you are actually pressing it.
CE has a hotkey object for this purpose | Code: | {$lua}
[ENABLE]
global_main_hk = createHotkey(function()
local mainAddr = "[gta_sa.exe+00D91078]+2FC"
local mainAddr2 = "[[[[gta_sa.exe+00DA8CC4]+C]+14]+F4]+4"
local Main = readInteger(mainAddr)
local Main2 = readInteger(mainAddr2)
print("Main/Main2 before: ", Main, "/", Main2)
if (Main == 1) or (Main2 == 1) then
writeInteger(mainAddr, 2)
writeInteger(mainAddr2, 2)
elseif (Main == 2) or (Main2 == 2) then
writeInteger(mainAddr, 1)
writeInteger(mainAddr2, 1)
end
print("Main/Main2 after: ", Main, "/", Main2)
end, VK_F1)
[DISABLE]
if global_main_hk then global_main_hk.destroy() end |
|
Thank you, you really helped me!
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|