PDA

View Full Version : Change active NPC?


JkWhoSaysNi
09-12-2006, 05:24 PM
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 :)

Luigi203
09-12-2006, 06:19 PM
wtf are you talking about? If you're talking about just changing the selected weapon, here.




for (i = 0; i < weaponscount; i++) { //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
}
}

projectigi
09-12-2006, 06:22 PM
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

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

edit: damn too slow

JkWhoSaysNi
09-12-2006, 06:28 PM
wtf are you talking about? If you're talking about just changing the selected weapon, here.




for (i = 0; i < weaponscount; i++) { //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 :)

Luigi203
09-12-2006, 06:29 PM
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

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.

projectigi
09-12-2006, 06:30 PM
but yours is gs1 =(

JkWhoSaysNi
09-12-2006, 06:43 PM
actually, i found a better way.


player.weapon = findweapon("Weapon Name");


However, it doesnt update the icon in the interface or make it selected in the Q menu.

projectigi
09-12-2006, 07:41 PM
well at wiki it says player.weapon is read only

Admins
09-13-2006, 01:14 AM
May be selectedweapon = player.weapons.index(findweapon(weaponname)) ?