[HELP]Avoiding GDT's Anti-cheat picking random function

Hello. What I am trying to do here, is avoid the game’s picking the same random notification when I click a button. For example, I have set variables for texts like this:

var p1 = "The best idea you've ever had! I'm training you so well! Do it. I'll give you a cookie after".localize()

Then, have an array with all the texts from notifications

var possibleTexts = [p1, p2, p3, n1, n2, n3, m1, m2, m3, m4]

So, every time I open the game, it picks a text, but clicking the button with this piece of code in its case,
GameManager.company.notifications.push(notification);
I assume it pushes the notification sucessfully so the game enables it and you can see it.

(Notification:)

var header = "Magic 8 Ball".localize("heading")
notification = new Notification({
            header: header,
            text: possibleTexts[Math.floor(Math.random() * possibleTexts.length)],
            image: imageSelector
        });

In short words
Problem: Game picks the same text and not a random one each time.
What I’m trying to do: Pick a random text every time the button is pressed.

-Thank you in advance.

1 Like

You are using Math.random() and not our built-in .pickRandom() so this will most definitely not return the same value, each call. You are likely not re-generating the notification.

1 Like

So, I’m gonna put possibleTexts.pickRandom() and I’m okay? One second, will try it out.

Can’t test it out yet, it seems that I’m pushing the notification once, it shows up and never shows again when I click the button. Obviously it’s pushed and won’t trigger ever again. Gotta find another way to do this.

You are storing the text in the “text” attribute of the Notification object at the moment you are creating it.
The text attribute will be the same after creating the object if you don’t change it. You may want to change the “text” of the Notification before pushing it.

Also check if the push method works ok if you push the same Notification object over and over again. I’m not familiar with the game code but maybe it was meant to be used with a new Notification object each time you use the push method.

1 Like

Oviously, I push it the first time and it works. The second though, it doesn’t show up anymore, since I have done changes in the code.