[lua]
local maps = { "gm_construct", "gm_flatgrass" } -- Table of maps
local function Winner( pl )
for _, ply in pairs( player.GetAll() ) do
ply:ChatPrint( pl:Nick() .. " has won the game!" ) -- Very fancy winning text.
local map = table.Random( maps ) -- Select a random map from the maps table.
ply:ChatPrint( "Next map will be: " .. map )
timer.Simple( 5, function() game.ConsoleCommand( "changelevel " .. map .. "\n" ) end ) -- Change map after 5 seconds.
end
end
local killsneeded = 50 -- Amount of kills needed before mapchange.
local function AddKill( vic, inf, pl )
if pl == vic then return end -- If the player killed himself, do not continue.
if pl.kills then pl.kills = pl.kills + 1 else pl.kills = 1 end -- Add kills to the player
if pl.kills >= killsneeded then Winner( pl ) end -- Check if the player have enough kills, if so; run the Winner function.
end
hook.Add( "PlayerDeath", "Kill_Gain", AddKill )
[/lua]
Sorry, you need to Log In to post a reply to this thread.