All pastes #745302 Raw Edit

Untitled

public lua v1 · immutable
·published 2007-10-22 08:34 UTC
rendered paste body
--Global Variablesg_arena = nilg_player = nilg_bGameRunning = falsefunction Arena_OnCreate(arena)	-- Set our global value	g_arena = arena		local cfg = GameSettings()       cfg.minplayers = 2       cfg.gamedelay = 15               cfg.str_pregame = "Game starting in "       cfg.str_noplayers = "Not Enough Players"        cfg.bDesertedGameEnd = false        --cfg.bIngameTicker = true       --cfg.tckrUpdateSpacing = 1000        g_state = g_arena:Takeover_State(cfg)   	-- Initialize random	math.randomseed(os.time())endfunction Player_OnDeath(killer, victim) -- player, player 	local humansAlive = false		if (killer:getTeam().m_name == "Beast") then --QLOOS: Please make sure this is the BEAST team name		victim:changeTeam('Spider', 'Spider') --QLOOS: Please make sure this is the correct team name and password for the spider	end	--QLOOS: Another feature I thought you might want is to find out if there are any humans left, so I'm going to go ahead and check for that and end the game if the last human was killed.	for i=1, g_arena:numPlaying() do			local player = g_arena:getPlayer(i)			if (player ~= nil) then				if (player:getTeam().m_name == "Human") then --QLOOS: This should be the name of the humans team					humansAlive = true				end			end		end		if (humansAlive == false) then		g_arena:message('The Beast has won by killing all humans, the last human alive was '..victim.m_name..'.')		g_state:Endgame()	end	endfunction Arena_OnGameStart() 	g_bGameRunning = true	g_arena:message("Let the Hunt Begin!")	local randomplayer = math.random(1, g_arena:numPlaying())	randomplayer = g_arena:getPlayer(randomplayer)	randomplayer:changeTeam('Beast', 'Beast') -- QLOOS: Please make sure the name of the beast team is correct	event_create(endGame, 600000, g_arena) -- QLOOS: please make sure the timer is correct I forgot off the top of my head.endfunction Arena_OnGameEnd()	 g_bGameRunning = false	 event_flush()endfunction endGame()		local humansAlive = false		local livinghumans = { }			--Find out if there are any humans left		for i=1, g_arena:numPlaying() do			local player = g_arena:getPlayer(i)			if (player ~= nil) then				if (player:getTeam().m_name == "Human") then --QLOOS: This should be the name of the humans team					humansAlive = true					table.insert(livinghumans, player.m_name)				end			end		end				if (humansAlive == true) then			g_arena:message('Humans are the winners, the following humans survived.')			--QLOOS: this will go down the list of every human who is still alive and display their names in the chat			for i=1, table.getn(livinghumans) do				g_arena:message(livinghumans[i])			end		else			g_arena:message('The Beast has won.')		end		g_state:Endgame()end--*Game Start* ---everyone randomly spawns on map as humans. ---1 player is randomly chosen to be the Beast. ---10 minute timer until game ends, if there are any living humans at game end, victory for humans. ---When a Beast kills a human he goes to the Spider team. --^thats all the LUA I need, game should already automaticly randomly warp the players around. Not sure if LUA is required for timer.