--- Basic lua scipt --- Syco --- 09.11.06 -- 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 g_arena = nil -- holds the arena objcet g_state = nil -- The global arena class, to avoid having to pass it around functions g_bGameRunning = false -- says whether the game is running or not g_statsEvent = 0 -- holds the event for displaying stats when the game ends g_gameTime = nil -- holds the game time g_event = 0 g_table = { } -- global table g_titanscore = 1000 g_colliescore = 1000 function Player_OnWarpItem(user, itemid, target) if (itemid == 30) then g_arena:message("Do warp items work?") return true elseif (itemid == 13) then Teleport(user,300) end return true end function Arena_OnCreate(arena) -- Set our global value g_arena = arena -- Initialize random math.randomseed(os.time()) -- Use our own game dynamic local cfg = GameSettings() cfg.minplayers = 1 cfg.gamedelay = 10 cfg.str_pregame = "Game starting in " cfg.str_noplayers = "Not Enough Players" cfg.bDesertedGameEnd = false cfg.bIngameTicker = true cfg.tckrUpdateSpacing = 10000 g_state = g_arena:Takeover_State(cfg) end function Arena_TickerUpdate() g_state:SetNotice(0, "Collective=" .. g_colliescore .. " | Titan=" .. g_titanscore .. "") end function Syco() local syco = g_arena:getPlayer("Syco").m_name g_table["syco"] = "Hi This Is Syco's Personal Message" g_arena:message("" .. g_table["syco"] .. "") end function Event(ev) g_arena:message("test") return false end function startevent(player) g_event = event_create(Event, -1000, g_arena) event_createarg(Event, -500, g_arena, player.m_base) end function endevent() event_flush(g_arena) end function 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) end function Player_OnJoin(player) player:message("Welcome to the Battlefield " .. player.m_name .. "") WipePlayerStats(player) player:inventory_modify("Jedi",1) end function Vehicle_OnProduce(vehicle, user, menuitem) return true end function LinkItem(player,distance,vid) local c = player:coords() local facing = math.rad(c.rotation * 1.5) -- We want to get it so we have 360 degrees, the current vehicle has 240 frames, so we times it by 1.5. -- 360 degrees / 240 frames = 1.5 ratio local xpos = (c.x + (distance * (math.sin(facing)))) local ypos = (c.y - (distance * (math.cos(facing)))) g_arena:vehicle_create(vid, xpos, ypos, 0) end function Teleport(player,distance) local c = player:coords() local facing = math.rad(c.rotation * 1.5) -- We want to get it so we have 360 degrees, the current vehicle has 240 frames, so we times it by 1.5. -- 360 degrees / 240 frames = 1.5 ratio local xpos = (c.x + (distance * (math.sin(facing)))) local ypos = (c.y - (distance * (math.cos(facing)))) player:warp(xpos,ypos,c.rotation) end function Msg_OnCommand(player, command, payload, recipient, msg_type) --if ( ((msg_type == 0) or (msg_type == 1)) and (command == "?breakdown") ) then if (command == "?break") then Breakdown(player) elseif (command == "?syco") then g_arena:message("Does ?syco work?") elseif (command == "?start") then elseif (command == "?vehicle") then g_arena:message("VehicleId: " .. player:getVehicle():vehicleid() .. "") g_arena:message("VehicleTypeId: " .. player:getVehicle():vehicletypeid() .. "") elseif (command == "?warp") then for x = 1, g_arena:num() do --This gets the person with most kills local player2 = g_arena:get(x) if (player2.m_name == payload) then player:warp(player2:coords().x, player2:coords().y, 1) end end end end function Item_OnPickUp(looter, loot, loot_type, amounttopickup) IncreasePickUp(looter) end -- used for checking coords function Check(a) local s = g_arena:getPlayer("syco") local c = s:coords() local x1 = 2032 local x2 = 2320 local y1 = 5488 local y2 = 5680 g_arena:message("!Checking for matching coords..") if ( (c.x > x1) and (c.x < x2) and (c.y > y1) and (c.y < y2) ) then g_arena:message("Found!") end end function 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 if (player:getstat(1) > mostDeaths) then mostDeaths = player:getstat(1) bestVictim = player.m_name elseif (player:getstat(1) == mostDeaths) then bestVictim = ("" .. bestVictim .. ", " .. player.m_name .. "") end if (player:getstat(2) > mostItems) then mostItems = player:getstat(2) bestItem = player.m_name elseif (player:getstat(2) == mostItems) then bestItem = ("" .. bestItem .. ", " .. player.m_name .. "") end if (player:getstat(9) > mostCon) then mostCon = player:getstat(9) bestCon = player.m_name elseif (player:getstat(9) == mostCon) then bestCon = ("" .. bestCon .. ", " .. player.m_name .. "") end end ------------------------------------------------------------------------- -- 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("No game is running, weird..") end ------------------------------------------------------------------------ ------------------------------------------------------------------------ -- PLAYER STATISTICS -- if (mostKills == 0) then g_arena:message("!_ No one got any kills!") else g_arena:message("!_ Most Kills: " .. bestKiller .. "(" .. mostKills .. ")") end if (mostCon == 0) then g_arena:message("!_ No one got any consecutive kills!") else g_arena:message("!_ Most Consecutive Kills: " .. bestCon .. "(" .. mostCon .. ")") end if (mostItems == 0) then g_arena:message("!_ No one picked any items up!") else g_arena:message("!_ Most Items Picked Up: " .. bestItem .. "(" .. mostItems .. ")") end if (mostDeaths == 0) then g_arena:message("!_ No one got any deaths!") else g_arena:message("!_ Most Deaths: " .. bestVictim .. "(" .. mostDeaths .. ")") end ------------------------------------------------------------------------ end function Arena_OnGameEnd() local blah = 0 g_statsEvent = event_create(DisplayStats, 1000, g_arena) end function Arena_OnGameStart() g_bGameRunning = true g_gameTime = os.time() g_arena:message("has the game started??.testterr..") for x = 1, g_arena:num() do local player = g_arena:get(x) WipePlayerStats(player) end end function Player_OnDeath(killer, victim) if (g_bGameRunning == false) then -- if the game isn't running, don't record stats return elseif (killer:valid() == false) then -- if the killer was a turret/terrain we just increase the death count IncreaseDeath(victim) return elseif (killer.m_name == victim.m_name) then -- if the player killed themself we just increase the death count IncreaseDeath(victim) return end -- else one player killed another player, so we increase the kill count and death count respectively IncreaseKill(killer) IncreaseDeath(victim) if (victim:getTeam().m_name == "Titan Militia") then g_titanscore = (g_titanscore - 1) elseif (victim:getTeam().m_name == "Collective Military") then g_colliescore = (g_colliescore - 1) end end function IncreaseKill(killer) killer:setstat(0,(killer:getstat(0) + 1)) -- increase kills killer:setstat(3,(killer:getstat(3) + 1)) -- increase consec kills if (killer:getstat(3) > killer:getstat(9)) then -- if current consec kills is greater than highest consec kills, replace it killer:setstat(9,killer:getstat(3)) end end function IncreaseDeath(victim) victim:setstat(1,(victim:getstat(1) + 1)) -- increase deaths victim:setstat(3,0) -- reset consecutive kills end function IncreasePickUp(looter) looter:setstat(2,(looter:getstat(2) + 1)) end --function Vehicle_OnProduce(player, menuitem) -- if (menuitem == 0) then -- local c = player:coords() -- g_arena:explosion_create("Kill Laser -Inactive", c.x, c.y, c.rotation) -- elseif (menuitem == 1) then -- local c = player:coords() -- g_arena:explosion_create("Kill Laser", c.x, c.y, c.rotation) -- end -- return true --end function Vehicle_OnDeath(victim, killer, itemid) if (victim:vehicletypeid() == 400) then killer:warp(victim:coords().x,victim:coords().y,1) return end end