Cloning Inventory?

Discussions about Coding and Scripting
Post Reply
TehDevil
Novice
Posts: 5
Joined: Fri Sep 17, 2010 3:18 pm

Cloning Inventory?

Post by TehDevil »

Hey guys!
I'm working on something here.

I have a custom pawn, and you see, I want this pawn to look exactly like us. So I've set his owner as us, the player, and made his skin according to us.

Now the problem here is, I want the pawn to have our inventory as well.
Is there a way I can make it so the pawn has our inventory by cloning our own inventory? and without deleting our own inventory?

THANKS. :mrgreen:
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Cloning Inventory?

Post by JackGriffin »

Sure, just iterate through inventory and spawn a copy on the actor you want to receive it. Pinata code will tell you how to iterate the inventory and then normal pickup code will show you how to add it to inventory.

I'm kinda interested where you are going with this.
So long, and thanks for all the fish
User avatar
Sp0ngeb0b
Adept
Posts: 376
Joined: Wed Feb 13, 2008 9:16 pm
Location: Cologne
Contact:

Re: Cloning Inventory?

Post by Sp0ngeb0b »

Considering you are speaking about the Inventory (and not the Weapons), you simply have to copy the Inventory list of the PlayerPawn to your custom Pawn.
That's a good way to start:

Code: Select all

local Inventory Inv, Copy;

for(Inv=Owner.Inventory; Inv!=None; Inv=Inv.Inventory )   {
  Copy = spawn(Inv.Class,Self);
  if(Copy != none) {
     Copy.RespawnTime = 0.0;
     Copy.bHeldItem = true;
     Copy.bTossedOut = false;
    
     // Here you can adjust specific values just as ammo
  
    Copy.GiveTo(Owner);
  }
}
Please remember that most Pawns will not be able to use the Inventory as a PlayerPawn is supposed to.
Website, Forum & UTStats

Image
******************************************************************************
Nexgen Server Controller || My plugins & mods on GitHub
******************************************************************************
Post Reply