I started programming a few months ago. I'm making a complete client side game in Animate CC, so I'm trying a simple measure against memory scan software.
I'm trying to avoid people to change my money variable.
var canMoneyChange = false;
var money = 0;
var previousMoney = 0;
function everyFrame() { //Let's admit that this function is called every frame
if (moneyChange == true) {
lastMoney = money;
canMoneyChange = false;
} else {
if (lastMoney != money) { //If money is "magically" changed it should drop here
resetGame();
}
}
Now evertime I update the money visual display I also have to include the boolean variable:
//...
canMoneyChange = true;
money += 100; //For example
updateMoney(); //This is only for visual effects
//...
Wondering if this works at all, thanks.
EDIT: Oh damn, I was not realising that CE would find both lastMoney and money at the same time. I could do something like multiplying by a number to hide lastMoney:
function everyFrame() { //Let's admit that this function is called every frame
if (moneyChange == true) {
lastMoney = money * 8;
canMoneyChange = false;
} else {
if (lastMoney != money * 8) {
resetGame();
}
}