Entity.SetVar

From GMod Wiki

Revision as of 13:51, 25 July 2010 by Overv (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax Entity:SetVar( Var index,Var value )
Description:
Sets Entity:GetTable()[index] to value.
Returns: nil
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.SetVar]Entity.SetVar [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionSpawn a ragdoll at the player's position and set it's var "ragdollname" to the player's name.
Used onNewerServer.png
Code
local ent = ents.Create( "prop_ragdoll" )
		if ent:IsValid() then
			ent:SetModel( "models/eli.mdl" )
			ent:SetKeyValue( "origin", ply:GetPos().x .. " " .. ply:GetPos().y .. " " .. ply:GetPos().z )
			ent:Spawn()
			ent:Activate() 
 
			ent:SetVar("ragdollname",ply:Nick().."")
OutputN/A



Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox