Garry's Mod Wiki

undo.AddFunction

undo.AddFunction( function func, vararg arguments )

Description

Adds a function to call when the current undo block is undone. Note that if an undo has a function, the player will always be notified when this undo is performed, even if the entity it is meant to undo no longer exists.

Arguments

1 function func
The function to call. First argument will be the Undo Structure, all subsequent arguments will be what was passed after this function in the argument below.
2 vararg arguments
Arguments to pass to the function (after the undo info table)

Example

This example creates a prop_physics, and adds it to the players undo list. A message will be printed to console about it.

prop = ents.Create("prop_physics") prop:SetModel("models/props_junk/wood_crate001a.mdl") prop:Spawn() undo.Create("prop") undo.AddEntity(prop) undo.AddFunction(function( tab, arg2 ) print( tab.Owner:GetName() .. " removed prop " .. tab.Entities[1]:GetModel() .. ", code: " .. arg2 ) end, 556 ) undo.SetPlayer(ply) undo.Finish()
Output: "PlayerName removed prop models/props_junk/wood_crate001a.mdl, code: 556" will be printed

Page Links


Special Pages


Wikis

?

Render Time: 126ms

DB GetPage 54
Generate Html 9
SaveChanges (1) 42
Render Body 0
Render Sidebar 18