Jump to content

Item Sorter Part 2


KnightPhoenix7

Recommended Posts

I have more questions on sorting items using scripts. Here is the basic text:

 

int Number

 

set Number to player.getitemcount WeapNVCleaver

player.removeitem WeapNVCleaver Number

ABMeleeWeapons2.additem WeapNVCleaver Number

 

Number is a variable storing the amount of items the player has. WeapNVCleaver is the editor ID of the Weapon and ABMeleeWeapons2 is the Reference Editor ID of the storage container. What I want to know is how to sort items and save the current item damage level. It would be handy to be able to remove the item from the player and move it to a locker instead of creating a new item at the destination. I also ran into the problem using this method that weapons with mods on them lose those mods. I was wondering if anybody has a solution to this.

Link to comment
Share on other sites

Here's a sample of script I'm using for my house mod.

scn WeaponSorterScript

 

Short WeapHealth

Float weaphealthF

Float TimerA

short Button

Short Count

 

Begin OnActivate

Set Button to 1

If WeaphealthF == 0

ShowMessage WeaponSortingMsg

Set WeaphealthF to 1

Endif

Set TimerA To .1

END

 

Begin GameMode

 

If Player.getitemcount Weap10mmPistol >=1

If button == 1

DisablePlayerControls 1 1 1 1 0 1 1

Player.equipitem Weap10mmPistol 0 1

if TimerA > 0

set TimerA to TimerA - getSecondsPassed

else

Set weaphealth to player.getweaponhealthperc

Set weaphealthF to (weaphealth*0.01)

Player.removeitem Weap10mmPistol 1 1

WeaponStorageREF.AddItemHealthPercent Weap10mmPistol 1 weaphealthF

set TimerA to .1

endif

endif

else

Set Button to 0

EnablePlayerControls

endif

END

 

This displays a message, then disables player controls while items are put into the container marked WeaponStorageREF, then reenables player controls when done. This solves the problem of weapon health, but not mods. Take note that this will not work for armor, and I don't know a solution to that. You should use this script on something like an activator and not a conatiner itself. Hopefully this helps you.

Link to comment
Share on other sites

  • 2 weeks later...

Heres how I did weapon sorting (Took me only a few minutes once I figured it out)

 

First, you need to make a Formlist with every weapon you don't want sorted. To do this, under the Item tap, just highlight weapons with no filter and add everything. Then go through the list and take out what you want sorted (The list is an exclusion list)

 

Then, for the actual sorting script, use the RemoveAllTypedItems

 

Mine is something like

player.RemoveAllTypedItems GSWeaponLocker11 1 0 40 GSArmoryLocker11LIST

 

What this will do is remove all items no in the list. This will cause some problems with mods, as those items also get sorted in any list. To work around this, you need another container (can be disabled/out of site). You also need create a Form List with every single weapon in it, and then script it to sort to this container first. Then, if you want, at the end of the sorting script, you could add another script to move all items from the first container (the temp storage for guns from mods) back to the player. So in the end, my script looks something like this...

 

player.RemoveAllTypedItems GSWeaponLocker16 1 0 40 GSArmoryLocker16LIST (Custom Weapons)

player.RemoveAllTypedItems GSWeaponLocker11 1 0 40 GSArmoryLocker11LIST (Guns)

player.RemoveAllTypedItems GSWeaponLocker12 1 0 40 GSArmoryLocker12LIST (Energy Weapons)

player.RemoveAllTypedItems GSWeaponLocker13 1 0 40 GSArmoryLocker13LIST (Explosive Weapons)

player.RemoveAllTypedItems GSWeaponLocker14 1 0 40 GSArmoryLocker14LIST (Melee Weapons)

player.RemoveAllTypedItems GSWeaponLocker15 1 0 40 GSArmoryLocker15LIST (Throwing Weapons)

GSWeaponLocker16.RemoveAllItems Player (Optional: not in my armory script {I use it for food/drink sorting however}, but it will return anything not sorted to the player)

Link to comment
Share on other sites

I know this post is a bit old but i would like to thank Avianrave for sharing his script. Kudos! I am new to scripting and i have a lot to learn. I did understand everything but one thing.

 

Like here: player.RemoveAllTypedItems GSWeaponLocker16 1 0 40 GSArmoryLocker16LIST (Custom Weapons). What are the 1 0 40 for?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...