Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to assign values to an address according to if statmen

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Thunder_Bird
Cheater
Reputation: 0

Joined: 27 Apr 2018
Posts: 33
Location: pakistan

PostPosted: Wed May 30, 2018 1:42 pm    Post subject: How to assign values to an address according to if statmen Reply with quote

Hello there,
I am facing a problem in LUA while scripting a mouse tool,
here is the code:
openProcess("gta-vc.exe")
if readBytes("0x7E49C0+0x408", 0) then
writeFloat("0068AE00", 1)
end
if readBytes("0x7E49C0+0x408", 1) then
writeFloat("0068AE00", 0.5)
end
if readBytes("0x7E49C0+0x408", 2) then
writeFloat("0068AE00", 4)
end

where, 0x7E49C0+0x408 is the address of active weapon block and 0068AE00 is the address of Mouse X-axis sens. The problem is that when I
execute it, it do not read for active weapon slot, I want the code to automatically read value from active -slot address and assign it to X-axis address whenever its value change. if it changed to 0 then the given value apply if changes to 3, given value apply and if again change to 0 the give value apply
if its not possible or you guys are not understanding the problem then sozzy.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu May 31, 2018 6:52 am    Post subject: Reply with quote

Code:
local t = createTimer() -- timers repeat code
t.Interval = 100 -- 100 millisecond delay
t.OnTimer = function(t) -- code to repeat
  -- names for otherwise magic numbers
  local wepAddr = "0x7E49C0+0x408"
  local xaxisAddr = "0068AE00"
 
  -- read from memory
  local weapon = readInteger(wepAddr) -- assuming a 4 byte value
 
  -- declare local value so it can be set (without being global)
  local value
 
  -- set local value based on read weapon value
  if weapon == 0 then
    value = 1
  elseif weapon == 1 then
    value = 0.5
  elseif weapon == 2 then
    value = 4
  end
 
  -- write determined value to memory
  writeFloat(xaxisAddr,value)
end

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites