Garry's Mod Wiki

Revision Difference

WEAPON:PrintWeaponInfo#517955

<function name="PrintWeaponInfo" parent="WEAPON" type="hook"> <ishook>yes</ishook> <description>A convenience function that draws the weapon info box, used in <page>WEAPON:DrawWeaponSelection</page>.</description> <realm>Client</realm> <args> <arg name="x" type="number">The x co-ordinate of box position</arg> <arg name="y" type="number">The y co-ordinate of box position</arg> <arg name="alpha" type="number">Alpha value for the box</arg> </args> </function> <example> <description>As defined in weapon_base</description> <code> function SWEP:PrintWeaponInfo( x, y, alpha ) if ( self.DrawWeaponInfoBox == false ) then return end if (self.InfoMarkup == nil ) then local str local title_color = "&amp;lt;color=230,230,230,255&amp;gt;" local text_color = "&amp;lt;color=150,150,150,255&amp;gt;" local title_color = "&lt;color=230,230,230,255&gt;" local text_color = "&lt;color=150,150,150,255&gt;" str = "&amp;lt;font=HudSelectionText&amp;gt;" if ( self.Author != "" ) then str = str .. title_color .. "Author:&amp;lt;/color&amp;gt;\t"..text_color..self.Author.."&amp;lt;/color&amp;gt;\n" end if ( self.Contact != "" ) then str = str .. title_color .. "Contact:&amp;lt;/color&amp;gt;\t"..text_color..self.Contact.."&amp;lt;/color&amp;gt;\n\n" end if ( self.Purpose != "" ) then str = str .. title_color .. "Purpose:&amp;lt;/color&amp;gt;\n"..text_color..self.Purpose.."&amp;lt;/color&amp;gt;\n\n" end if ( self.Instructions != "" ) then str = str .. title_color .. "Instructions:&amp;lt;/color&amp;gt;\n"..text_color..self.Instructions.."&amp;lt;/color&amp;gt;\n" end str = str .. "&amp;lt;/font&amp;gt;" str = "&lt;font=HudSelectionText&gt;" if ( self.Author != "" ) then str = str .. title_color .. "Author:&lt;/color&gt;\t"..text_color..self.Author.."&lt;/color&gt;\n" end if ( self.Contact != "" ) then str = str .. title_color .. "Contact:&lt;/color&gt;\t"..text_color..self.Contact.."&lt;/color&gt;\n\n" end if ( self.Purpose != "" ) then str = str .. title_color .. "Purpose:&lt;/color&gt;\n"..text_color..self.Purpose.."&lt;/color&gt;\n\n" end if ( self.Instructions != "" ) then str = str .. title_color .. "Instructions:&lt;/color&gt;\n"..text_color..self.Instructions.."&lt;/color&gt;\n" end str = str .. "&lt;/font&gt;" self.InfoMarkup = markup.Parse( str, 250 ) end surface.SetDrawColor( 60, 60, 60, alpha ) surface.SetTexture( self.SpeechBubbleLid ) surface.DrawTexturedRect( x, y - 64 - 5, 128, 64 ) draw.RoundedBox( 8, x - 5, y - 6, 260, self.InfoMarkup:GetHeight() + 18, Color( 60, 60, 60, alpha ) ) self.InfoMarkup:Draw( x+5, y+5, nil, nil, alpha ) end </code> </example>