I've converted it to GS2 and fixed a couple of things; see the comments I left
PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
if (! this.flute) { // the flute is off, so turn it on
setAni("idle", NULL);
disableDefMovement();
disableWeapons();
disableSelectWeapons();
disablePause();
disableMap();
this.flute = true; // 'set' and 'unset' are deprecated and no longer used
}
}
// like Jerret (fowlplay4) said, you can combine them in to one function
function onKeyPressed(code, key) {
if (this.flute) { // if the flute is on
if (keydown(6)) { // turn off the flute
enableDefMovement();
enableWeapons();
enableSelectWeapons();
enablePause();
enableMap();
this.flute = false;
} else if (key == "z") {
setAni("delitto_flute-play1", NULL);
} else if (key == "x") {
setAni("delitto_flute-play2", NULL);
} else if (key == "c") {
setAni("delitto_flute-play3", NULL);
} else if (key == "j") {
setAni("delitto_flute-play4", NULL);
} else if (key == "v") {
setAni("delitto_flute-play5", NULL);
} else if (key == "b") {
setAni("delitto_flute-play6", NULL);
}
}
}
There are better ways to do this, but they're more complicated and would probably just make it even more confusing.
As for the problem of the sound repeating, that's in the GANI. Open up each of the GANI files in the GraalShop.exe program, and on the right side with the GANI attributes, change "SETBACKTO" to the name of the flute idle GANI. This way, when the GANI is over, it goes back to the normal animation and doesn't loop the sound.