You can't use
while loops like that in Graal; it will hit a max loop limit. Either way, it's best to just use the
onKeyPressed event.
I would probably do it somewhat like this:
PHP Code:
//#CLIENTSIDE
function startFishing() {
this.isFishing = true;
this.onNextFish();
}
function onNextFish() {
this.keyToPress = int(random(0, 4));
this.cancelEvents("nextFish");
this.scheduleEvent(3, "nextFish", null);
}
function onKeyPressed(code, key) {
if (! this.isFishing) {
return;
}
for (temp.i = 0; i < 4; i ++) {
if (keydown(i)) {
if (this.keyToPress == i) {
this.caughtFish();
}
// next fish
this.onNextFish();
break;
}
}
}
You'll need to add in images and such, and I haven't tested it so it may not work for some reason, not sure.