• Log in or sign up for an account here: https://www.sythe.org/login

Question regarding a redirect...

Joined
Nov 26, 2007
Sythe Gold
1,198
Messages
7,630
Two Factor Authentication User
SytheSteamer
http://forums.sonicretro.org/index.php?

If you type in:

19 65 09 17

and then press A+Enter simultaneously, it redirects to a new page.

http://forums.sonicretro.org/cheats/

(for those that don't know 19 65 09 17 is the level select cheat in Sonic the Hedgehog 2)

I was wondering if anyone could explain how that works, as it's damn interesting and i'd like to know how to code something like that!

Thanks!

Ame
 
You'll notice that there is a file http://forums.sonicretro.org/cheats/cheatEngine.js in this file, you have javascript.

The main part of this javascript is
Code:
jQuery(document).ready(function () {
    jQuery("body").keydown(function (e) {
        var kc = (e.keyCode == 0) ? e.which : e.keyCode;
        for (var i = 0; i < cheatCodes_C.length; i++) if (cheatCodes_E[i] == 1) {
            if (kc == cheatCodes_C[i][cheatCodes_P[i]][0] || kc == cheatCodes_C[i][cheatCodes_P[i]][1]) {
                cheatCodes_P[i]++;
            } else {
                cheatCodes_P[i] = 0;
            }
            if (cheatCodes_P[i] == cheatCodes_R[i]) playRing();
            if (cheatCodes_P[i] == cheatCodes_C[i].length) {
                cheatCodes_F[i]();
                cheatCodes_E[i] = 0;
                cheatCodes_P[i] = 0;
            }
        }
    });
});
Which translates to: every time a button is pushed on this web page, add it to an array.
Check that array against another, which is a list of the keys you need to press to activate a 'cheat code'



To create a cheat code, first add in an array of character keys and the callback function.
Code:
    addCheat([k1, k9, k6, k5, k0, k9, k1, k7, kA, kS], function () {
        window.location.href = 'http://forums.sonicretro.org/cheats/';
    }, 8);

I hope this helps you understand the javascript behind it.
 
Two Factor Authentication User
SytheSteamer
You'll notice that there is a file http://forums.sonicretro.org/cheats/cheatEngine.js in this file, you have javascript.

The main part of this javascript is
Code:
jQuery(document).ready(function () {
    jQuery("body").keydown(function (e) {
        var kc = (e.keyCode == 0) ? e.which : e.keyCode;
        for (var i = 0; i < cheatCodes_C.length; i++) if (cheatCodes_E[i] == 1) {
            if (kc == cheatCodes_C[i][cheatCodes_P[i]][0] || kc == cheatCodes_C[i][cheatCodes_P[i]][1]) {
                cheatCodes_P[i]++;
            } else {
                cheatCodes_P[i] = 0;
            }
            if (cheatCodes_P[i] == cheatCodes_R[i]) playRing();
            if (cheatCodes_P[i] == cheatCodes_C[i].length) {
                cheatCodes_F[i]();
                cheatCodes_E[i] = 0;
                cheatCodes_P[i] = 0;
            }
        }
    });
});
Which translates to: every time a button is pushed on this web page, add it to an array.
Check that array against another, which is a list of the keys you need to press to activate a 'cheat code'



To create a cheat code, first add in an array of character keys and the callback function.
Code:
    addCheat([k1, k9, k6, k5, k0, k9, k1, k7, kA, kS], function () {
        window.location.href = 'http://forums.sonicretro.org/cheats/';
    }, 8);

I hope this helps you understand the javascript behind it.

Thanks for the response Jazz, very helpful. Cheers.
 
Runescape Gamblingrunescape gambling
Back
Top