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
  #2  
Old 09-10-2011, 09:49 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
PHP Code:
function onWeaponFired() {
  if (! 
this.isEquipped()) {
    return 
this.equip(); // it's not already equipped, so equip it
  
}
  
  
// it's already equipped
  
this.fire();
}

function 
GraalControl.onKeyCode(temp.codetemp.key) {
  if (
temp.key == "s" && this.isEquipped()) {
    
// pressed "s" while equipped, unequip it
    
this.unequip();
  }

Just do something like this.


Also, note that this is incorrect:

PHP Code:
player.weapons[selectedweapon] == this.name 
weapons is an array of weapon objects, not weapon names. The only reason it works is because the weapon object is coerced into a string, which is then compared to the current weapon's name.

The correct way would be to do
PHP Code:
player.weapons[selectedweapon] == this 
However, the best way would just be to do

PHP Code:
player.weapon == this 
(player.weapon always refers to the currently selected weapon)
__________________
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 01:10 PM.


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