All pastes #953316 Raw Edit

Unnamed

public lua v1 · immutable
#953316 ·published 2008-03-22 23:44 UTC
rendered paste body
--[[Dodgeball/League administration script]]---- Player stat settings-- 0 - Kills-- 1 - Deaths-- 2 - items picked up-- 3 - current consecutive kills-- 4 - vehicles destroyed-- 5 - -- 6 - -- 7 --- 8 - -- 9 -- highest consecutive kills--- [[ Global Variables ]] ---------- g_arena = nil      -- The global arena class, to avoid having to pass it around functionsg_bGameRunning = false  -- Is the game running?g_statsEvent = 0 -- holds the event for displaying stats when the game endsg_gameTime = nil -- holds the game timeg_referee = { }table.insert(g_referee, "HellSpawn")--- [[ Functions ]] --------- when the arena is created, it runs thisfunction Arena_OnCreate(arena)            g_arena = arena            math.randomseed(os.time())end-- when someones kill someone else, it displays this message to the victimfunction Player_OnDeath(killer, victim)	local pos = victim:coords()	local ballNum = victim:inventory_find("Ball")	if (victim:inventory_find("Catcher") == 1) then	local pos = victim:coords()	victim:resurrectWarp(pos.x, pos.y, 1)	victim:setCrown(true, 5000)	killer:warp(1044, 1003, 1)	killer:setCrown(false, 0)	killer:message("You are out! " .. victim.m_name .. " caught your ball!")	end	victim:message("You got out by " .. killer.m_name .. " Now you must wait until the next game begins!")	IncreaseKill(killer)	IncreaseDeath(victim)	victim:inventory_modify("Ball", -ballNum)	g_arena:item_create("Ball", ballNum, pos.x, pos.y)end-- when a player enters the zone, it gives them this messagefunction Player_OnJoin(player)    player:message("&Welcome to Dodgeball " .. player.m_name .. "!")	player:inventory_modify("Ball", -2)endfunction Arena_OnGameEnd()	local blah = 0	g_statsEvent = event_create(DisplayStats, 1000, g_arena)	event_flush(g_arena)endfunction Arena_OnGameStart()	g_bGameRunning = true	g_gameTime = os.time()	event_create(InitSpawn, 10000, g_arena)	for x = 1, g_arena:num() do		local player = g_arena:get(x)		WipePlayerStats(player)		player:inventory_modify("Ball", -2)	endendfunction WipePlayerStats(player)	player:setStat(0,0)	player:setStat(1,0)	player:setStat(2,0) 	player:setStat(3,0)	player:setStat(4,0)	player:setStat(5,0)	player:setStat(6,0)	player:setStat(7,0)	player:setStat(8,0)	player:setStat(9,0)endfunction DisplayStats(ev)	--g_bGameRunning = false		local bestKiller = ""	local bestVictim = ""	local bestItem = ""	local bestCon = ""	local mostKills = 0	local mostDeaths = 0	local mostItems = 0	local mostCon = 0		for x = 1, g_arena:num() do   --This gets the person with most kills		local player = g_arena:get(x)		if (player:getStat(0) > mostKills) then			mostKills = player:getStat(0)			bestKiller = player.m_name		elseif (player:getStat(0) == mostKills) then			bestKiller = ("" .. bestKiller .. ", " .. player.m_name .. "")		end		end		-------------------------------------------------------------------------	g_arena:message("&Endgame Breakdown")	-- GAME TIME STATISTICS --	if (g_gameTime ~= nil) then		local diff = (os.time() - g_gameTime)		local minutes = math.floor(diff / 60)		if (minutes == 1) then			local seconds = (diff-60*math.floor(diff/60))			g_arena:message("Total Game Time: " .. minutes .. " minute, " .. seconds .. " seconds")		elseif (minutes > 1) then			local seconds = (diff-60*math.floor(diff/60))			g_arena:message("Total Game Time: " .. minutes .. " minutes, " .. seconds .. " seconds")		else			g_arena:message("Total Game Time: " .. diff .. " seconds")		end	else		g_arena:message("The Game is not running!")	end	------------------------------------------------------------------------			------------------------------------------------------------------------	-- PLAYER STATISTICS --	if (mostKills == 0) then		g_arena:message("!_    No one got any kills!")	else		g_arena:message("!_    Most Kills: " .. bestKiller .. "(" .. mostKills .. ")")	end	------------------------------------------------------------------------	for x = 1, g_arena:num() do   --This gets the person with most kills	local player = g_arena:get(x)	local playerKills = 0	playerKills = player:getStat(0)	player:message("Personal Stats")	if (mostKills == 0) then		player:message("!_    You got zero kills!")	else		player:message("!_    Kills:(" .. playerKills .. ")")			end		end	end	function IncreaseKill(killer)	killer:setStat(0,(killer:getStat(0) + 1)) -- increase killsendfunction IncreaseDeath(victim)	victim:setStat(1,(victim:getStat(1) + 1)) -- increase deathsendfunction Msg_OnCommand(player, command, payload, recipient, msg_type)	if (command == "*setteam") then		local target = g_arena:getPlayer(recipient)		local found = false		for x = 1, table.getn(g_referee) do			if (g_referee[x] == player.m_name) then -- FOUND HIM!				found = true			end		end				if (found == true) then			if (target:exists() == true) then				target:team_change("" .. payload .. "","")			else				player:message("Error: You did not correctly specify a player to team change")			end		else			player:message("Error: You're not in the referee table!")			end				elseif (command == "*referee") then		local target = g_arena:getPlayer(payload)		-- local target = g_arena:getPlayer(recipient) -- You don't mean this?		if (target:exists() == true) then			if (player == "HellSpawn") then			table.insert(g_referee, target.m_name)			else			end			player:message("You're not the league admin!")		else			player:message("Error: That player does not exist!")		end	endend