Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MTV: Multi-Team-Vehicles v2 for SAPP by H® Shaft
- -- ||| Incompatible with team games ||| If attempted, the script will move to next map, and log it, and report to console.
- -- Allows you to enter the enemy's vehicle during FREE-for-All (FFA) games
- -- Aiming reticle (crosshairs) will not turn red: Big fuggin deal, just aim and shoot!
- -- Gametype settings: Under 'team play options': turn off radar or enemies will show as friendly/yellow on motion sensor.
- -- Created originally for Phasor by H® Shaft and AelitePrime
- -- Portions inspired by/taken from 002's Anti-Teamshoot, and sehé°°'s Zombie script
- -- SAPP api version --
- api_version = "1.8.0.0"
- team_play = 3
- function OnScriptLoad()
- local tick_counter_sig = sig_scan("8B2D????????807D0000C644240600")
- if(tick_counter_sig ~= 0) then
- tick_counter_address = read_dword(read_dword(tick_counter_sig + 2)) + 0xC
- register_callback(cb['EVENT_TICK'],"OnTick")
- end
- register_callback(cb['EVENT_GAME_START'],"OnNewGame")
- register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
- register_callback(cb['EVENT_JOIN'],"OnPlayerJoin")
- register_callback(cb['EVENT_SPAWN'],"OnPlayerSpawn")
- register_callback(cb['EVENT_DIE'], "OnPlayerDeath")
- register_callback(cb['EVENT_BETRAY'], "OnPlayerBetray")
- disable_killmsg_addr = sig_scan("8B42348A8C28D500000084C9") + 3
- original_code_1 = read_dword(disable_killmsg_addr)
- execute_command("var_add kname 3")
- safe_write(true)
- write_dword(disable_killmsg_addr, 0x03EB01B1)
- safe_write(false)
- if get_var(0, "$gt") ~= "n/a" then
- OnNewGame()
- end
- end
- function OnScriptUnload()
- safe_write(true)
- write_dword(disable_killmsg_addr, original_code_1)
- safe_write(false)
- execute_command("var_del kname")
- end
- function OnNewGame()
- -- team games incompatability notice for console and log
- if team_play == 3 then team_play = getteamplay() end
- if (team_play == true) then
- local MODE = get_var(0,"$mode")
- local str1 = string.format("MTV script NOT compatible with %s gametype which is a team game! Skipping map.", tostring(MODE))
- say_all(str1)
- execute_command("log_note \""..str1.."\"")
- cprint(str1)
- execute_command("sv_map_next")
- else
- game_started = true
- for i=1,16 do
- if (player_present(i) == true) then
- write_byte(get_player(i) + 0x20, 0)
- kill(i)
- end
- end
- end
- end
- function OnGameEnd()
- game_started = false
- end
- function OnPlayerDeath(PlayerIndex, KillerIndex)
- if game_started then
- -- set killer index (KillerIndex)
- local killer = tonumber(KillerIndex)
- execute_command('var_set kname "$name" '..PlayerIndex, killer)
- -- set victim name
- local victim_name = get_var(PlayerIndex,"$name")
- -- when killer is 0, the victim died by a vehicle, -1 means killer is the server, fall damage, or team change which are not used here
- if killer == 0 then
- say_all(victim_name .. " was killed by a vehicle.")
- end
- -- killed by a player if killer index > 0
- if killer > 0 then
- -- set killer name for death by self or another player
- local killer_name = get_var(KillerIndex,"$kname")
- -- suicide if player and killer are the same
- if PlayerIndex == killer then
- say_all(victim_name.. " committed suicide.")
- else
- -- killed by another player
- execute_command('say * "$name was killed by $kname"', PlayerIndex)
- end
- end
- end
- end
- function OnPlayerBetray(PlayerIndex)
- if game_started then
- if player_present(PlayerIndex) then
- if not team_play then
- -- since this script can cause betrays on free-for-all, if betray count is > 0, then set to 0 to prevent tk warning or kick/ban
- -- sapp remembers the tk score, even if player quits and rejoins, and between maps too
- if read_dword(get_player(PlayerIndex) + 0xC0) > 0 then
- write_dword(get_player(PlayerIndex) + 0xC0, 0)
- end
- if read_dword(get_player(PlayerIndex) + 0xE0) > 0 then
- write_dword(get_player(PlayerIndex) + 0xE0, 0)
- end
- end
- end
- end
- end
- function OnPlayerSpawn(PlayerIndex)
- if player_present(PlayerIndex) then
- write_byte(get_player(PlayerIndex) + 0x20, 0)
- end
- end
- function OnPlayerJoin(PlayerIndex)
- if player_present(PlayerIndex) then
- write_byte(get_player(PlayerIndex) + 0x20, 0)
- end
- end
- function OnTick()
- local tick_id = read_dword(tick_counter_address)
- for i=1,16 do
- local player_dyn = get_dynamic_player(i)
- if (player_dyn ~= 0) then
- for k=0,3 do
- local struct = player_dyn + 0x430 + 0x10 * k
- local damager_time = read_dword(struct)
- if (damager_time == tick_id) then
- local damager_pid = read_word(struct + 0xC)
- local damager_player = nil
- if (damager_pid ~= 0xFFFF) then
- damager_player = to_player_index(damager_pid)
- OnDamageLookup(i,damager_player)
- end
- end
- end
- end
- end
- end
- function OnDamageLookup(ReceiverIndex, CauserIndex)
- if (CauserIndex and ReceiverIndex ~= CauserIndex) then
- local c_team = read_word(get_player(CauserIndex) + 0x20)
- local r_team = read_word(get_player(ReceiverIndex) + 0x20)
- if c_team == r_team then
- local count = r_team
- while (r_team == count) do
- count = count + 1
- if count > 15 then count = 0 end
- write_byte(get_player(ReceiverIndex) + 0x20, count)
- end
- end
- end
- end
- -- returns true if team game, false if ffa game
- function getteamplay()
- if get_var(0,"$ffa") == "0" then
- return true
- else
- return false
- end
- end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement