View previous topic :: View next topic |
Author |
Message |
Discusser Newbie cheater
Reputation: 0
Joined: 15 Jun 2019 Posts: 10 Location: no?
|
Posted: Sun Jun 16, 2019 7:26 am Post subject: How to freeze value and allow increase/decrease with Lua? |
|
|
So I'm trying to make a trainer with Lua since I prefer using buttons instead of hotkeys and to use buttons I need to use Lua, now if I wanted to increase or decrease the value, it would be simple, but how am I supposed to freeze the value and allow increase/decrease?
_________________
I came here for help |
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Sun Jun 16, 2019 7:30 am Post subject: |
|
|
Code: |
myValue = 100;
function inc()
myValue = myValue + 1;
end
function dec()
myValue = myValue - 1;
end
myTimer = createTimer();
t.Interval = 100 -- ms
t.onTimer = function(sender)
writeInteger('SomeAddress',myValue);
end
|
call inc or dec to increase or decrease the value.
The timer will write it to given address every 100 milliseconds (freeze it)
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
Discusser Newbie cheater
Reputation: 0
Joined: 15 Jun 2019 Posts: 10 Location: no?
|
Posted: Sun Jun 16, 2019 7:32 am Post subject: |
|
|
Well, I'm not the one changing the value, it's the game that is. So, I still can't do it.
Also, the increase and decrease isn't always by 1, sometimes it can be 0.99, sometimes 5.99, sometimes 10, etc..
_________________
I came here for help |
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Sun Jun 16, 2019 7:35 am Post subject: |
|
|
It's the game that modifies the value, erm ok.
What type of value is it, and why do you want to freeze it, also if the game modifies the value yet you want to freeze it and allow it, it basically cancels the freezing operation.
So how do you think to do it?
Edit:
So if the games modifies by 0.99/1/1.01 and etc. from what kind of values do you seek to prevent/disallow change?
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
Discusser Newbie cheater
Reputation: 0
Joined: 15 Jun 2019 Posts: 10 Location: no?
|
Posted: Sun Jun 16, 2019 7:37 am Post subject: |
|
|
Basically, it's a float and I want to freeze it so you don't lose any of it (money).
Some trainers allow you to freeze a value and only make it increase so basically you never lose money but instead get more. I know that you can make it freeze and allow increase/decrease using hotkeys but I don't want to use hotkeys since they are annoying.
Edit: I'm not english so I didn't understand what you meant by Quote: | from what kind of values do you seek to prevent/disallow change? |
Edit2: I give up for today, this is why I don't like coding.
_________________
I came here for help |
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Sun Jun 16, 2019 7:53 am Post subject: |
|
|
Discusser wrote: |
Edit: I'm not english so I didn't understand what you meant by Quote: | from what kind of values do you seek to prevent/disallow change? |
Edit2: I give up for today, this is why I don't like coding. |
English is not my native language too )
Sorry for the questions as I was trying to understand what was your goal, because freezing but yet allowing value to change, is tricky.
Was aiming to create a rule of valid change and invalid change.
Here, use this example to create your own trainer, added some comments so you could understand the logic.
Code: | -- set up form and buttons for given example;
f = createForm();
bInc = createButton(f);
bDec = createButton(f);
bInc.autosize,bDec.autosize = true,true;
bInc.Caption = 'Allow Increase';
bDec.Caption = 'Allow Decrease';
bInc.left = (f.width - bInc.Width - bDec.Width)//2
bDec.left = bInc.left + bInc.Width + 5;
bInc.Top,bDec.Top = 25,25;
-- allow only one button to be active at a time (after user first selected)
bInc.onClick = function (sender)
sender.Enabled = false;
bDec.Enabled = true;
end
bDec.onClick = function (sender)
sender.Enabled = false;
bInc.Enabled = true;
end
-- timer event;
ourValue = nil; -- define some variable;
freezeTimer = createTimer(f);
freezeTimer.Interval = 100;
freezeTimer.onTimer = function(sender)
if (not ourValue) then
ourValue = readFloat('address'); -- our starting value, so we know to what compare; fetches once timer started;
end
local currentValue = readFloat('address');
-- if increase selected & and current value is smaller than saved value, or decrease selected and current value is bigger than saved value;
if ( (not bInc.Enabled and currentValue < ourValue) or (not bDec.Enabled and currentValue > ourValue)) then -- freeze it
writeFloat('address',ourValue);
else -- everything is fine, and we should update ourValue to currentValue
ourValue = currentValue;
end
end
|
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
Discusser Newbie cheater
Reputation: 0
Joined: 15 Jun 2019 Posts: 10 Location: no?
|
Posted: Sun Jun 16, 2019 12:31 pm Post subject: |
|
|
Thanks, I'll check it out later.
_________________
I came here for help |
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 467
Joined: 09 May 2003 Posts: 25675 Location: The netherlands
|
Posted: Sun Jun 16, 2019 2:20 pm Post subject: |
|
|
put the addresses in your addresslist if they aren't there already andf give them unique descriptions
Then use stuff like
Code: |
mr1=AddressList.getMemoryRecordByDescription('unique description')
mr2=AddressList.getMemoryRecordByDescription('unique description 2')
...
mr1.Active=true
mr2.Active=true
mr1.AllowIncrease=true
mr2.AllowDecrease=true
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
|