View previous topic :: View next topic |
Author |
Message |
Aziixz Cheater Reputation: 0
Joined: 26 Oct 2021 Posts: 31 Location: Earth
|
Posted: Wed May 24, 2023 11:28 am Post subject: Differientiating Timers |
|
|
I have a timer script but trying to add more than one and changing
myAddress and the wav file so I can play multiple sounds on different
value disables the previous script from working in
my table. How can I differentiate them?
[ENABLE]
{$lua}
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=120 cycleTimer.Enabled=false
oldValue = nil
myAddress = "chumbucket" -- tried changing this
function checkValue()
local al = getAddressList()
if oldValue == nil then
for i=0,al.Count-1 do
if al[i].Description == myAddress then
oldValue = al[i].Value
end
end
else
for i=0,al.Count-1 do
if al[i].Description == myAddress then
if al[i].Value ~= oldValue then
playSound(findTableFile('killmarker.wav')) -- Tried changing this
oldValue = al[i].Value
end
end
end
end
end
cycleTimer.OnTimer = checkValue
if ExitKey then ExitKey.Destroy() ExitKey=nil end
ExitKey = createHotkey((function()
sleep(200)
if cycleTimer.Enabled==false then
cycleTimer.Enabled=true
else
cycleTimer.Enabled=false
end
end), VK_F8)
{$asm}
[DISABLE]
{$lua}
if ExitKey then ExitKey.Destroy() ExitKey=nil end
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1253
|
Posted: Wed May 24, 2023 1:06 pm Post subject: |
|
|
Probably "playSound" is broadcasting from a single cell and you can't add two streams to one channel.
Search the forum for the "playMP3" function to play multiple audios at once.
My advice is watch me and @Corroder's comments carefully.
Also, remove the "for" loop from the code.
Instead of;
"myAddr=al.MemoryRecordByDescrption("yourDescName")
myAddr.value"
Use a reading like
And find the used music durations as short as one second.
If there is still no solution, I can help with sample solution codes when I switch to PC over the weekend.
_________________
|
|
Back to top |
|
|
Aziixz Cheater Reputation: 0
Joined: 26 Oct 2021 Posts: 31 Location: Earth
|
Posted: Wed May 24, 2023 10:11 pm Post subject: |
|
|
Is it this one?
https://forum.cheatengine.org/viewtopic.php?t=607021
And no I'm not trying to play multiple audio cues at once I am trying to have multiple copies of this script to play different audio/music with many addresses, for example
Script 1 -
Mem Description - Chumbucket
Sound - Killmarker.wav
-- When I shoot chumbucket play sound
-- Address A8FFB7 holds information on how many hits chumbucket has received, When this value increases play sound Killmarker.wav
Script 2
Mem Description - Weapon
Sound - Gunshot.wav
-- Play sound when I shoot my gun
-- Address B8FDB7 holds information on how many times I shoot my gun. When this value increases play sound Gunshot.wav
Script 3
Mem Description - Shield
Sound - Hit.wav
-- Play sound on shield depletion (when my shield hits 0)
-- Address 6F21A9C hold information on my shield value. When my shield reached 0 play sound once.
Etc so I can modify as many sounds as I want without having it
so activating the second script disables the first one.
I'll look into the thread you mentioned but I'm not
knowledgeable in lua/scripting. Just wondering if there was a
simply way to have multiple instances of the script whilst only
changing the Description and sound.wav file? .
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Wed May 24, 2023 11:59 pm Post subject: |
|
|
This is just an illustration. Do whatever you want.
Code: | local myAddress = {"chumbucket", "jarhead", "funkface"}
myDesc = "funkface"
function checkValue()
for i=1, #myAddress do
if myAddress[i] == "chumbucket" and myAddress[i] == myDesc then
playSound(findTableFile("mywav1.wav"))
elseif myAddress[i] == "jarhead" and myAddress[i] == myDesc then
playSound(findTableFile("mywav2.wav"))
elseif myAddress[i] == "funkface" and myAddress[i] == myDesc then
playSound(findTableFile("mywav3.wav"))
end
end
end
checkValue() |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1253
|
Posted: Thu May 25, 2023 5:26 am Post subject: |
|
|
I still haven't tested the response of "playSound" during collision, as this is my example for the general pattern of the code.
I created the code in notepad on my phone, I haven't had a chance to try it for CE syntaxes.
Code: |
[ENABLE]
{$lua}
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=420 cycleTimer.Enabled=false
oldValue1 = "" --string "" or number 0 or 1
oldValue2 = ""
oldValue3 = ""
function checkValue()
local al = getAddressList()
myAddr1=al.MemoryRecordByDescrption("Chumbucket")
myAddr2=al.MemoryRecordByDescrption("Weapon")
myAddr3=al.MemoryRecordByDescrption("Shield")
if myAddr1.Value ~= oldValue1 then
playSound(findTableFile('yourSound1.wav')) -- Tried changing this
oldValue1 = myAddr1.Value
elseif myAddr2.Value ~= oldValue2 then
playSound(findTableFile('yourSound2.wav')) -- Tried changing this
oldValue2 = myAddr2.Value
elseif myAddr3.Value ~= oldValue3 then
playSound(findTableFile('yourSound3.wav')) -- Tried changing this
oldValue3 = myAddr3.Value
end
end
cycleTimer.OnTimer = checkValue
if ExitKey then ExitKey.Destroy() ExitKey=nil end
ExitKey = createHotkey((function()
sleep(200)
if cycleTimer.Enabled==false then
cycleTimer.Enabled=true
else
cycleTimer.Enabled=false
end
end), VK_F8)
{$asm}
[DISABLE]
{$lua}
if ExitKey then ExitKey.Destroy() ExitKey=nil end
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
|
_________________
|
|
Back to top |
|
|
Aziixz Cheater Reputation: 0
Joined: 26 Oct 2021 Posts: 31 Location: Earth
|
Posted: Thu May 25, 2023 6:05 am Post subject: |
|
|
Error in line 11?
Description: |
|
Filesize: |
78.95 KB |
Viewed: |
2245 Time(s) |
|
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Thu May 25, 2023 7:05 am Post subject: |
|
|
Aziixz wrote: | Error in line 11? |
From:
Code: |
myAddr1=al.MemoryRecordByDescrption("Chumbucket")
myAddr2=al.MemoryRecordByDescrption("Weapon")
myAddr3=al.MemoryRecordByDescrption("Shield")
|
To:
Code: |
myAddr1 = al.getMemoryRecordByDescrption("Chumbucket")
myAddr2 = al.getMemoryRecordByDescrption("Weapon")
myAddr3 = al.getMemoryRecordByDescrption("Shield")
|
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1253
|
Posted: Thu May 25, 2023 10:08 am Post subject: |
|
|
Oh yes, I haven't tried.
"get" and "Descrption" = "Description"
Code: | myAddr1=al.getMemoryRecordByDescription("Chumbucket")
myAddr2=al.getMemoryRecordByDescription("Weapon")
myAddr3=al.getMemoryRecordByDescription("Shield") |
_________________
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Thu May 25, 2023 10:12 am Post subject: |
|
|
Yes, I did not spot the 2nd error also haha . Nevermind, it's the heat ^^
|
|
Back to top |
|
|
Aziixz Cheater Reputation: 0
Joined: 26 Oct 2021 Posts: 31 Location: Earth
|
Posted: Thu May 25, 2023 11:55 pm Post subject: |
|
|
Thanks guys, how would I add say a float number as oldValue since my shield is a float
value, tried this but no luck
oldValue1 = tonumber (float)74
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Fri May 26, 2023 1:29 am Post subject: |
|
|
I don't believe there is a need to specify since you're basing it on the value of the memory record.
If you want to write a specific type to an address you can use these functions:
Code: |
writeShortInteger(address,value) / writeByte(address,value) : Writes a 8-bit integer to the specified address. Returns true on success
writeSmallInteger(address,value) : Writes a 16-bit integer to the specified address. Returns true on success
writeInteger(address,value) : Writes a 32-bit integer to the specified address. Returns true on success
writeQword(address, value): Write a 64-bit integer to the specified address. Returns true on success
writePointer(address,value)
writeFloat(address,value) : Writes a single precision floating point to the specified address. Returns true on success
writeDouble(address,value) : Writes a double precision floating point to the specified address. Returns true on success
writeString(address,text, widechar OPTIONAL) : Write a string to the specified address. Returns true on success
|
It's worthwhile checking celua.txt documentation for more information.
|
|
Back to top |
|
|
Aziixz Cheater Reputation: 0
Joined: 26 Oct 2021 Posts: 31 Location: Earth
|
Posted: Fri May 26, 2023 1:56 am Post subject: |
|
|
So if I wanted to read the value at 175292D8 which I indicated as 1 and
then wanted it so that only if the value is below (float)1 it would play the
sound would I do something like this?
[ENABLE]
{$lua}
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=50 cycleTimer.Enabled=false
oldValue1 = readFloat("175292D8","1") -- Read (float) 1 from the address
oldValue2 = nil
oldValue3 = nil
function checkValue()
local al = getAddressList()
myAddr1 = al.getMemoryRecordByDescription("xGun")
myAddr2 = al.getMemoryRecordByDescription("xBulletsFired")
myAddr3 = al.getMemoryRecordByDescription("xFoV")
if myAddr1.Value < oldValue1 then -- If the value from xGun is below the value of (float) 1 then play sound sliding.wav?
playSound(findTableFile('sliding.wav'))
oldValue1 = myAddr1.Value
elseif myAddr2.Value ~= oldValue2 then
playSound(findTableFile('killmarker.wav')) -- Tried changing this
oldValue2 = myAddr2.Value
elseif myAddr3.Value ~= oldValue3 then
playSound(findTableFile('AK47.wav')) -- Tried changing this
oldValue3 = myAddr3.Value
end
end
cycleTimer.OnTimer = checkValue
if ExitKey then ExitKey.Destroy() ExitKey=nil end
ExitKey = createHotkey((function()
sleep(200)
if cycleTimer.Enabled==false then
cycleTimer.Enabled=true
else
cycleTimer.Enabled=false
end
end), VK_F8)
{$asm}
[DISABLE]
{$lua}
if ExitKey then ExitKey.Destroy() ExitKey=nil end
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Fri May 26, 2023 2:15 am Post subject: |
|
|
Please use code tags when posting code. It makes it easier for people to read, even more so when indentation is severely lacking.
Code: |
[ENABLE]
{$lua}
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=50 cycleTimer.Enabled=false
-- readFloat only takes one parameter, the address.
oldValue1 = readFloat(0x175292D8) -- Read (float) 1 from the address
oldValue2 = nil
oldValue3 = nil
-- It's better to have a single reference used throughout the script rather than obtain a reference every time you execute the function
local al = getAddressList()
function checkValue()
myAddr1 = al.getMemoryRecordByDescription("xGun")
myAddr2 = al.getMemoryRecordByDescription("xBulletsFired")
myAddr3 = al.getMemoryRecordByDescription("xFoV")
if myAddr1.Value < oldValue1 then -- If the value is below from xGun is below the value of (float) 1 then play sound sliding.wav?
playSound(findTableFile('sliding.wav'))
oldValue1 = myAddr1.Value
elseif myAddr2.Value ~= oldValue2 then
playSound(findTableFile('killmarker.wav')) -- Tried changing this
oldValue2 = myAddr2.Value
elseif myAddr3.Value ~= oldValue3 then
playSound(findTableFile('AK47.wav')) -- Tried changing this
oldValue3 = myAddr3.Value
end
end
cycleTimer.OnTimer = checkValue
if ExitKey then ExitKey.Destroy() ExitKey=nil end
ExitKey = createHotkey((function()
sleep(200)
if cycleTimer.Enabled==false then
cycleTimer.Enabled=true
else
cycleTimer.Enabled=false
end
end), VK_F8)
{$asm}
[DISABLE]
{$lua}
if ExitKey then ExitKey.Destroy() ExitKey=nil end
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
|
Does the value of xGun ever go beyond the value 1? If so, it wouuld be better to compare against an arbitrary value. Also, addresses have to be hexadecimal notation (0x[address])
|
|
Back to top |
|
|
Aziixz Cheater Reputation: 0
Joined: 26 Oct 2021 Posts: 31 Location: Earth
|
Posted: Fri May 26, 2023 3:27 am Post subject: |
|
|
okay so this works but it keeps repeating the sound and not playing the
file fully probably due to the timer interval. Is there a way to allow the file
to only be played once when it hits 0 and not play again until it hits 0
again without messing with timer interval?
code:
Code: |
[ENABLE]
{$lua}
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=50 cycleTimer.Enabled=false
oldValue2 = writeFloatLocal(0x17AB92D8,"1")
oldValue3 = writeFloatLocal(0x17AB92D8,"1")
function checkValue()
local al = getAddressList()
myAddr2 = al.getMemoryRecordByDescription("xBulletsFired")
myAddr3 = al.getMemoryRecordByDescription("xFoV")
if readFloat (0x17AB92D8) == tonumber (0) then -- Changed this
playSound(findTableFile('sliding.wav'))
oldValue1 = myAddr1.Value
elseif myAddr2.Value ~= oldValue2 then
playSound(findTableFile('killmarker.wav'))
oldValue2 = myAddr2.Value
elseif myAddr3.Value ~= oldValue3 then
playSound(findTableFile('AK47.wav'))
oldValue3 = myAddr3.Value
end
end
cycleTimer.OnTimer = checkValue
if ExitKey then ExitKey.Destroy() ExitKey=nil end
ExitKey = createHotkey((function()
sleep(200)
if cycleTimer.Enabled==false then
cycleTimer.Enabled=true
else
cycleTimer.Enabled=false
end
end), VK_F8)
{$asm}
[DISABLE]
{$lua}
if ExitKey then ExitKey.Destroy() ExitKey=nil end
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
|
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1253
|
Posted: Fri May 26, 2023 4:56 am Post subject: |
|
|
LeFiXER wrote: | Yes, I did not spot the 2nd error also haha . Nevermind, it's the heat ^^ |
No problem. Also, thanks for the fix and taking over the watch in case of need, mate.
Just in addition to the available options;
[ Code: | ENABLE]
{$lua}
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=50 cycleTimer.Enabled=false
local al = getAddressList()
myAddr1 = al.getMemoryRecordByDescription("xGun")
myAddr2 = al.getMemoryRecordByDescription("xBulletsFired")
myAddr3 = al.getMemoryRecordByDescription("xFoV")
--oldValue1 = 1 --readFloat(myAddr1.Address) -- Read (float) 1 from the address
-- save first value ( integer? float?)
oldValue2 = readInteger(myAddr2.Address)
oldValue3 = readFloat(myAddr3.Address)
function checkValue()
myAddr1 = al.getMemoryRecordByDescription("xGun")
myAddr2 = al.getMemoryRecordByDescription("xBulletsFired")
myAddr3 = al.getMemoryRecordByDescription("xFoV")
if readFloat(myAddr1.Address) < 1 then -- If the value is below from xGun is below the value of (float) 1 then play sound sliding.wav?
playSound(findTableFile('sliding.wav'))
--oldValue1 = myAddr1.Value --> oldValue1=1
--writeFloat(myAddr1.Address,1) --> replace value 1
elseif readInteger(myAddr2.Address) ~= oldValue2 then
playSound(findTableFile('killmarker.wav')) -- Tried changing this
oldValue2 = readInteger(myAddr2.Address)
elseif readFloat(myAddr3.Address) ~= oldValue3 then
playSound(findTableFile('AK47.wav')) -- Tried changing this
oldValue3 = readFloat(myAddr3.Address)
end
end
cycleTimer.OnTimer = checkValue
if ExitKey then ExitKey.Destroy() ExitKey=nil end
ExitKey = createHotkey((function()
sleep(200)
if cycleTimer.Enabled==false then
cycleTimer.Enabled=true
else
cycleTimer.Enabled=false
end
end), VK_F8)
{$asm}
[DISABLE]
{$lua}
if ExitKey then ExitKey.Destroy() ExitKey=nil end
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end |
Now edit these options according to your script and use whatever you want from them.
_________________
|
|
Back to top |
|
|
|