undo.AddFunction
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.
Function argument(s):
2 vararg ... - What was passed after the function callback argument.
Function return value(s):
1 boolean result - Returning
false
will mark execution of this function as "failed", meaning that the undo might be skipped if no other entities are removed by it. This is useful when for example an entity you want to access is removed therefore there's nothing to do.Example
This example creates a prop_physics, and adds it to the players undo list. A message will be printed to console about it.
Output: PlayerName removed prop models/props_junk/wood_crate001a.mdl, code: 556
will be printed