Data Realms Fan Forums http://forums.datarealms.com/ |
|
How to get actor's inventory and transfer items http://forums.datarealms.com/viewtopic.php?f=73&t=16878 |
Page 1 of 1 |
Author: | CaveCricket48 [ Sun Oct 18, 2009 5:19 pm ] |
Post subject: | 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? |
Author: | Roon3 [ Sun Oct 18, 2009 7:16 pm ] |
Post subject: | 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. |
Author: | CaveCricket48 [ Sun Oct 18, 2009 7:51 pm ] |
Post subject: | 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? |
Author: | Roon3 [ Sun Oct 18, 2009 8:03 pm ] |
Post subject: | 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). |
Author: | CaveCricket48 [ Sun Oct 18, 2009 8:23 pm ] |
Post subject: | 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. |
Author: | Foa [ Sun Oct 18, 2009 11:08 pm ] |
Post subject: | 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. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |