Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7527029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:00:07+00:00 2026-05-30T04:00:07+00:00

I have been trying to get a custom inventory script working in unrealscript. I

  • 0

I have been trying to get a custom inventory script working in unrealscript. I need to check on weapon pickup if the weapon you are picking up has a weapon group that matches one you already have or not. If so it swaps the weapons of the given group. If not you gain the new weapon. Currently we have 4 weapon groups. What i have tried to no avail to find is how to find the weapon group of a weapon being picked up. and how to check that against the other weapons. I have been working with the add inventory function.

NewItem is the item you just interacted with. And i need to find the other weapons in your current inventory and their weapon groups.

simulated function bool AddInventory(Inventory NewItem, optional bool bDoNotActivate)
{
    local Inventory Item, LastItem;

    // The item should not have been destroyed if we get here.
    if( (NewItem != None) && !NewItem.bDeleteMe )
    {
        // if we don't have an inventory list, start here
        if( InventoryChain == None )
        {
            InventoryChain = newItem;
        }
        else
        {
            // Skip if already in the inventory.
            for (Item = InventoryChain; Item != None; Item = Item.Inventory)
            {
                if( Item == NewItem )
                {
                    return FALSE;
                }
                LastItem = Item;
            }
            LastItem.Inventory = NewItem;
        }

        //Edited by Matt Kerns

        `LogInv("adding" @ NewItem @ "bDoNotActivate:" @ bDoNotActivate);

        `Log ("Added to inventory!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        NewItem.SetOwner( Instigator );
        NewItem.Instigator = Instigator;
        NewItem.InvManager = Self;
        NewItem.GivenTo( Instigator, bDoNotActivate);

        // Trigger inventory event
        Instigator.TriggerEventClass(class'SeqEvent_GetInventory', NewItem);
        return TRUE;
    }

    return FALSE;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:00:10+00:00Added an answer on May 30, 2026 at 4:00 am

    If you want write all code in InventoryManager it will be look like

    simulated function bool AddInventory(Inventory NewItem, optional bool bDoNotActivate){
    local Inventory Item, LastItem;
    
    // The item should not have been destroyed if we get here.
    if( (NewItem != None) && !NewItem.bDeleteMe )
    {
    //if weapon - work in personal weapon function
    if(Weapon(NewItem) != none)
            return AddItemWeapon(NewItem, bDoNotActivate);
        // if we don't have an inventory list, start here
        if( InventoryChain == None )
        {
            InventoryChain = newItem;
        }
        else
        {
            // Skip if already in the inventory.
            for (Item = InventoryChain; Item != None; Item = Item.Inventory)
            {
                if( Item == NewItem )
                {
                    return FALSE;
                }
                LastItem = Item;
            }
            LastItem.Inventory = NewItem;
        }
    
        //Edited by Matt Kerns
    
        `LogInv("adding" @ NewItem @ "bDoNotActivate:" @ bDoNotActivate);
    
        `Log ("Added to inventory!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        NewItem.SetOwner( Instigator );
        NewItem.Instigator = Instigator;
        NewItem.InvManager = Self;
        NewItem.GivenTo( Instigator, bDoNotActivate);
    
        // Trigger inventory event
        Instigator.TriggerEventClass(class'SeqEvent_GetInventory', NewItem);
        return TRUE;
    }
    
    return FALSE;
    

    }

    simulated function AddItemWeapon(Inventory NewItem, optional bool bDoNotActivate)
    {

    local Inventory Item, LastItem;
    local Weapon WeaponNewItem;
    
    WeaponNewItem= Weapon(NewItem);
    
    // The item should not have been destroyed if we get here.
    if( (NewItem != None) && !NewItem.bDeleteMe )
    {
        // if we don't have an inventory list, start here
        if( InventoryChain == None )
        {
            InventoryChain = newItem;
        }
        else
        {
            //look for our group
            for (Item = InventoryChain; Item != None; Item = Item.Inventory){
                if(Weapon(Item) != none && Weapon(Item).Group == WeaponNewItem.Group){
                    RemoveFromInventory(Item);
                    break;
                }
    
            }
                // Skip if already in the inventory.
                for (Item = InventoryChain; Item != None; Item = Item.Inventory)
                {
                    if( Item == NewItem )
                    {
                        return FALSE;
                    }
                    LastItem = Item;
                }
                LastItem.Inventory = NewItem;
    
        }
    
        //Edited by Matt Kerns
    
        `LogInv("adding" @ NewItem @ "bDoNotActivate:" @ bDoNotActivate);
    
        `Log ("Added to inventory!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        NewItem.SetOwner( Instigator );
        NewItem.Instigator = Instigator;
        NewItem.InvManager = Self;
        NewItem.GivenTo( Instigator, bDoNotActivate);
    
        // Trigger inventory event
        Instigator.TriggerEventClass(class'SeqEvent_GetInventory', NewItem);
        return TRUE;
    }
    
    return FALSE;
    

    }

    This is best way if your game use network and replicate inventory. If not, you can simple write something like

    simulated function AddItemWeapon(Inventory NewItem, optional bool bDoNotActivate){
    local Inventory Item, LastItem;
    local Weapon WeaponNewItem;
    local bool bAddNewWeapon;
    
    bAddNewWeapon = true;
    WeaponNewItem = Weapon(NewItem);
    
    // The item should not have been destroyed if we get here.
    if( (NewItem != None) && !NewItem.bDeleteMe )
    {
        // if we don't have an inventory list, start here
        if( InventoryChain == None )
        {
            InventoryChain = newItem;
        }
        else
        {
            //look for our group
            for (Item = InventoryChain; Item != None; Item = Item.Inventory){
                if(Weapon(Item) != none && Weapon(Item).Group == WeaponNewItem.Group){
                    NewItem.Inventory = Item.Inventory; 
                    bAddNewWeapon = false;
                    RemoveFromInventory(Item);
                    break;
                }
                LastItem = Item;
    
            }
            if(bAddNewWeapon){
                for (Item = InventoryChain; Item != None; Item = Item.Inventory){
                    LastItem = Item;
                }
            }
            LastItem.Inventory = NewItem;
        }
    

    But im sure that this is bad way. You should write class which will save all used weapon groups and use InventoryManager only as storage

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying for 4 days to get app-engine and grails working together
So I have been working with Wordpress 3.x and trying to build a custom
Ok, I have been trying to get a 'custom' ACL to work with extra
I have been trying to get around this error for a day now and
I have been trying to get more in to TDD. Currently keeping it simple
I have been trying to get yui-css grid system to make a three column
I have been trying to get nServiceBus to work with Ninject 2.0 as the
I have been trying to get LastBootUpTime using Win32_OperatingSystem class (WMI). HRESULT hr =
I have been trying to get this one section of my UI to immediatly
I have been trying all afternoon to get the jQuery Sifr Plugin ( http://jquery.thewikies.com/sifr/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.