I should note that the functionality of the default sword is a bit of a special case. You can swing it regardless of whether your player is currently frozen, but only if your gani = sword. This means the checks should go before the movement functions and the check for the player being frozen.
PHP Code:
function onTimeout() {
CheckSword();
if (player.freezetime == -1) Movement();
setTimer(0.05);
}
function CheckSword() {
// this.keyspressed[x] would be an array that tracks the keys pressed(0-9)
// for situations like below, or else you'd end up being able to just hold down 'S'
// for quick and repeated swings. That would be most undesirable :P
if (keydown(5)) {
if (this.keyspressed[5] == false) {
if (player.freezetime == -1 || player.ani == "sword") {
setAni("sword",null);
freezeplayer(.25);
}
this.keyspressed[5] = true;
}
} else this.keyspressed[5] = false;
}