Gamemode.PropBreak

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NamePropBreak
SyntaxGM:PropBreak( Entity attacker, Entity prop )
DescriptionCalled whenever a prop is destroyed.
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.PropBreak]Gamemode.PropBreak [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Example

DescriptionHook the PropBreak function and send messages to players who break props.
Used onNewerServer.png
Code
local function PropBreak(breaker,prop)
	if breaker:IsValid() and breaker:IsPlayer() and prop:IsValid() then
		breaker:PrintMessage( HUD_PRINTTALK ,"You broke a "..prop:GetClass().." ("..prop:EntIndex()..")!")
		breaker:PrintMessage( HUD_PRINTCONSOLE ,"You broke a "..prop:GetClass().." ("..prop:EntIndex()..")!")
	end
end
hook.Add("PropBreak","OnPropBreak",PropBreak)
OutputTells the player every time he breaks a prop.


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox