• Derma Button Help
    12 replies, posted
I am making this suitcase addon and I need to know how do I set the player model of a player inside of the derma menu, but the derma menu is in cl_init.lua, I know you have to hook it up but how would it look like?
See the Net Library! [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url] For example you'd want to do something like [code] net.Receive("Example", function(len, ply) ply:SetModel("whatever") end) button.DoClick = function() net.Start("Example") net.SendToServer() end [/code]
-edit- I may have mis-read the question ( If you're networking the data to the server make sure you have a list of models that can be chose; send the table KEY from client to server then have the server verify that the model can be chosen... Never trust user input ). If you're using a DModelPanel you'd use panel:SetModel( "path/to/model.mdl" ); Same if you're using SpawnIcon...
Thank you very much! [editline]31st January 2015[/editline] I got this [lua] [ERROR] addons/darkrpmodification-master/lua/entities/suit_case/cl_init.lua:40: Calling net.Start with unpooled message name [[url]http://goo.gl/qcx0y][/url] 1. Start - [C]:-1 2. DoClick - addons/darkrpmodification-master/lua/entities/suit_case/cl_init.lua:40 3. unknown - lua/vgui/dlabel.lua:206 [/lua]
In future you should read any resources you get given, instead of just copy/pasting code as you'll learn a lot more that way. Your problem is very simple to fix: [img]http://i.imgur.com/tXevUh5.png[/img]
I have this serverside: [lua] util.AddNetworkString( "Test" ) function ENT:Use( activator, caller ) net.Start( "Test" ) net.Broadcast() umsg.Start( "Menu", ply ) umsg.End() end [/lua] and this clientside: [lua] local Close = vgui.Create( "DButton" ) Close:SetParent( Panel ) Close:SetPos( 750, 0 ) Close:SetSize( 50, 30 ) Close:SetText( "" ) Close.DoClick = function() net.Receive("Test", function(len, ply) LocalPlayer():SetModel("models/player/Group01/female_01.mdl") end) Panel:Remove() end [/lua] But it won't set my player model. I used close button just for testing by the way.
You don't need to use ENT:Use() unless you want to make something for your entity, which im sure you're not creating? Remove the function ent:use() And in your doclick function do: net.Start("name") do your shit net.SendToServer() then serverside: util.AddNetworkString("name") net.Receive( "name", function( len, ply ) do your shit end )
I'm making something for an entity cause I am making a suitcase addon. And I did what you said and it won't work. I already said this[B].[/B]
[QUOTE=VortexZ;47052707]I'm making something for an entity cause I am making a suitcase addon. And I did what you said and it won't work. I already said this[B].[/B][/QUOTE] You're doing it wrong, and the guy above is right. Will help when I get on PC
[QUOTE=VortexZ;47048186]I have this serverside: [lua] util.AddNetworkString( "Test" ) function ENT:Use( activator, caller ) net.Start( "Test" ) net.Broadcast() umsg.Start( "Menu", ply ) umsg.End() end [/lua] and this clientside: [lua] local Close = vgui.Create( "DButton" ) Close:SetParent( Panel ) Close:SetPos( 750, 0 ) Close:SetSize( 50, 30 ) Close:SetText( "" ) Close.DoClick = function() net.Receive("Test", function(len, ply) LocalPlayer():SetModel("models/player/Group01/female_01.mdl") end) Panel:Remove() end [/lua] But it won't set my player model. I used close button just for testing by the way.[/QUOTE] Your setting the model Clientside bud. How about I just do it all for you eh? [code] --Serverside util.AddNetworkString("extra") util.AddNetworkString("setMdl") function ENT:Use(activator) net.Start("extra") net.Send(activator) end function SetModel(ply) ply:SetModel(--path to model) end net.Receive("setMdl",SetModel) [/code] [code] --Clientside function CockSniff() local DFrame = vgui.Create("DFrame") DFrame:SetSize(ScrW() / 2 / 2,ScrH() / 2) DFrame:SetDraggable(true) DFrame:SetTittle("Twat") DFrame:ShowCloseButton(true) DFrame:Center() local Close = vgui.Create( "DButton", DFrame ) Close:SetSize( 50, 30 ) Close:SetText( "Click me" ) Close:Center() Close.DoClick = function() net.Start("setMdl") net.SendToServer() end end net.Receive("extra",CockSniff) [/code] EDIT: I would also add a network string including the path of the player model since this is going to be multiple models.
It's not setting the model...
[QUOTE='[CLRP]extra;47052936']Your setting the model Clientside bud. How about I just do it all for you eh? [code] --Serverside util.AddNetworkString("extra") util.AddNetworkString("setMdl") function ENT:Use(activator) net.Start("extra") net.Send(activator) end function SetModel(ply) ply:SetModel(--path to model) end net.Receive("setMdl",SetModel) [/code] [code] --Clientside function CockSniff() local DFrame = vgui.Create("DFrame") DFrame:SetSize(ScrW() / 2 / 2,ScrH() / 2) DFrame:SetDraggable(true) DFrame:SetTittle("Twat") DFrame:ShowCloseButton(true) DFrame:Center() local Close = vgui.Create( "DButton", DFrame ) Close:SetSize( 50, 30 ) Close:SetText( "Click me" ) Close:Center() Close.DoClick = function() net.Start("setMdl") net.SendToServer() end end net.Receive("extra",CockSniff) [/code] EDIT: I would also add a network string including the path of the player model since this is going to be multiple models.[/QUOTE]ply in net.receive is len you'll have to add another argument before ply and you forgot brackets in the end [code] --Serverside util.AddNetworkString("extra") util.AddNetworkString("setMdl") function ENT:Use(activator) net.Start("extra") net.Send(activator) end function SetModel(len, ply) ply:SetModel(--path to model) end net.Receive("setMdl",SetModel()) [/code] [code] --Clientside function CockSniff() local DFrame = vgui.Create("DFrame") DFrame:SetSize(ScrW() / 2 / 2,ScrH() / 2) DFrame:SetDraggable(true) DFrame:SetTittle("Twat") DFrame:ShowCloseButton(true) DFrame:Center() local Close = vgui.Create( "DButton", DFrame ) Close:SetSize( 50, 30 ) Close:SetText( "Click me" ) Close:Center() Close.DoClick = function() net.Start("setMdl") net.SendToServer() end end net.Receive("extra",CockSniff()) [/code]
[QUOTE=Carlton Dance;47061253]ply in net.receive is nil you'll have to network the localplayer and you forgot brackets in the end [code] --Serverside util.AddNetworkString("extra") util.AddNetworkString("setMdl") function ENT:Use(activator) net.Start("extra") net.Send(activator) end function SetModel() local ply = net.ReadEntity() ply:SetModel(--path to model) end net.Receive("setMdl",SetModel) [/code] [code] --Clientside function CockSniff() local DFrame = vgui.Create("DFrame") DFrame:SetSize(ScrW() / 2 / 2,ScrH() / 2) DFrame:SetDraggable(true) DFrame:SetTittle("Twat") DFrame:ShowCloseButton(true) DFrame:Center() local Close = vgui.Create( "DButton", DFrame ) Close:SetSize( 50, 30 ) Close:SetText( "Click me" ) Close:Center() Close.DoClick = function() net.Start("setMdl") net.WriteEntity(LocalPlayer()) net.SendToServer() end end net.Receive("extra",CockSniff()) [/code][/QUOTE] Ah, sorry. Quickly typed that up without really going over it.
Sorry, you need to Log In to post a reply to this thread.