• Player Model Derma Menu
    0 replies, posted
My friend made a code for me. It's a derma menu that has a selection of player models that you can choose from. When you click on a player model, you become that player model and the menu closes automatically. But when you die or respawn, you change back to your default player model. Is there anyway to stay that player model when you die or respawn? Here is the code: [CODE]if SERVER then concommand.Add( "Set_Model", function( p, c, a ) if p:Alive() then p:SetModel( "models/player/" .. a[1] .. ".mdl" ); end; if not p.Model then p.Model = p:GetModel(); end; end ); hook.Add( "PlayerSpawn", "SetPlayerModel", function( p, c, a ) if p:Alive() then p:SetModel( p.Model ); end; end ); function MyMenu( ply ) --Start the function RunConsoleCommand( "model_menu" ) end --End the function hook.Add("ShowSpare2", "MyHook", MyMenu) --Add the hook "ShowHelp" so it opens with F1 end if CLIENT then local models = { "swat", "urban", "gasmask", "riot", "leet", "phoenix", "guerilla", "arctic"}; concommand.Add( "model_menu", function() local Menu = vgui.Create( "DFrame" ); Menu:SetSize( 400, 400 ); Menu:SetTitle( "Choose a model" ); Menu:SetDraggable( false ); Menu:SetVisible( true ) Menu:MakePopup() Menu:Center() local List = vgui.Create( "DPanelList", Menu) List:SetPos( 5, 20 ); List:SetSize( 390, 375 ) List:EnableHorizontal( true ) List:EnableVerticalScrollbar( true ) for k, v in pairs( models ) do local Model = vgui.Create( "SpawnIcon" ) Model:SetModel( "models/player/".. v .. ".mdl" ) Model:SetToolTip( "Models/player/" .. v .. ".mdl" ) Model.DoClick = function() RunConsoleCommand( "Set_Model", v ) Menu:Close() end List:AddItem( Model ); end; end ); usermessage.Hook("Menu", Menu) end;[/CODE] Any help is appreciated.
Sorry, you need to Log In to post a reply to this thread.