DModelPanel.SetModel

From GMod Wiki

Jump to: navigation, search
Function
Syntax DModelPanel.SetModel( String ModelPath )
Description:
Sets the clientside model used to draw the panel
Returns: nil
In Object: DModelPanel
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=DModelPanel.SetModel]DModelPanel.SetModel [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionSets the model of a DModelPanel to the blue trash bin
Used onNewerClient.png
Code
ModelPanel:SetModel("models/props_borealis/bluebarrel001.mdl")
OutputA camera look of a blue trash bin

DescriptionRedefines the SetModel code to allow you to specify the animation it will have.
Used onNewerClient.png
Code
ModelPanel.SetModel = function( self, strModelName, seq )
	// Note - there's no real need to delete the old
	// entity, it will get garbage collected, but this is nicer.
	if ( IsValid( self.Entity ) ) then
			self.Entity:Remove()
			self.Entity = nil              
	end
 
	// Note: Not in menu dll
	if ( !ClientsideModel ) then return end
 
	self.Entity = ClientsideModel( strModelName, RENDER_GROUP_OPAQUE_ENTITY )
	if ( !IsValid(self.Entity) ) then return end
 
	self.Entity:SetNoDraw( true )
 
	local iSeq = 0
	if seq then
		iSeq = self.Entity:LookupSequence( seq )
	end
	if (iSeq <= 0) then iSeq = self.Entity:LookupSequence( "walk_all" ) end
	if (iSeq <= 0) then iSeq = self.Entity:LookupSequence( "WalkUnarmed_all" ) end
	if (iSeq <= 0) then iSeq = self.Entity:LookupSequence( "walk_all_moderate" ) end
 
	if (iSeq > 0) then self.Entity:ResetSequence( iSeq ) end
end
OutputThere is now a second argument, sequence, which you can use to set it's animation. (hint, try "run_all")
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox