--- [[ Global Variables ]] ---------- g_arena = nil -- The global arena class, to avoid having to pass it around functions g_bGameRunning = false -- Is the game running? g_gameTime = nil -- holds the game time g_statsEvent = 0 -- holds the event for displaying stats when the game ends g_startTime = nil -- for timer stuff g_kills = 0 g_shooter = nil g_shooter = nil gc_mapcenterx = 1630 -- The center of the map along the x axis gc_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 killer function 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 end end -- when a player enters the zone, it gives them this message function 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 true function 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 end end -- when the game finishes, it sets gameRunning to false function 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 end end function DisplayCoords() h = g_arena:getPlayer("HellSpawn"):coords() g_arena:message("x = " .. h.x .. " y = " .. h.y .. "") end function 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 true end function WipeAll() for x = 1, g_arena:num() do local player = g_arena:get(x) WipePlayerStats(player) player:inventory_modify("Suicide!", -1) end end function 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) end function 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