Garry's Mod Wiki

Revision Difference

Player:HasGodMode#551036

<function name="HasGodMode" parent="Player" type="classfunc"> <description> Returns whether the player has god mode or not, contolled by <page>Player:GodEnable</page> and <page>Player:GodDisable</page>. ⤶ <bug issue="2038">This is not synced between the client and server. This will cause the client to always return false even in godmode.</bug>⤶ </description> <realm>Shared</realm> <file line="283-L291">lua/includes/extensions/player.lua</file> <rets> <ret name="" type="boolean">Whether the player has god mode or not.</ret> </rets> </function>⤶ ⤶ <example>⤶ <description>A fix for accessing this data on client side since you can't at the moment.</description>⤶ <code>⤶ if CLIENT then⤶ local meta = FindMetaTable( "Player" )⤶ ⤶ function meta:HasGodMode()⤶ return self:GetNWBool( "HasGodMode" )⤶ end⤶ end⤶ ⤶ if SERVER then⤶ local meta = FindMetaTable( "Player" )⤶ ⤶ meta.DefaultGodEnable = meta.DefaultGodEnable or meta.GodEnable⤶ meta.DefaultGodDisable = meta.DefaultGodDisable or meta.GodDisable⤶ ⤶ function meta:GodEnable()⤶ self:SetNWBool( "HasGodMode", true )⤶ self:DefaultGodEnable()⤶ end⤶ ⤶ function meta:GodDisable()⤶ self:SetNWBool( "HasGodMode", false )⤶ self:DefaultGodDisable()⤶ end⤶ end⤶ </code>⤶ ⤶ </example></function>