Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Team Score Display
- -- by H® Shaft
- -- Will show Red Team and Blue Team Scores with Time Left (HH:MM:SS) at the top of the screen in console text.
- -- Will show team death totals for both CTF and Team Slayer
- -- Players can toggle Team Score Display by typing /hide to HIDE, or /show to UNHIDE the display
- -- Designed for Team Games: CTF and Team Slayer
- api_version = "1.9.0.0"
- tick_counter_address = nil
- sv_map_reset_tick_address = nil
- timelimit_address = nil
- teamdeaths = {}
- message_hide = {}
- function OnScriptLoad()
- register_callback(cb['EVENT_JOIN'],"OnPlayerJoin")
- register_callback(cb["EVENT_GAME_START"], "OnNewGame")
- register_callback(cb["EVENT_GAME_END"], "OnGameEnd")
- register_callback(cb['EVENT_DIE'], "OnPlayerDeath")
- register_callback(cb['EVENT_CHAT'], "OnPlayerChat")
- local tick_counter_sig = sig_scan("8B2D????????807D0000C644240600")
- if (tick_counter_sig == 0) then return end
- local sv_map_reset_tick_sig = sig_scan("8B510C6A018915????????E8????????83C404")
- if (sv_map_reset_tick_sig == 0) then return end
- local timelimit_location_sig = sig_scan("8B0D????????83C8FF85C97E17")
- if (timelimit_location_sig == 0) then return end
- tick_counter_address = read_dword(read_dword(tick_counter_sig + 2)) + 0xC
- sv_map_reset_tick_address = read_dword(sv_map_reset_tick_sig + 7)
- timelimit_address = read_dword(timelimit_location_sig + 2)
- if get_var(0, "$gt") ~= "n/a" then
- OnNewGame()
- end
- end
- function OnNewGame()
- game_started = true
- team_play = getteamplay()
- game_type = get_var(0, "$gt")
- teamdeaths["red"] = 0
- teamdeaths["blue"] = 0
- timer(1000, "messenger")
- end
- function OnPlayerJoin(PlayerIndex)
- announce = timer(12000, "timedannounce", PlayerIndex)
- message_hide[get_var(PlayerIndex,"$hash")] = nil
- end
- function OnPlayerChat(PlayerIndex, Message)
- local response = nil
- if Message == nil then
- return true
- end
- local Message = string.lower(Message)
- if Message ~= nil then
- if (Message == "hide") or (Message == "/hide") then
- response = false
- message_hide[get_var(PlayerIndex,"$hash")] = true
- say(PlayerIndex, "The team scores have been hidden. Type /show to unhide. ")
- elseif (Message == "show") or (Message == "/show") then
- response = false
- message_hide[get_var(PlayerIndex,"$hash")] = nil
- say(PlayerIndex,"The team scores are no longer hidden. Type /hide to re-hide.")
- end
- end
- return response
- end
- function timedannounce(PlayerIndex)
- if player_present(PlayerIndex) then
- rprint(PlayerIndex, "|c SCORES: You can toggle display by typing /hide or /show")
- end
- return false
- end
- function OnGameEnd()
- game_started = false
- teamdeaths = {}
- end
- function getteamplay()
- if get_var(0,"$ffa") == "0" then
- return true
- else
- return false
- end
- end
- function OnPlayerDeath(PlayerIndex, KillerIndex)
- -- Killer Index is: -- falling = -1, server = -1, team-switch = -1, vehicle = 0, other players = 1 or greater
- if game_started then
- local vteam = get_var(PlayerIndex, "$team")
- local killer = tonumber(KillerIndex)
- if team_play then
- if teamdeaths["red"] == nil then teamdeaths["red"] = 0 end
- if teamdeaths["blue"] == nil then teamdeaths["blue"] = 0 end
- teamdeaths[vteam] = teamdeaths[vteam] + 1
- end
- end
- end
- function messenger()
- if game_started then
- -- time remaining by 002
- local timeleftinseconds = math.floor((read_dword(timelimit_address) - (read_dword(tick_counter_address) - read_dword(sv_map_reset_tick_address))) / 30)
- local minutes = math.floor(timeleftinseconds / 60)
- local seconds = timeleftinseconds % 60
- local zero = "0"
- if(seconds > 9) then zero = "" end
- tmessage = "Time Left: "
- if (minutes > 59) then
- local hours = math.floor(minutes / 60)
- minutes = minutes % 60
- tmessage = tmessage .. hours .. ":"
- end
- time_left = tmessage .. minutes .. ":" .. zero .. seconds
- -- end time remaining
- if game_type == "ctf" or game_type == "slayer" then
- if team_play then
- local red_score = tonumber(get_var(0,"$redscore"))
- local blue_score = tonumber(get_var(0,"$bluescore"))
- if teamdeaths["red"] == nil then teamdeaths["red"] = 0 end
- if teamdeaths["blue"] == nil then teamdeaths["blue"] = 0 end
- local red_deaths = teamdeaths["red"]
- local blue_deaths = teamdeaths["blue"]
- local message = string.format(" Red Team: %s | Blue Team: %s | %s", red_score, blue_score, time_left)
- local deaths = string.format(" R Deaths: %s | B Deaths: %s", red_deaths, blue_deaths)
- for PlayerIndex = 1,16 do
- local hash = get_var(PlayerIndex, "$hash")
- if (message_hide[hash] ~= true) then
- rprint(PlayerIndex, message)
- rprint(PlayerIndex, deaths)
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- rprint(PlayerIndex, "\n")
- end
- end
- end
- end
- return true
- else
- return false
- end
- end
- function OnScriptUnload() end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Add Comment
Please, Sign In to add comment