Gamemode.RoundEnd

From GMod Wiki

Revision as of 20:43, 29 June 2010 by Aide (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Event Hook
Hook NameRoundEnd
SyntaxGM:RoundEnd( )
DescriptionCalled at the end of a round
ReturnsNil
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.RoundEnd]Gamemode.RoundEnd [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionIf the player is alive and not a spectator, then it plays a sound and prints a message.
Used onNewerServer.png
Code
 
 
function GM:RoundEnd( )
	local LoseSound = { "vo/npc/Barney/ba_no01.wav", "vo/npc/Barney/ba_no02.wav", "vo/npc/male01/no01.wav", "vo/npc/male01/no02.wav" }
	local WinSound = { "vo/npc/female01/yeah02.wav", "vo/npc/male01/yeah02.wav" }
	for k,v in pairs(player.GetAll()) do
		if !v:Alive() and !v:Team() == TEAM_SPECTATOR then
			v:SendLua( "surface.PlaySound( \"" .. table.Random(LoseSound) .. "\" )" )
			v:ChatPrint("You failed, the other team has won the round.")
		elseif v:Alive and !v:Team() == TEAM_SPECTATOR then
			v:SendLua( "surface.PlaySound( \"" .. table.Random(WinSound) .. "\" )" )
			v:ChatPrint("You won, the other team has lost the round.")
		end
	end
end
 
 
OutputN/A
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox