Data Realms Fan Forums http://45.55.195.193/ |
|
Deleting an item in inventory? [SOLVED] http://45.55.195.193/viewtopic.php?f=73&t=21477 |
Page 1 of 1 |
Author: | ramonimbao [ Sat Feb 12, 2011 2:33 am ] |
Post subject: | Deleting an item in inventory? [SOLVED] |
How do you delete an item in the inventory of an actor? I've figured out how to delete the current item being held, but not how to delete it when it's in their inventory. Or maybe even cycling through the inventory until you reach the item, then delete it? |
Author: | Coops [ Sat Feb 12, 2011 3:06 am ] |
Post subject: | Re: Deleting an item in inventory? |
I think something like this should work: Code: for actor in MovableMan.Actors do self.weap = <Weapon Name Here> if actor:HasObject(self.weap) then self.weap.ToDelete = true end end I'm not entirely sure if that would work though, haven't tested this. |
Author: | ramonimbao [ Sat Feb 12, 2011 3:15 am ] |
Post subject: | Re: Deleting an item in inventory? |
I think for your code, self.weap should be pointing to an MO, so I don't think this'll actually work. This has been my code so far: Code: for actor in MovableMan.Actors do if actor:IsPlayerControlled() == true then for i = 1, MovableMan:GetMOIDCount()-1 do gun=MovableMan:GetMOFromID(i); if gun.PresetName == "M16" and gun.RootID == actor.ID then gun.ToDelete = true end end end end It deletes the weapon you're currently holding if it's an M16, but does not delete ones in the inventory. |
Author: | none [ Sat Feb 12, 2011 5:41 pm ] |
Post subject: | Re: Deleting an item in inventory? |
Anything to do with CC inventory is buggy as hell and very likely to screw up your game. but anyway Code: for actor in MovableMan.Actors do if actor:IsPlayerContolled() then local weap = actor:Inventory(); if weap.PresetName == "weapon name" then self:SwapNextInventory(nil, false); else self:SwapNextInventory(weap, false); end end end |
Author: | ramonimbao [ Sun Feb 13, 2011 1:03 am ] |
Post subject: | Re: Deleting an item in inventory? |
Awesome! Exactly what I needed! Thanks! |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |