• Lua scripting problem! Trying to edit bodygroups on playermodels (pointshop)
    2 replies, posted
Ok, so I'm running a gmod Jailbreak 7 server, and I'm trying to be able to edit the bodygroups of a playermodel I have in Pointshop. Here is the .Lua I'm currently using. And I'm using this addon: [url]http://steamcommunity.com/sharedfile.../?id=546524865[/url] I'm new to coding so most of the time I've no idea what I'm doing. So can someone pls help me! ITEM.Name = 'Black Rock Shooter' ITEM.Price = 1000 ITEM.Model = 'models/jazzmcfly/brs/brs.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:SetSkin(1) ply:SetBodygroup(1, modifications.group1 or 0) --Hood ply:SetBodygroup(2, modifications.group2 or 0) --Coat ply:SetBodygroup(3, modifications.group3 or 0) --Bottom ply:SetBodygroup(4, modifications.group4 or 0) --Flame 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("Choose Hood", "", "Hood Down", function() modifications.group1 = 0 -- Default Hood PS:SendModifications(self.ID, modifications) --Makes sure the pointshop knows to apply changes end, "Hood", function() modifications.group1 = 1 -- Hood PS:SendModifications(self.ID, modifications) end, "No Hood", function() modifications.group1 = 2 -- No Hood PS:SendModifications(self.ID, modifications) end) Derma_Query_Dropdown("Choose Coat", "", "Coat", function() modifications.group2 = 0 -- Default Coat PS:SendModifications(self.ID, modifications) --Makes sure the pointshop knows to apply changes end, "No Coat", function() modifications.group2 = 2 -- no Coat PS:SendModifications(self.ID, modifications) end) Derma_Query_Dropdown("Choose Bottom", "", "Bottom", function() modifications.group3 = 0 -- Default Bottom PS:SendModifications(self.ID, modifications) --Makes sure the pointshop knows to apply changes end, "No Bottom", function() modifications.group3 = 1 -- No Bottom PS:SendModifications(self.ID, modifications) end) Derma_Query_Dropdown("Choose Flame", "", "No Flame", function() modifications.group4 = 0 -- No Flame PS:SendModifications(self.ID, modifications) --Makes sure the pointshop knows to apply changes end, "Flame", function() modifications.group4 = 1 -- Flame 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
Please use code tags
[QUOTE=HeyBanditoz;50683746]Please use code tags[/QUOTE] You mean like this? [CODE]ITEM.Name = 'Black Rock Shooter' ITEM.Price = 1000 ITEM.Model = 'models/jazzmcfly/brs/brs.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:SetSkin(1) ply:SetBodygroup(1, modifications.group1 or 0) --Hood ply:SetBodygroup(2, modifications.group2 or 0) --Coat ply:SetBodygroup(3, modifications.group3 or 0) --Bottom ply:SetBodygroup(4, modifications.group4 or 0) --Flame 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("Choose Hood", "", "Hood Down", function() modifications.group1 = 0 -- Default Hood PS:SendModifications(self.ID, modifications) --Makes sure the pointshop knows to apply changes end, "Hood", function() modifications.group1 = 1 -- Hood PS:SendModifications(self.ID, modifications) end, "No Hood", function() modifications.group1 = 2 -- No Hood PS:SendModifications(self.ID, modifications) end) Derma_Query_Dropdown("Choose Coat", "", "Coat", function() modifications.group2 = 0 -- Default Coat PS:SendModifications(self.ID, modifications) --Makes sure the pointshop knows to apply changes end, "No Coat", function() modifications.group2 = 2 -- no Coat PS:SendModifications(self.ID, modifications) end) Derma_Query_Dropdown("Choose Bottom", "", "Bottom", function() modifications.group3 = 0 -- Default Bottom PS:SendModifications(self.ID, modifications) --Makes sure the pointshop knows to apply changes end, "No Bottom", function() modifications.group3 = 1 -- No Bottom PS:SendModifications(self.ID, modifications) end) Derma_Query_Dropdown("Choose Flame", "", "No Flame", function() modifications.group4 = 0 -- No Flame PS:SendModifications(self.ID, modifications) --Makes sure the pointshop knows to apply changes end, "Flame", function() modifications.group4 = 1 -- Flame 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[/CODE]
Sorry, you need to Log In to post a reply to this thread.