iAxel Posted January 15, 2015 Share Posted January 15, 2015 In your code is a function of creating a backpack addEventHandler('onPlayerJoin', root, function () Backpack:create(source) end ) But do not have delete function backpack addEventHandler('onPlayerQuit', root, function () --Backpack Delete end ) Help with function delete backpack Example function BackPack:delete(player) Backpack.list[player] = nil setmetatable(self, self) return true end I did the right function? Link to comment
iAxel Posted January 16, 2015 Share Posted January 16, 2015 Remove 4th line. So Much? function BackPack:delete(player) Backpack.list[player] = nil return true end Link to comment
Et-win Posted January 16, 2015 Share Posted January 16, 2015 He said remove the 4th line. return true Link to comment
Cadu12 Posted January 16, 2015 Share Posted January 16, 2015 Yes, that's right, Monson. Link to comment
iAxel Posted January 17, 2015 Share Posted January 17, 2015 Yes, that's right, Monson. Thanks you! Link to comment
iAxel Posted January 17, 2015 Share Posted January 17, 2015 Yes, that's right, Monson. See if the backpack is created so function Backpack:create(player, slots) if (Backpack.list[player]) then return Backpack.list[player] end local new = { items = {}, slots = slots or 100, owner = player } setmetatable(new, {__index = Backpack}) Backpack.list[player] = new return new end And thus is deleted function Backpack:delete(player) Backpack.list[player] = nil return true end Maybe I should null and self.items = nil self.slots = nil self.owner = nil --or destroyElement(self.items) destroyElement(self.slots) destroyElement(self.owner) --or destroyElement(self) And thus should delete the backpack? function Backpack:delete(player) self = nil --or destroyElement(self) Backpack.list[player] = nil return true end Link to comment
MTA Team botder Posted January 17, 2015 MTA Team Share Posted January 17, 2015 The backpack is not an element, you can't use destroyElement on it. Anyway, that should be enough to delete the backpack: Backpack.list[player] = nil Link to comment
iAxel Posted January 18, 2015 Share Posted January 18, 2015 The backpack is not an element, you can't use destroyElement on it.Anyway, that should be enough to delete the backpack: Backpack.list[player] = nil Okay, thank you very much Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now