View Single Post
  #3  
Old 06-26-2013, 12:11 AM
defaultaccount defaultaccount is offline
Cassini
Join Date: Feb 2006
Location: HeLLifAX
Posts: 299
defaultaccount is on a distinguished road
I'm trying to get my weapons script to work, I tried searching how to make a rate of fire, but it doesn't work while walking it only works when im standing still to shoot.

NPC Code:

function onKeypressed() {
if (keydown(4)) {
if (this.equiped = true) {
player.weapon.trigger("weaponFired");
} else if (this.equiped = false) {
onEquip();
}
}
}

function onWeaponFired() {
if (this.fired) {
if (this.equiped = true) {
if (this.ammo > 0) {
this.fired = false;
setani(this.fire, null);
this.ammo -= 1;
freezeplayer(this.freeze);
this.angle=getangle(vecx(playerdir),vecy(playerdir ));
setshootparams(player.account);
shoot(player.x+.3, player.y+.3, player.z, this.angle+random(this.bulletangle, abs(this.bulletangle)), 0, this.bspeed, "pb_bullet1", "pb_bullet.png");
triggerServer("gui", this.name, "Shell");
}
}
}
}

function onTimeout() {
if (this.fired == false) {
this.fired = true;
setTimer(this.rof);



holding d on this makes me shoot when I change my direction i'm trying to make it shoot when im walking, it shoots when I move but only when I move

Last edited by defaultaccount; 06-26-2013 at 12:23 AM..
Reply With Quote