• Getting certain CW 2.0 attachments on spawn?
    4 replies, posted
I've spent literally all day trying to figure this out and screamed "fuck" a few times really loud. Looking at Customizable Weaponry 2.0's code, I found this part is how you give a player certain attachments. [code]-- use this func when you want to send a certain amount of specific attachments to the clientfunction CustomizableWeaponry:giveAttachments(tbl, dontNotify) -- add the attachments to the player's inventory for k, v in ipairs(tbl) do if CustomizableWeaponry.registeredAttachmentsSKey[v] then self.CWAttachments[v] = true end end -- concatenate the table into a string local result = table.concat(tbl, " ") if SERVER then -- send it to the client if dontNotify then net.Start("CW20_NEWATTACHMENTS") net.WriteString(result) net.Send(self) else net.Start("CW20_NEWATTACHMENTS_NOTIFY") net.WriteString(result) net.Send(self) end end end[/code] But how exactly would I do this?? Lets use "md_acog" as an example attachment.
[CODE]CustomizableWeaponry:giveAttachments({"md_acog"}, true)[/CODE]
[QUOTE=Phoenixf129;47044029][CODE]CustomizableWeaponry:giveAttachments({"md_acog"}, true)[/CODE][/QUOTE] First of all thank you trying to help. I tried that and it didn't do anything. I looked at the base code again and noticed it's actually "giveAttachment" without an s, so I tried that but still nothing. I then tried using [code]ply:CWAttachments = {"md_acog"}[/code] and it said I need function arguments near ' = ' So I added a ' ,true ' after {"md_acog"} to get [code]ply:CWAttachments = {"md_acog"}, true[/code] Also tried [code]ply:CWAttachments = ({"md_acog"}, true)[/code] And it still returned the same error. Not using an ' = ' said that it was a table value so I must use that.
If it's saying you ned the function args, do it. I think that means instead of [lua]ply:CWAttachments[/lua] you use [lua]ply:CWAttachments()[/lua] (Obviously this wont work on its own.)
I hate to bump something this old but it was the only thing to come up and no right answer was given, I hate not leaving an answer for future people like myself who open the thread and not find an answer. This will work. It's the same method the entities you can pickup use. [CODE] CustomizableWeaponry.giveAttachments(ply, {"md_acog"}) [/CODE]
Sorry, you need to Log In to post a reply to this thread.