Results 1 to 14 of 14
  1. #1
    Qvintus's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    189
    My Mood
    Relaxed

    Question Possible to create a player inventory list?

    Hello I've been working on a server manager tool lately, and I'd like to make a player inventory list if possible.
    I've however run into a problem with my list always returning null, I'm calling the list this way:

    Code:
    Container playerInventory = player.GetContainerOfType(CollectionTypes.Inventory);
    var fullInventory = playerInventory.Contents.GetItems();
    I know the player is not null, so that is not the problem. Later on in my code I check for whether fullInventory is null or not.
    It's always returning null, I would assume this would return all items in a player inventory?

    I would have thought it might have been because I do not get such info from the server, however I can't even find my own inventory through this?

    Guessing I'm simply doing something wrong, any tips or guiding pointer would be lovely.
    - If my post helped you in any way, please hit the Thanks button. It'll keep me motivated.

  2. #2
    .Zer0's Avatar
    Join Date
    Mar 2015
    Gender
    male
    Posts
    331
    Reputation
    11
    Thanks
    1,181
    My Mood
    Amused
    Hey first of possible it is for sure.
    I am currently not on my Workstation and at university I will take a look later tonight (GMT+1)

    Meanwhile check how inventory is being sorted.


    Side Question : Does anyone know how data is being saved on The Server side.
    I guess it is for sure not using SQL vor sqlite which would offer great extensions.

  3. #3
    Qvintus's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    189
    My Mood
    Relaxed
    I've found out using the .ToList() method returns everything I need to know.
    Code:
    Container playerInventory = player.GetContainerOfType(CollectionTypes.Inventory);
    var fullInventory = playerInventory.Contents.ToList();
    After this it's a simple matter for putting it through a foreach or for loop. Guess I simply wasn't thinking straight.
    - If my post helped you in any way, please hit the Thanks button. It'll keep me motivated.

  4. #4
    .Zer0's Avatar
    Join Date
    Mar 2015
    Gender
    male
    Posts
    331
    Reputation
    11
    Thanks
    1,181
    My Mood
    Amused
    Could you post The output you get with this ?

    Pure just item names or also The item ids

  5. #5
    Qvintus's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    189
    My Mood
    Relaxed
    Quote Originally Posted by .Zer0 View Post
    Could you post The output you get with this ?

    Pure just item names or also The item ids
    Well it's dependent on what character you click.. not sure I understand what ya mean?
    To get an item name etc. you simply
    Code:
    private static void fillInvList()
        {
            if (SelectedEntity == null || SelectedEntity.Controller.Id == ServerID)
                return;
    
            Entity player = SelectedEntity;
            Container playerInv = player.GetContainerOfType(CollectionTypes.Inventory);
            playerInventory = playerInv.Contents.ToList();
            int count = 0;
            foreach (var item in playerInventory)
            {
                if (item != null && item.Name != null)
                {
                    GUI.Label(new Rect(0, (20 * count), 195, 20), string.Format("{0} : {1}", item.Name, item.StackAmount), PlayerListBtnStyle);
                    count++;
                }
                
            }
        }
    Above makes a list of selected entities inventory, "ItemName : StackAmount".

    Etc. "Stone : 159"
    Output
    Sometimes I get empty fields, not entirely sure why..
    Edit: Likely due to empty stacks that used to be items in the player's inventory. Changed for loop to foreach.

    As for your Data question
    From what I can see everything appear to be stored in .dat files
    In the location: <Username>\AppData\LocalLow\CodeHatch\Reign Of Kings\Slot0
    Last edited by Qvintus; 04-02-2015 at 04:58 AM. Reason: Changed for loop to a foreach loop to avoid empty spaces.
    - If my post helped you in any way, please hit the Thanks button. It'll keep me motivated.

  6. The Following 2 Users Say Thank You to Qvintus For This Useful Post:

    .Zer0 (04-02-2015),lantro (04-04-2015)

  7. #6
    fisheyed's Avatar
    Join Date
    Mar 2015
    Gender
    male
    Posts
    196
    Reputation
    10
    Thanks
    13
    Quote Originally Posted by Qvintus View Post
    Well it's dependent on what character you click.. not sure I understand what ya mean?
    To get an item name etc. you simply
    Code:
    private static void fillInvList()
        {
            if (SelectedEntity == null || SelectedEntity.Controller.Id == ServerID)
                return;
    
            Entity player = SelectedEntity;
            Container playerInv = player.GetContainerOfType(CollectionTypes.Inventory);
            playerInventory = playerInv.Contents.ToList();
            int count = 0;
            foreach (var item in playerInventory)
            {
                if (item != null && item.Name != null)
                {
                    GUI.Label(new Rect(0, (20 * count), 195, 20), string.Format("{0} : {1}", item.Name, item.StackAmount), PlayerListBtnStyle);
                    count++;
                }
                
            }
        }
    Above makes a list of selected entities inventory, "ItemName : StackAmount".

    Etc. "Stone : 159"
    Output
    Sometimes I get empty fields, not entirely sure why..
    Edit: Likely due to empty stacks that used to be items in the player's inventory. Changed for loop to foreach.

    As for your Data question
    From what I can see everything appear to be stored in .dat files
    In the location: <Username>\AppData\LocalLow\CodeHatch\Reign Of Kings\Slot0
    Nice addition to any admin tool! Now if you combine this with containers like chests etc from:

    Code:
    . Core.Cache.ContainerEntity instead of the usual .Entity for players
    You could possibly also check all chests a player own.

    If you parse via the guild id you could possibly even check guild containers connected to that person.

  8. #7
    Qvintus's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    189
    My Mood
    Relaxed
    Yea exactly, I'm working on an inventory tab so it's possible to check inventories for hacky items.
    Sure it's not possible to be sure it's not hard work, but well that is up to the admin to decide.
    - If my post helped you in any way, please hit the Thanks button. It'll keep me motivated.

  9. #8
    .Zer0's Avatar
    Join Date
    Mar 2015
    Gender
    male
    Posts
    331
    Reputation
    11
    Thanks
    1,181
    My Mood
    Amused
    Quote Originally Posted by fisheyed View Post
    Nice addition to any admin tool! Now if you combine this with containers like chests etc from:

    Code:
    . Core.Cache.ContainerEntity instead of the usual .Entity for players
    You could possibly also check all chests a player own.

    If you parse via the guild id you could possibly even check guild containers connected to that person.
    If my drives wouldn't be fucked I would have provided you with my playerlist scoreboard addition with kick and ban buttons

  10. #9
    Qvintus's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    189
    My Mood
    Relaxed
    I just accidentally found out that you can view monster / animal inventories, and thus know exactly what they're gonna drop.
    Anyone know how to use the Container.BelongsTo() command? Not entirely sure Component or what this "EntityAware" is oO
    - If my post helped you in any way, please hit the Thanks button. It'll keep me motivated.

  11. #10
    .Zer0's Avatar
    Join Date
    Mar 2015
    Gender
    male
    Posts
    331
    Reputation
    11
    Thanks
    1,181
    My Mood
    Amused
    Wait what....I thought the drop is created on the ACTUAL drop so it isn't predicatable..well that is kinda stupid xD

  12. #11
    Qvintus's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    189
    My Mood
    Relaxed
    Everything appears to BelongTo the server, no idea how I check container owner.... everything I try ends up returning the server Id.
    If any figured it out pointers in the right direction is appreciated.
    - If my post helped you in any way, please hit the Thanks button. It'll keep me motivated.

  13. #12
    MrTomBlack's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Posts
    60
    Reputation
    10
    Thanks
    7
    My Mood
    Sleepy
    Dont understand this xd

  14. #13
    Qvintus's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    189
    My Mood
    Relaxed
    Quote Originally Posted by MrTomBlack View Post
    Dont understand this xd
    If you don't understand it, I suggest reading up on C# and Unity API.
    The unity community has a really great forum community that has almost answered every question you could possible ask, it's a simple matter of using google in most cases.

    As for C# there is a lot of great guides you can make use of on Youtube and you'll likely find some great written ones as well if you google.
    Here's a link to a youtube C# beginners playlist

    Enjoy.
    - If my post helped you in any way, please hit the Thanks button. It'll keep me motivated.

  15. #14
    .Zer0's Avatar
    Join Date
    Mar 2015
    Gender
    male
    Posts
    331
    Reputation
    11
    Thanks
    1,181
    My Mood
    Amused
    Quote Originally Posted by Qvintus View Post
    If you don't understand it, I suggest reading up on C# and Unity API.
    The unity community has a really great forum community that has almost answered every question you could possible ask, it's a simple matter of using google in most cases.

    As for C# there is a lot of great guides you can make use of on Youtube and you'll likely find some great written ones as well if you google.
    Here's a link to a youtube C# beginners playlist

    Enjoy.
    The standard still kicks in.
    We will help you if you are encouraged to learn and try it yourself before asking a step by step. We help with problems but you need to have tried to solve it yourself.

Similar Threads

  1. [Help Request] Is it possible to create CA (NA) hacks in Visual Studio 2010?
    By discblade128 in forum Combat Arms Help
    Replies: 3
    Last Post: 05-28-2012, 03:09 AM
  2. [Help] Is it possible to create hacks in C#?
    By Rivalo in forum Coders Lounge
    Replies: 24
    Last Post: 08-09-2011, 10:11 AM
  3. [Help Request] is it possible to create a server vindictus?
    By jHoro in forum Vindictus Help
    Replies: 10
    Last Post: 08-06-2011, 02:05 AM
  4. [Request] is it possible 2 create a no delay hack
    By 8339734 in forum Combat Arms Mod Discussion
    Replies: 9
    Last Post: 07-17-2011, 11:19 AM
  5. Is it possible to create hacks with python?
    By elitexppro in forum Programming Tutorials
    Replies: 4
    Last Post: 12-22-2009, 08:05 PM