View previous topic :: View next topic |
Author |
Message |
alphanote How do I cheat?
Reputation: 0
Joined: 16 Sep 2014 Posts: 7
|
Posted: Mon Sep 22, 2014 12:40 pm Post subject: String Find And Replace FUNCTION |
|
|
I need a function that you can call, that finds and replaces string.
Ex;
FindAndReplaceString("text to find","text to replace with")
Please, I've been looking for hours and hours, days and days.
I need it so bad for my trainer!
|
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Mon Sep 22, 2014 2:14 pm Post subject: |
|
|
Code: | function replaceString(string_in,string_out,ignore_length)
if (not ignore_length) then
if (not(string_in and string_out and #string_in >= #string_out)) then
return print("Not recommended to override shorter string with a longer string");
end
end
local bytes_in = {};
local bytes_out = {};
for i=1,(#string_in >= #string_out and #string_in or #string_out) do -- lazy to copy paste same loop for string_out so just looping both and inserting if possible
if (i <= #string_in) then
table.insert(bytes_in,string.format("%x", tonumber(string.byte(string.sub(string_in,i,i)))));
end
if (i <= #string_out) then
-- table.insert(bytes_out,'0x' .. string.format("%x", tonumber(string.byte(string.sub(string_out,i,i)))));
table.insert(bytes_out,tonumber(string.byte(string.sub(string_out,i,i))));
end
end
local object = AOBScan(table.concat(bytes_in," "));
if object then
for entry = 0, object.Count -1 do
writeBytes(object.getString(entry), unpack(bytes_out));
end
object.destroy();
return true
end
return false
end
-- replaceString(String to find(string), string to replace with(string), ignore replace string length(true/false))
-- returns true/false as result
replaceString("Hi","Hey",true); |
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
alphanote How do I cheat?
Reputation: 0
Joined: 16 Sep 2014 Posts: 7
|
Posted: Mon Sep 22, 2014 2:28 pm Post subject: OMG |
|
|
TY!!
|
|
Back to top |
|
 |
alphanote2 How do I cheat?
Reputation: 0
Joined: 23 Sep 2014 Posts: 6
|
Posted: Wed Sep 24, 2014 7:22 am Post subject: qq |
|
|
Does not work.
It just crashes my game.
I want a large string to change to a smaller string.
|
|
Back to top |
|
 |
sodahead0 How do I cheat?
Reputation: 0
Joined: 17 Apr 2017 Posts: 1
|
Posted: Mon Apr 17, 2017 12:45 pm Post subject: There's a way without scripting |
|
|
Change your string to an array of byte. Just use this link cryptii,com/text/hexadecimal. Then copy-paste the two string to notepad. So if you want a larger string to a smaller string, Ex. you want 57 AD 4A 67 0C 57 to be 56 BC 89. You see that the first one has 6 bytes, but the second one has 3 bytes. So if a string has 9 characters, but you want 6 characters, you have to add three 00's to the replacement AOB. Only thing I don't know is how to change a smaller string to a larger string, because that always messes up the game.
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 204
Joined: 25 Jan 2006 Posts: 8579 Location: 127.0.0.1
|
Posted: Mon Apr 17, 2017 5:57 pm Post subject: |
|
|
Lua has 'string.gsub' built into it for string replacements. Check the Lua documentation for info on how to use it.
_________________
- Retired. |
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Mon Apr 17, 2017 7:59 pm Post subject: |
|
|
Code: | function Textswap()
local txt2scn = 'bla bla bla'
local txt2chg = 'i am not bla bla bla'
--convert to hex string
local searchTable = {}
for i=1,txt2scn:len() do
searchTable[i]=string.format('%X',txt2scn:byte(i))
end
local searchHexString = table.concat(searchTable)
local aobs2 = AOBScan(searchHexString)
if(aobs2 ~= nil) then
for i=0,stringlist_getCount(aobs2)-1 do
local address=stringlist_getString(aobs2,i)
writeString('0x'..address,change2)
end
object_destroy(aobs2);
aobs2=nil
end
beep()
print('Done')
end |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
nebusk !BEWARE! Deletes post on answer
Reputation: 0
Joined: 07 Jun 2019 Posts: 10
|
Posted: Fri Jun 07, 2019 10:08 pm Post subject: please help me |
|
|
i am currently making a trainer but the problem is, i want my editbox/textbox/trackbar (any of those) to change a number inside one of my script that is currently on cheat table, but i havent seen any post related to me if anyone has the solve please reply back would be a big help,
Description: |
As you can see at top left corner where it says 8575 thats the number i want to edit using one of those editbox/textbox/trackbar
but i am lacking in experience so if you know how to solve it please reply |
|
Filesize: |
58.23 KB |
Viewed: |
10388 Time(s) |

|
|
|
Back to top |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 201
|
Posted: Fri Jun 07, 2019 10:23 pm Post subject: |
|
|
https://forum.cheatengine.org/viewtopic.php?t=610209
Code: | function getStrBoundByHeadTail(s,h,t, excludeHT)
local h1,h2 = s:find(h) -- return beginning and ending index of h if found
local t1,t2 = s:find(t) -- ditto for t
if h1 and t1 and h1~='' and t1~='' then -- find both
local hh = excludeHT and h2+1 or h1 -- ending+1 or beginning index of h
local tt = excludeHT and t1-1 or t2 -- beginning-1 or ending index of t
return s:sub(hh,tt)
end
if not t1 then return s:gsub(h,t) end
end
local s='1@2@3@4@5@6@7@8'
print(getStrBoundByHeadTail(s,'1@','@8'))
--1@2@3@4@5@6@7@8
print(getStrBoundByHeadTail(s,'1@','@8',0))
--2@3@4@5@6@7
print(getStrBoundByHeadTail(s,'@','-'))
--1-2-3-4-5-6-7-8 7 | [/quote]
|
|
Back to top |
|
 |
nebusk !BEWARE! Deletes post on answer
Reputation: 0
Joined: 07 Jun 2019 Posts: 10
|
Posted: Fri Jun 07, 2019 10:29 pm Post subject: .lua |
|
|
function getStrBoundByHeadTail(s,h,t, excludeHT)
local h1,h2 = s:find(h) -- return beginning and ending index of h if found
local t1,t2 = s:find(t) -- ditto for t
if h1 and t1 and h1~='' and t1~='' then -- find both
local hh = excludeHT and h2+1 or h1 -- ending+1 or beginning index of h
local tt = excludeHT and t1-1 or t2 -- beginning-1 or ending index of t
return s:sub(hh,tt)
end
if not t1 then return s:gsub(h,t) end
end
local s='1@2@3@4@5@6@7@8'
print(getStrBoundByHeadTail(s,'1@','@8'))
--1@2@3@4@5@6@7@8
print(getStrBoundByHeadTail(s,'1@','@8',0))
--2@3@4@5@6@7
print(getStrBoundByHeadTail(s,'@','-'))
--1-2-3-4-5-6-7-8 7
can you tell me where i put those? and which are they for? editbox/textbox/trackbar
|
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Fri Jun 07, 2019 11:42 pm Post subject: Re: please help me |
|
|
nebusk wrote: | i am currently making a trainer but the problem is, i want my editbox/textbox/trackbar (any of those) to change a number inside one of my script that is currently on cheat table, but i havent seen any post related to me if anyone has the solve please reply back would be a big help, |
Is this a spam?. Found the same topic in another post,
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
nebusk !BEWARE! Deletes post on answer
Reputation: 0
Joined: 07 Jun 2019 Posts: 10
|
Posted: Fri Jun 07, 2019 11:49 pm Post subject: n |
|
|
This is not a spam, i can send u the full cetrainer and maybe you can make it work add me on discord Angelo#0963 or email me ordinarydark1 gm ail com
|
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Sat Jun 08, 2019 3:14 am Post subject: |
|
|
Code: | f = createForm()
e = createEdit(f)
t = createToggleBox(f)
t.top = e.top + e.height + 10
t.Caption = 'Change'
function changevalue()
local al = AddressList or getAddressList()
local mr1 = al.getMemoryRecordByDescription("MyHack") -- your hack description on cheat table
local myvalue = e.Text
local mr2 = tonumber(myvalue) -- if the hack value is a number
if not mr1 or not mr2 then error("Memrecs do not exist!!!") end
if (checkbox_getState(t) == 1) then
mr1.Value = mr2
mr1.Active = true
t.caption = 'ON'
else
mr1.Active = false
t.caption = 'OFF'
end
end
f.show()
t.onChange = changevalue |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
|