Cpanel Help, trying to get DModelPanel to show up.
8 replies, posted
STOOL code below, I think i have something missing someplace but what I am doing is adding a dynamic preview window the this STOOLs spawn menu. I have little experience in building CPanels and the like so if someone can look over this code and possibly fix it where needed and please make footnotes on what you did please so i can use for future reference.
Much thanks.
-Melinda - ESN - SB/LS/RD4 team
[code]
TOOL.Category = 'Tiberium'
TOOL.Name = 'Storage Devices'
TOOL.Command = nil
TOOL.ConfigName = ''
if (CLIENT and GetConVarNumber("RD_UseLSTab") == 1) then TOOL.Tab = "Life Support" end
TOOL.ClientConVar['type'] = 'rawtibstorage'
TOOL.ClientConVar['model'] = 'models/Tiberium/small_tiberium_storage.mdl'
cleanup.Register('tibstor')
if ( CLIENT ) then
language.Add( 'Tool_tibstor_name', 'Tiberium Storage Devices' )
language.Add( 'Tool_tibstor_desc', 'Create Storage Devices attached to any surface.' )
language.Add( 'Tool_tibstor_0', 'Left-Click: Spawn a Device. Right-Click: Repair Device.' )
language.Add( 'Undone_tibstor', 'Storage Device Undone' )
language.Add( 'Cleanup_tibstor', 'Tiberium Storage Device' )
language.Add( 'Cleaned_tibstor', 'Cleaned up all Storage Devices' )
language.Add( 'SBoxLimit_tibstor', 'Maximum Storage Devices Reached' )
end
if not ( RES_DISTRIB == 2 ) then Error("Please Install Resource Distribution 2 Addon.'" ) return end
local tibstor = {}
if (SERVER) then
tibstor.rawtibstorage = function( ply, ent, system_type, system_class, model )
local rtable, maxhealth, mass = {}, 0, 0
if ( model == "models/Tiberium/small_tiberium_storage.mdl" ) then
maxhealth = 600
mass = 20
RD_AddResource(ent, "Raw Green Tiberium", 1000)
RD_AddResource(ent, "Raw Blue Tiberium", 1000)
RD_AddResource(ent, "Raw Red Tiberium", 1000)
elseif ( model == "models/Tiberium/medium_tiberium_storage.mdl" ) then
maxhealth = 1200
mass = 200
RD_AddResource(ent, "Raw Green Tiberium", 3000)
RD_AddResource(ent, "Raw Blue Tiberium", 3000)
RD_AddResource(ent, "Raw Red Tiberium", 3000)
elseif ( model == "models/Tiberium/large_tiberium_storage.mdl" ) then
maxhealth = 3000
mass = 500
RD_AddResource(ent, "Raw Green Tiberium", 9000)
RD_AddResource(ent, "Raw Blue Tiberium", 9000)
RD_AddResource(ent, "Raw Red Tiberium", 9000)
end
LS_RegisterEnt(ent, "Storage")
return rtable, maxhealth, mass
end
tibstor.chemtibstorage = function( ply, ent, system_type, system_class, model )
local rtable, maxhealth, mass = {}, 0, 0
if ( model == "models/Tiberium/small_chemical_storage.mdl" ) then
maxhealth = 600
mass = 20
RD_AddResource(ent, "ChemicalTiberium", 1000)
elseif ( model == "models/Tiberium/medium_chemical_storage.mdl" ) then
maxhealth = 1200
mass = 200
RD_AddResource(ent, "ChemicalTiberium", 3000)
elseif ( model == "models/Tiberium/large_chemical_storage.mdl" ) then
maxhealth = 3000
mass = 500
RD_AddResource(ent, "ChemicalTiberium", 9000)
end
LS_RegisterEnt(ent, "Storage")
return rtable, maxhealth, mass
end
tibstor.energycell = function( ply, ent, system_type, system_class, model )
local rtable, maxhealth, mass = {}, 0, 0
if ( model == "models/Tiberium/small_energy_cell.mdl" ) then
maxhealth = 600
mass = 20
RD_AddResource(ent, "energy", 1000)
elseif ( model == "models/Tiberium/medium_energy_cell.mdl" ) then
maxhealth = 1200
mass = 200
RD_AddResource(ent, "energy", 3000)
elseif ( model == "models/Tiberium/large_energy_cell.mdl" ) then
maxhealth = 3000
mass = 500
RD_AddResource(ent, "energy", 9000)
end
LS_RegisterEnt(ent, "Storage")
return rtable, maxhealth, mass
end
tibstor.liquidtibstor = function( ply, ent, system_type, system_class, model )
local rtable, maxhealth, mass = {}, 0, 0
if ( model == "models/Tiberium/small_chemical_storage.mdl" ) then
maxhealth = 600
mass = 20
RD_AddResource(ent, "LiquidTiberium", 1000)
elseif ( model == "models/Tiberium/medium_chemical_storage.mdl" ) then
maxhealth = 1200
mass = 200
RD_AddResource(ent, "LiquidTiberium", 3000)
elseif ( model == "models/Tiberium/large_chemical_storage.mdl" ) then
maxhealth = 3000
mass = 500
RD_AddResource(ent, "LiquidTiberium", 9000)
end
LS_RegisterEnt(ent, "Storage")
return rtable, maxhealth, mass
end
tibstor.refinedtibstor = function( ply, ent, system_type, system_class, model )
local rtable, maxhealth, mass = {}, 0, 0
if ( model == "models/Tiberium/small_tiberium_storage.mdl" ) then
maxhealth = 600
mass = 20
RD_AddResource(ent, "RefinedTiberium", 1000)
elseif ( model == "models/Tiberium/medium_tiberium_storage.mdl" ) then
maxhealth = 1200
mass = 200
RD_AddResource(ent, "RefinedTiberium", 3000)
elseif ( model == "models/Tiberium/large_tiberium_storage.mdl" ) then
maxhealth = 3000
mass = 500
RD_AddResource(ent, "RefinedTiberium", 9000)
end
LS_RegisterEnt(ent, "Storage")
return rtable, maxhealth, mass
end
tibstor.gas_stor = function( ply, ent, system_type, system_class, model )
local rtable, maxhealth, mass = {}, 0, 0
if ( model == "models/Tiberium/small_chemical_storage.mdl" ) then
maxhealth = 600
mass = 20
RD_AddResource(ent, "Tiberium Gas", 1000)
elseif ( model == "models/Tiberium/medium_chemical_storage.mdl" ) then
maxhealth = 1200
mass = 200
RD_AddResource(ent, "Tiberium Gas", 3000)
elseif ( model == "models/Tiberium/large_chemical_storage.mdl" ) then
maxhealth = 3000
mass = 500
RD_AddResource(ent, "Tiberium Gas", 9000)
end
LS_RegisterEnt(ent, "Storage")
return rtable, maxhealth, mass
end
end
local tibstor_models = {
{ 'Small Raw Tiberium Storage', 'models/Tiberium/small_tiberium_storage.mdl', 'rawtibstorage' },
{ 'Medium Raw Tiberium Storage', 'models/Tiberium/medium_tiberium_storage.mdl', 'rawtibstorage' },
{ 'Large Raw Tiberium Storage', 'models/Tiberium/large_tiberium_storage.mdl', 'rawtibstorage' },
{ 'Small Chemical Tiberium Storage', 'models/Tiberium/small_chemical_storage.mdl', 'chemtibstorage' },
{ 'Medium Chemical Tiberium Storage', 'models/Tiberium/medium_chemical_storage.mdl', 'chemtibstorage' },
{ 'Large Chemical Tiberium Storage', 'models/Tiberium/large_chemical_storage.mdl', 'chemtibstorage' },
{ 'Small Energy Cell', 'models/Tiberium/small_energy_cell.mdl', 'energycell' },
{ 'Medium Energy Cell', 'models/Tiberium/medium_energy_cell.mdl', 'energycell' },
{ 'Large Energy Cell', 'models/Tiberium/large_energy_cell.mdl', 'energycell' },
{ 'Small Liquid Tiberium Storage', 'models/Tiberium/small_chemical_storage.mdl', 'liquidtibstor' },
{ 'Medium Liquid Tiberium Storage', 'models/Tiberium/medium_chemical_storage.mdl', 'liquidtibstor' },
{ 'Large Liquid Tiberium Storage', 'models/Tiberium/large_chemical_storage.mdl', 'liquidtibstor' },
{ 'Small Refined Tiberium Storage', 'models/Tiberium/small_tiberium_storage.mdl', 'refinedtibstor' },
{ 'Medium Refined Tiberium Storage', 'models/Tiberium/medium_tiberium_storage.mdl', 'refinedtibstor' },
{ 'Large Refined Tiberium Storage', 'models/Tiberium/large_tiberium_storage.mdl', 'refinedtibstor' },
{ 'Small Tiberium Gas Storage', 'models/Tiberium/small_chemical_storage.mdl', 'gas_stor' },
{ 'Medium Tiberium Gas Storage', 'models/Tiberium/medium_chemical_storage.mdl', 'gas_stor' },
{ 'Large Tiberium Gas Storage', 'models/Tiberium/large_chemical_storage.mdl', 'gas_stor' },
}
function TOOL.BuildCPanel( CPanel )
// HEADER
CPanel:AddControl( "Header", { Text = "#Tool_tibstor_name", Description = "#Tool_tibstor_desc" } )
CPanel:SetSpacing( 10 )
CPanel:SetName( "Preview" )
local ModelPre = vgui.Create( "DModelPanel" )
ModelPre:SetSize( 100,200 )
ModelPre:SetModel( tibstor_models )
ModelPre:SetCamPos( Vector( 246 , 235 , 143 ) )
ModelPre:SetLookAt( Vector( -246 , -235 , -143 ) )
CPanel:AddItem( ModelPre )
local function ESN_Tibstor_Preview( tibstor_models )
ModelPre.Entity:SetModel( tibstor_models )
DModelPanel doesn't like to render while it's height it greater than it's width. I haven't really messed around to much with it for a while, but maybe try using an equal width and height and use the stencil if you really need it to be taller than it is wide.
yeah its a typo i made. its 100,100
Might just not be looking at it, try setting the lookat to 0, 0, 0.
ummm this is a TOOL menu not and entity...there is not lookat in there
oh yeah i found it, changed it and still nothing.
Ok what this is supposed to be doing is placing a preview image in the tools menu and when you click on a storage device the image changes in the preview.
Also a re-skining option but thats later and i cant figure out the skin lists for this addon...I know theres 7 of them but the option only allows me to choose the first 3.
thats to object of it anyways but its not doing what i need it to do. I still have the original tool menu with the individual buttons in it..
[editline]15th October 2010[/editline]
ok i took alot of that code out to set the skin and left this:
[code]
function TOOL.BuildCPanel( window )
window:SetSpacing( 10 )
local window = vgui.Create( "DModelPanel" )
window:SetSize( 100,200 )
window:SetCamPos( Vector( 246 , 235 , 143 ) )
window:SetLookAt( Vector( -246 , -235 , -143 ) )
window:SetTitle( "Tiberium Storage Preview" )
local icon = vgui.Create( "DModelPanel", window )
icon:SetModel(ent:GetModel())
panel:AddItem( window )
end
[/code]
I got that off the wiki but i wish the wiki went into more explanation and had more examples of the code per function...
any help would be greatly appreciated.
Ok new problem... for the life of me I cannot get the models centered on the panel.
[IMG]http://i213.photobucket.com/albums/cc110/Adriel_G/exe1.jpg[/IMG]
[code]
local playmdl = vgui.Create('DButton')
playmdl:SetParent(DPanel1)
playmdl:SetSize(85, 25)
playmdl:SetPos(500, 160)
playmdl:SetText('Your Model')
playmdl.DoClick = function()
local window = vgui.Create( "DFrame" )
window:SetSize( 200,200 )
window:Center()
window:SetDraggable( false )
window:ShowCloseButton(true)
window:SetDeleteOnClose(false)
window:SetTitle( "Your 3D Player Model" )
window:MakePopup()
local icon = vgui.Create( "DModelPanel", window )
icon:SetModel( LocalPlayer():GetModel() )
icon:SetSize( 200, 100 )
icon:SetCamPos( Vector( 50, 50, 50 ) )
icon:SetLookAt( Vector( 40, 0, 80 ) )
end
end
[/code]
help!!!
Sorry, you need to Log In to post a reply to this thread.