Entity.GetNetworkedEntity

From GMod Wiki

Jump to: navigation, search
Function
Syntax Entity:GetNetworkedEntity( Var index [, Entity default] )
Description:
Returns a networked Entity reference in this entity set with Entity:SetNetworkedEntity with the given index.
Returns: Entity
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.GetNetworkedEntity]Entity.GetNetworkedEntity [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionWhen you die, it will save your killer.
Used onNewerShared.png
Code
local function RunWhenImDead( victim, weapon, killer )
	victim:SetNetworkedEntity("mykiller",killer) --Saving the last killer.
end
hook.Add("PlayerDeath","RunnedWhenYouDies",RunWhenImDead)
 
local function ShowKillersClass( ply, command, args )
	local get_killer = ply:GetNetworkedEntity("mykiller") --We got the last killer.
	local killers_class = get_killer:GetClass() --And here is his class.
 
	ply:ChatPrint("Your killer was a "..killers_class) --Now print the class in his chat.
end
concommand.Add("show_my_killer",ShowKillersClass)
OutputNow when you type show_my_killer in your console, it will print the killer's class in your chat.


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox