Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-12-2006, 05:24 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Change active NPC?

Hello, how can I change the active (the one that gets used when you press D) weapon npc through code? I guess it could be done through a trigger, but i dont know the name of it.

thanks for any help
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #2  
Old 09-12-2006, 06:19 PM
Luigi203 Luigi203 is offline
Hamma Time
Luigi203's Avatar
Join Date: Mar 2003
Location: North East PA
Posts: 285
Luigi203 is on a distinguished road
Send a message via AIM to Luigi203
wtf are you talking about? If you're talking about just changing the selected weapon, here.


PHP Code:

for (0weaponscounti++) { //loop through the weapons
  
if (strequals(#w(i),WEAPONNAME)) {  //check to see if the weapons index i is equal to what you want to change the weapon to
   
selectedweapon i//change the selected weapon
   
break; //end the loop
  
}

__________________


CAUTION
Reply With Quote
  #3  
Old 09-12-2006, 06:22 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
hrm i think selectedweapon is the id of the current weapon
you could loop through the player.weapons array and use weapon.name to get the name
like
NPC Code:

function onCreated(){
for(i=0;i<=player.weapons.size();i++){
if(player.weapons[i]=="weaponname")
selectedweapon=i;
}
}



edit: damn too slow
Reply With Quote
  #4  
Old 09-12-2006, 06:28 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Quote:
Originally Posted by Luigi203
wtf are you talking about? If you're talking about just changing the selected weapon, here.


PHP Code:

for (0weaponscounti++) { //loop through the weapons
  
if (strequals(#w(i),WEAPONNAME)) {  //check to see if the weapons index i is equal to what you want to change the weapon to
   
selectedweapon i//change the selected weapon
   
break; //end the loop
  
}

yes, thats all i wanted to do. Thanks
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #5  
Old 09-12-2006, 06:29 PM
Luigi203 Luigi203 is offline
Hamma Time
Luigi203's Avatar
Join Date: Mar 2003
Location: North East PA
Posts: 285
Luigi203 is on a distinguished road
Send a message via AIM to Luigi203
Quote:
Originally Posted by projectigi
hrm i think selectedweapon is the id of the current weapon
you could loop through the player.weapons array and use weapon.name to get the name
like
NPC Code:

function onCreated(){
for(i=0;i<=player.weapons.size();i++){
if(player.weapons[i]=="weaponname")
selectedweapon=i;
}
}


Okay, you just did the same exact thing I did. Selectedweapon is the current weapon, its writable.
__________________


CAUTION
Reply With Quote
  #6  
Old 09-12-2006, 06:30 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
but yours is gs1 =(
Reply With Quote
  #7  
Old 09-12-2006, 06:43 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
actually, i found a better way.

PHP Code:
player.weapon findweapon("Weapon Name"); 
However, it doesnt update the icon in the interface or make it selected in the Q menu.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #8  
Old 09-12-2006, 07:41 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
well at wiki it says player.weapon is read only
Reply With Quote
  #9  
Old 09-13-2006, 01:14 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
May be selectedweapon = player.weapons.index(findweapon(weaponname)) ?
Reply With Quote
Reply


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 06:25 AM.


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