Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-10-2011, 09:39 PM
furry_mougle furry_mougle is offline
big heart
furry_mougle's Avatar
Join Date: Aug 2011
Posts: 42
furry_mougle is an unknown quantity at this point
weapon equip/dequip

I've been trying to figure this out for ages, and I simply cannot figure it out.

Essentially I've been having a problem with onWeaponFired and the detection of an equipped weapon.

What I want to do is when the player presses D, it 'equips' the weapon (sets ganis) and when they dequip it (pressing S) it'll reset the ganis. However, when I want to use onWeaponFired it'll immediately fire the weapon even though the weapon isn't equipped by pressing D. I've tried many different ways including with booleans, but it doesn't go over very well because pressing D is the same thing as executing onWeaponFired at the same time. Not really sure how I would go about this.

Also, one thing to note is that this isn't a clone of Era or something I just made the weapon for fun and uhh I know Era uses the same equip/dequip system for guns. First you press D, it equips then you press D again and it fires the weapon.

PHP Code:
//#CLIENTSIDE
/*
  0 dequipped
  1 equipped
*/
function onCreated(){
  
this.on false;
  
this.dPress 0;
}

function 
onKeyPressed(code,key){
  if (
key == "d" && player.weapons[selectedweapon] == this.name && this.dPress == 0){ 
     
this.on true;
     
player.chat this.dPress;
     
gravAni();
     
this.dPress 1;
    
// this.increment += 1; 
  
}
  if (
key == "s" && player.weapons[selectedweapon] == this.name && this.dPress == 1){ 
     
this.on false;
     
gravAni();
     
this.dPress 0;
     
player.chat this.dPress;
  }


function 
gravAni(){
  if (
this.on){
    
replaceani("idle""gravgun_idle");
    
replaceani("walk""gravgun_walk");
    
setani("gravgun_idle"NULL);
  }else if(!
this.on){
    
replaceani("idle""idle");
    
replaceani("walk""walk");
  }
}

function 
onWeaponFired(){
 if( 
this.on ){ // if equipped, fire
      
setani("gravgun_fire"NULL);
    
player.chat "Fired";
    
//  player.chat = this.dPress;
      //sleep(this.increment - );
      //  player.chat = "Fired for " @ this.increment;
      //  setani("gravgun_idle", NULL);
 
}

Is there a way to prevent onWeaponFired from being executed this way?
__________________
Quote:
Originally Posted by ffcmike View Post
But make sure to change beer.png to Orange Juice.
pay bills to play graal
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.