View previous topic :: View next topic |
Author |
Message |
Quarter187 Newbie cheater Reputation: 0
Joined: 13 Aug 2022 Posts: 13
|
Posted: Thu Aug 18, 2022 2:11 pm Post subject: Getting value from txt (mimicking coordinates) |
|
|
How would I writeInteger() to an address from the value stored inside of a .txt? I have a script that will constantly write the value to the txt and when I do a standard io.open read I can see the value being updated. I simply want to apply this value to a different address. I want to do it through a text file instead of shared memory because I want to be able to share the values across separate machines, through a shared network folder, over LAN. At least that's the idea. My end goal is to create a simple 2player mode where an npc will be forced to the players coordinates on the other end.
Here is how I update the value to a txt:
Code: | {$lua}
if syntaxcheck then return end
[ENABLE]
function writefile(path, content)
local file = io.open(path,"w+b")
if file then
file:write(content)
file:close()
return true
else
return false
end
end
Timer=createTimer(MainForm)
Timer.Interval=100
Timer.OnTimer= function(timer)
writefile('shared.txt',readInteger ("21CEAD45E80")..'\n')
end
[DISABLE]
Timer.Enabled=false
Timer.destroy() |
Now I just need to flip this around and get the values from the text file and update the new address. I have tried quite a few different ideas to no avail.
|
|
Back to top |
|
|
cooleko Grandmaster Cheater Reputation: 11
Joined: 04 May 2016 Posts: 717
|
Posted: Thu Aug 18, 2022 6:53 pm Post subject: |
|
|
Don't know the answer but be mindful that if you attempt to read the file as the other script writes the file or vice-versa there may be an access conflict with unpredictable results so you will have to manage file access.
|
|
Back to top |
|
|
Quarter187 Newbie cheater Reputation: 0
Joined: 13 Aug 2022 Posts: 13
|
Posted: Thu Aug 18, 2022 8:27 pm Post subject: |
|
|
cooleko wrote: | Don't know the answer but be mindful that if you attempt to read the file as the other script writes the file or vice-versa there may be an access conflict with unpredictable results so you will have to manage file access. |
If I can just get the data and apply it to the address from the text alone I would be happy. Maybe something like this? It doesn't work. I haven't figured out how to apply it yet but I feel I am close.
Code: | local open = io.open
local function read_file(path)
local file = open(path, "r+")
if not file then return nil end
local content = file:read "*a"
file:close()
return content
end
print(read_file("shared.txt"))
local vga_files = {}
for line in io.lines("shared.txt") do
writeInteger("2A3712935A0")
end |
I know with trainers you can get properties from text and assign the text to an address as its value.
Example:
Code: | Function CEButton1Click(sender)
writeInteger("Test.exe+1A234", getProperty(CETrainer_CEdit1,"Text"))
end
form_show(CETrainer)
strings_add(getAutoAttachList(), "Test.exe") |
So maybe I can do the same thing but from a text file instead of a trainer. Or maybe I can make a script that will write the value to the trainer and I can just use this one to apply it to the other address.
|
|
Back to top |
|
|
|