You'll want to use onKeyPressed() and GraalControl.onKeyUp()
PHP Code:
//#CLIENTSIDE
function onCreated() {
this.spread = 0.1;
this.freeze = 0.1; // player freeze time
this.speed = 0.05; // controls the timeout
this.reload = 50;
this.load = 50;
}
function onKeyPressed(code, key, scan) {
if (player.weapon != this) {
return; // weapon not selected
}
if (this.keyD) {
return;
}
if (key == "d") {
this.keyD = true;
this.onTimeOut();
}
}
function GraalControl.onKeyUp(code, key, scan) {
if (key == "d") {
this.keyD = false;
this.setTimer(0); // end the timeout, stop shooting
}
}
function onTimeOut() { // this is where the shooting goes
freezePlayer(this.freeze);
setAni("millenium_scar-fire", NULL);
temp.angl = getangle(vecx(player.dir), vecy(player.dir))+random(this.spread*-1,this.spread);
shoot(player.x + 0.5 + vecx(player.dir), player.y + vecy(player.dir), player.z, temp.angl, 0, 0, "idle", player.dir);
setTimer(this.speed);
}
You'll also need to add checks for things like reloading, etc.
Also, remember not to mix GS1 and GS2 (and not to use GS1), such as you're doing here:
PHP Code:
if(actionprojectile){
hurt 1;
}
The proper way to do that is:
PHP Code:
function onActionProjectile() {
hurt(1);
}
...which should go in a system weapon, anyway.