Entity.SetModel

From GMod Wiki

Jump to: navigation, search
Function
Syntax Entity:SetModel( String modelname )
Description:
Sets the model of the entity. This is used both in scripted entities and before creating hard-coded entities (like prop_physics).
Returns: nil
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.SetModel]Entity.SetModel [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionCreates a prop and sets the model before spawning it.
Used onNewerServer.png
Code
prop=ents.Create("prop_physics")
prop:SetModel("models/props_c17/oildrum001.mdl")
prop:SetPos(Vector(0,0,0))
prop:Spawn()
OutputN/A


DescriptionSets the model of a scripted entity in the initilization function.
Used onNewerServer.png
Code
function ENT:Initialize()
    self:SetModel("models/props_c17/oildrum001.mdl")
end
OutputN/A


Additional Notes

  1. First off it will search the garrysmod folder.
  2. After that it will check the currently active gamemode's content folder.
  3. If the first two options fail it will also search the GCFs of your installed steam games if the model isn't found in the Garry's Mod folder.

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox