View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:45 am



Reply to topic  [ 6 posts ] 
 How to get actor's inventory and transfer items 
Author Message
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post How to get actor's inventory and transfer items
Is it possible to read every weapon in an actor's inventory and give another actor all of those weapons?


Sun Oct 18, 2009 5:19 pm
Profile
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Re: How to get actor's inventory and transfer items
Code:
   x = self:Inventory() --Grab first thing.
   if x ~= nil then
      if x.ClassName == "HDFirearm" then -- Copy weap
         self.tospawn:AddInventoryItem(CreateHDFirearm(x.PresetName))
      elseif x.ClassName == "Held Device" then
         self.tospawn:AddInventoryItem(CreateHeldDevice(x.PresetName))
      elseif x.ClassName == "TDExplosive" then
         self.tospawn:AddInventoryItem(CreateTDExplosive(x.PresetName))
      end
      self:SwapNextInventory(x,false)
      z = self:Inventory()
      while z ~= nil and z.PresetName ~= x.PresetName do
         if z.ClassName == "HDFirearm" then -- Copy weap
            self.tospawn:AddInventoryItem(CreateHDFirearm(z.PresetName))
         elseif z.ClassName == "Held Device" then
            self.tospawn:AddInventoryItem(CreateHeldDevice(z.PresetName))
         elseif z.ClassName == "TDExplosive" then
            if z:IsInGroup("Zombies") then
               self.tospawn:AddInventoryItem(CreateTDExplosive(z.PresetName, "Zombies.rte"))
            else
               self.tospawn:AddInventoryItem(CreateTDExplosive(z.PresetName))
            end
         end
         self:SwapNextInventory(z,false) --Move on
         z = self:Inventory() -- Get next thing
      end
   end

Taken from Zombies 09, I think mail made the original.


Sun Oct 18, 2009 7:16 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: How to get actor's inventory and transfer items
Arg, getting some issues. First off, the console says that "Inventory" is not a valid method. Second, would this work on an actor that just died?


Sun Oct 18, 2009 7:51 pm
Profile
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Re: How to get actor's inventory and transfer items
I don't think it would, it may also be the source of your problem, but I don't know how the function works (I think it gets the weapon the actor is currently holding or something).


Sun Oct 18, 2009 8:03 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: How to get actor's inventory and transfer items
When the script is in the "Update" function, the sound of weapons switching is heard, so it probably gets the current weapon being held, switches to another weapon, and repeates.


Sun Oct 18, 2009 8:23 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Wed Sep 05, 2007 4:14 am
Posts: 3966
Location: Canadida
Reply with quote
Post Re: How to get actor's inventory and transfer items
CaveCricket48 wrote:
When the script is in the "Update" function, the sound of weapons switching is heard, so it probably gets the current weapon being held, switches to another weapon, and repeates.

Trying to fix the phoenix dilemma?
You know, the 'respawn, goddammit I have no guns, the guns get squashed, and ♥♥♥♥, the guns are destroyed' dilemma?

If you look at the whole enter process of the 'actor randomization' code, it figures out what the actor is holding, deletes it, and then gives the inventory to the newly spawned actor flawlessly.

Now you just need the actor to gib, and the rest is done for you.
Your code just makes the actor gib into itself, and give it the respawner.
Just make it so that the inventory gets recorded, gib the actor and it's inventory, create a new actor, and give it the old actor's inventory, and make sure there is only one respawner in it's inventory.


Sun Oct 18, 2009 11:08 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.035s | 13 Queries | GZIP : Off ]