Garry's Mod Wiki

Revision Difference

GM:CanUndo#527796

<function name="CanUndo" parent="GM" type="hook"> <ishook>yes</ishook> <description>Called whenever a players tries to undo.</description> <realm>Server</realm> <args> <arg name="ply" type="Player">The player who tried to undo something</arg>⤶ <arg name="undo" type="table">The undo table as a <page>Structures/Undo</page></arg>⤶ <arg name="ply" type="Player">The player who tried to undo something.</arg>⤶ <arg name="undo" type="table">The undo table as a <page>Structures/Undo</page>.</arg>⤶ </args> <rets> <ret name="" type="boolean">Return false to disallow the undo</ret>⤶ <ret name="" type="boolean">Return false to disallow the undo.</ret>⤶ </rets> </function> <example> <description> Here's a trick you can do to achieve the behavior of this function on the client. </description> <code> hook.Add("PlayerBindPress", "CanUndo", function(ply, bind) hook.Add( "PlayerBindPress", "CanUndo", function( ply, bind ) if ply == LocalPlayer() and bind == "gmod_undo" then return true -- false to allow, true to prevent end end) end ) </code> </example>