• Custom ply:SetBodygroup IDs?
    2 replies, posted
I am adding the option to switch bodygroups/skins to my server's pointshop. This is the code I am using: [url]http://facepunch.com/showthread.php?t=1370552&p=45503950&viewfull=1#post45503950[/url] Within that code, there's the different body pieces such as head being 1, chest being 2, etc. I have some player models that for example have horns. Does this not count as a helmet? If not, then what ID would it be identified as? I've tried numbers 1 to 20 and still nothing. Skins seem to work fine, but I had another model with a bodygroup titled wings, and I still could not seem to get it to work with any number. I've tried skins and they function just fine. It just seems to be these unusual bodygroup pieces that I cannot find an ID for. Any help is appreciated, it's not a huge issue, but I've searched and searched and found no answers. Here's my code, just in case I messed something up. [lua] ITEM.Name = 'Demon Violinist [M]' ITEM.Price = 9250 ITEM.Model = 'models/player/demon_violinist/demon_violinist.mdl' function ITEM:OnEquip(ply, modifications) if not ply._OldModel then ply._OldModel = ply:GetModel() end timer.Simple(2, function() ply:SetupHands() ply:SetModel(self.Model) ply:SetBodygroup(1, modifications.group1 or 0) end) end function Derma_Query_Dropdown( strText, strTitle, ... ) local Window = vgui.Create( "DFrame" ) Window:SetTitle( strTitle or "Message Title (First Parameter)" ) Window:SetDraggable( false ) Window:ShowCloseButton( false ) Window:SetBackgroundBlur( true ) Window:SetDrawOnTop( true ) local InnerPanel = vgui.Create( "DPanel", Window ) InnerPanel:SetDrawBackground( false ) local Text = vgui.Create( "DLabel", InnerPanel ) Text:SetText( strText or "Message Text (Second Parameter)" ) Text:SizeToContents() Text:SetContentAlignment( 5 ) Text:SetTextColor( color_white ) local ButtonPanel = vgui.Create( "DPanel", Window ) ButtonPanel:SetTall( 50 ) ButtonPanel:SetDrawBackground( false ) local NumOptions = 0 local ListBox = vgui.Create( "DComboBox", ButtonPanel ) local k = 1 while true do local Text = select( k, ... ) if Text == nil then break end local Func = select( k+1, ... ) or function() end ListBox:AddChoice(Text, Func, k == 1) NumOptions = NumOptions + 1 k = k + 2 end ListBox:SetPos(5,25) ListBox:SetWide(100) ListBox:SetTall(20) ListBox.OnSelect = function(self, index, value, data) data() Window:Close(); end local w, h = Text:GetSize() w = math.max( w, ButtonPanel:GetWide() ) Window:SetSize( w + 50, h + 25 + 45 + 10 ) Window:Center() InnerPanel:StretchToParent( 5, 25, 5, 45 ) Text:SetPos(0,5) Text:CenterHorizontal() ButtonPanel:StretchToParent( 5, 25, 5, 5 ) ListBox:SetWide(ButtonPanel:GetWide()) ListBox:CenterHorizontal() ListBox:CenterVertical() Window:MakePopup() if ( NumOptions == 0 ) then Window:Close() Error( "Derma_Query: Created Query with no Options!?" ) return nil end return Window end function ITEM:OnHolster(ply) if ply._OldModel then ply:SetModel(ply._OldModel) end end function ITEM:Modify(modifications) Derma_Query_Dropdown("Do you want demon horns?", "Model Modifier", "Yes", function() modifications.group1 = 0 -- Horns PS:SendModifications(self.ID, modifications) --Makes sure the pointshop knows to apply changes end, "No", function() modifications.group1 = 1 -- No horns PS:SendModifications(self.ID, modifications) end) print("modify") end function ITEM:OnModify(ply, modifications) self:OnHolster(ply) self:OnEquip(ply, modifications) -- adds the item back again, with new mods end [/lua] In another thread I was told that each "ID" is unique for each model, and it can be retrieved via lua. I wouldn't know how to do that exactly though, I'm fairly new to lua and gmod in general. Any assistance is greatly appreciated.
Find the icon for the model in the sandbox spawn menu, right click it and go to edit icon. If I recall correctly, you can find all the bodygroups there.
[QUOTE=Jeezy;46115017]Find the icon for the model in the sandbox spawn menu, right click it and go to edit icon. If I recall correctly, you can find all the bodygroups there.[/QUOTE] Won't that only give me the name, not the ID to identify that body piece?
Sorry, you need to Log In to post a reply to this thread.