
08-27-2010, 10:52 PM
|
the fake one
|
 |
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
|
|
Quote:
Originally Posted by cbk1994
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.
|
.. |
|
|