About Store Forum Documentation Contact
Donations:
327$/mo



Post Reply 
Adding items to your inventory in the MMO source.
Author Message
hawksprite Offline
Member

Post: #1
Adding items to your inventory in the MMO source.
I've been trying to add items to the players inventory (Like if they press P give them a set of armor) with no prevail. It either crashes when I try to view the inventory or some other issue.

Could someone give me a example of how to do this? I've been trying to add Net Item's to the Players inv list with no avail.

Thanks.
08-06-2012 01:57 AM
Find all posts by this user Quote this message in a reply
Rollcage Offline
Member

Post: #2
RE: Adding items to your inventory in the MMO source.
Show the code you are using.
08-06-2012 10:35 PM
Find all posts by this user Quote this message in a reply
hawksprite Offline
Member

Post: #3
RE: Adding items to your inventory in the MMO source.
Well i'm in the Player class of the Esenthel MMO source code.

On startup I create an object with this bit :
Code:
NetItem swordl
Item usab;

sword.create("Obj/sword");  // Example location
usab.create(sword);

Then later in the update method if they press P for instance i'll use this:
Code:
inv.items.add(usab);

I have also tried other iterations such as building objects from Game::Objs.ptrRequire("Object Location");

Then turning it into an object and trying to add it. Also with no luck.
08-07-2012 12:27 AM
Find all posts by this user Quote this message in a reply
Fex Offline
Bronze Supporter

Post: #4
RE: Adding items to your inventory in the MMO source.
You can create and load items like this

Declare the items:

Code:
Game::Item shield;
Game::Item sword;

In Player.create function put:

Code:
Game::ObjParamsPtr obj2=Game::Objs.ptrRequire("Obj/Item/Armor/Shield/lion/0.obj");
   Game.ObjParams obj3= *obj2;
   shield.create(obj3);
   shield.actor.collision(false);
  
   Game::ObjParamsPtr obj4=Game::Objs.ptrRequire("Obj/Item/Weapon/Sword/0/0.obj");
   Game.ObjParams obj5= *obj4;
   sword.create(obj5);
   sword.actor.collision(false);

I would guess you could then do: inv.items.add(sword);

But I am not sure as I don't use that, you can try it though.
(This post was last modified: 08-07-2012 07:35 PM by Fex.)
08-07-2012 07:33 PM
Find all posts by this user Quote this message in a reply
hawksprite Offline
Member

Post: #5
RE: Adding items to your inventory in the MMO source.
Ok thanks, i'll give it a try tonight and post my results.
08-07-2012 11:18 PM
Find all posts by this user Quote this message in a reply
hawksprite Offline
Member

Post: #6
RE: Adding items to your inventory in the MMO source.
I'm still having issues with it. Mostly because inv.items.add(Value) is requiring a NetItem instead of a normal Item.

I'm trying to use this

Code:
inv.items.New().create("Obj/item/Armor/Sheild/elf/sheild.obj");

But it throws an error saying the object can't be loaded when the player is created in game.
08-08-2012 06:43 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #7
RE: Adding items to your inventory in the MMO source.
sheild.obj should be shield.obj ?
08-08-2012 06:46 PM
Find all posts by this user Quote this message in a reply
hawksprite Offline
Member

Post: #8
RE: Adding items to your inventory in the MMO source.
Haha yeah I slipped up on that one.

I managed to get it to work when the player is created server side, which successfully adds the shield to my inv when I create a new character.

However If i use that client side once the character has already been made, while just running around and finding one for instance. It causes the game to crash when I try to view my inventory.
08-08-2012 07:40 PM
Find all posts by this user Quote this message in a reply
Post Reply