All pastes #458541 Raw Edit

Something

public lua v1 · immutable
#458541 ·published 2007-04-25 23:03 UTC
rendered paste body
--- [[ Global Variables ]] ----------g_arena = nil      -- The global arena class, to avoid having to pass it around functionsg_bGameRunning = false  -- Is the game running?g_gameTime = nil -- holds the game timeg_statsEvent = 0 -- holds the event for displaying stats when the game endsg_startTime = nil -- for timer stuffg_kills = 0g_shooter = nilg_shooter = nilgc_mapcenterx = 1630	-- The center of the map along the x axisgc_mapcentery = 1662	-- The center of the map along the y axis--[[Functions]]--dofile("stats.lua")function Arena_OnCreate(arena)            g_arena = arena    math.randomseed(os.time())end-- when a player kills another player drop some body parts for the killerfunction Player_OnDeath(killer, victim)		IncreaseDeath(victim)		ChooseStudent(victim)	local chance = math.random(0, 100)		if (chance > 67) then			ChooseCop(victim)			g_arena:message("Congratz, " .. victim.m_name .. " you are now a cop!")	if (killer.m_name == g_shooter.m_name) then		g_kills = g_kills + 1		g_arena:message("" .. g_shooter.m_name .. " has killed " .. g_kills .. " people!")		return		end	endend-- when a player enters the zone, it gives them this messagefunction Player_OnJoin(player)    player:message("Welcome to the Masscre " .. player.m_name .. "!")	WipePlayerStats(player)	player:inventory_modify("Suicide", -1)end-- when the game starts, it sets gameRunning to truefunction Arena_OnGameStart()	WipeAll()	g_startTime = os.time()	g_bGameRunning = true	g_gameTime = os.time()	g_kills = 0	for x = 1, g_arena:num() do		local student = g_arena:get(x)		local vehicletype = 103	if (student:spectator() == false) then		if (student:skill_find(1) == true) then			vehicletype = 101		elseif (student:skill_find(2) == true) then			vehicletype = 102		end		student:setVehicle(vehicletype)		student:team_change("School", "")		end	end	local shooters = 1	local numplayers = g_arena:num()	for x = 1, shooters do		local shooter = g_arena:get(math.random(1, numplayers))		local vehicletypeb = 100			if (shooter:spectator() == false) then				if (shooter:skill_find(3) == true) then				vehicletypeb = 104				end				shooter:setVehicle(vehicletypeb)				shooter:team_change("Shooter", "")				shooter:inventory_modify("Ammo",500)				g_shooter = shooter				shooter = shooter - 1			else				--try again				x = x - 1				if (shooters == 0) then				break				else			end		end	endend-- when the game finishes, it sets gameRunning to falsefunction Arena_OnGameEnd()	DisplayStats()	for x = 1, g_arena:num() do		local plyr = g_arena:get(x)		if (plyr:spectator() == false) then		plyr:team_change("School", "")		plyr:setVehicle(103)		plyr:inventory_modify("Suicide!", -1)	--stop all events that are still running		event_flush(g_arena)		g_shooter = nil		g_kills = 0		end	endendfunction DisplayCoords()	h = g_arena:getPlayer("HellSpawn"):coords()	g_arena:message("x = " .. h.x .. " y = " .. h.y .. "")endfunction Player_OnUnspec(visitor)		visitor:unspec("School", "")			visitor:setVehicle(103)		visitor:warp(gc_mapcenterx, gc_mapcentery, gc_mapcenterx*3)		visitor:message("&You have spawned as a student!")		-- Process as per normal	return trueendfunction WipeAll()	for x = 1, g_arena:num() do	local player = g_arena:get(x)	WipePlayerStats(player)	player:inventory_modify("Suicide!", -1)	endendfunction ChooseCop(victim)local vehicletype = 105		if (victim:skill_find(4) == true) then			vehicletype = 107		elseif (victim:skill_find(5) == true) then			vehicletype = 108		elseif (victim:skill_find(6) == true) then			vehicletype = 109		end		victim:setVehicle(vehicletype)		victim:inventory_modify("Ammo", 400)endfunction ChooseStudent(victim)local vehicletype = 103		if (victim:skill_find(1) == true) then			vehicletype = 101		elseif (victim:skill_find(2) == true) then			vehicletype = 102		end		victim:setVehicle(vehicletype)		victim:team_change("School", "")end