Garry's Mod Wiki

Revision Difference

GM:OnScreenSizeChanged#527339

<function name="OnScreenSizeChanged" parent="GM" type="hook"> <ishook>yes</ishook> <added>2020.04.29</added> <description> Called when the player's screen resolution of the game changes. <note> Cannot print new size, use `print(ScrW())` and `print(ScrH())`</note>⤶ <page>Global.ScrW</page> and <page>Global.ScrH</page> will return the new values when this hook is called. </description> <realm>Client</realm> <predicted>No</predicted> <args> <arg name="oldWidth" type="number">The previous width of the game's window</arg> <arg name="oldWidth" type="number">The previous width of the game's window</arg> <arg name="oldHeight" type="number">The previous height of the game's window</arg> </args> </function> <example> <description>When a player change his Screen Size it's print the old Size and the new size</description> <code> hook.Add("OnScreenSizeChanged", "PrintOld", function(oldWidth, oldHeight) print(oldWidth) -- Print old Screen Width⤶ print(oldHeight) -- Print old Screen Height⤶ print(ScrW()) -- Print new Screen Width⤶ print(ScrH()) -- Print new Screen Height⤶ print(oldWidth, oldHeight) -- Prints old width and height⤶ print(ScrW(), ScrH()) -- Prints new width and height⤶ end) </code> </example>