Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ ### Race Guardian ###]]--
- --[[ ### by H® Shaft ###]]--
- -- Race Guardian: Will warn, then damage and/or kill those who are not racing in a vehicle. If a player is killed by this script, it will say so.
- -- Damage will stop when the player enters a vehicle, and the timer begins again when they exit the vehicle or when they respawn.
- -- Suggestion: Use in conjuction with my Taxi script: http://pastebin.com/EYqiMWU4
- -- Edit --
- timeout_time = 10 --| time in seconds - Amount of time given after warning before damage begins. Suggested Time Out Time: 10 seconds
- max_time = 60 --| time in seconds - Amount of time allowed to be on foot before being warned to get in a vehicle Suggested Max Time: 60 seconds
- -- Don't Edit --
- warned = {}
- foot_time = {}
- last_damage = {}
- enable_guardian = {}
- -- If the boolean is true for the map then Race Guardian will be enabled for the map
- -- Map: Boolean:
- enable_guardian. beavercreek = false -- battle creek
- enable_guardian. bloodgulch = true
- enable_guardian. boardingaction = false
- enable_guardian. carousel = false -- derelict
- enable_guardian. chillout = false
- enable_guardian. damnation = false
- enable_guardian. dangercanyon = true
- enable_guardian. deathisland = true
- enable_guardian. gephyrophobia = true
- enable_guardian. hangemhigh = false
- enable_guardian. icefields = true
- enable_guardian. infinity = true
- enable_guardian. longest = false
- enable_guardian. prisoner = false
- enable_guardian. putput = false -- chiron tl34
- enable_guardian. ratrace = false
- enable_guardian. sidewinder = true
- enable_guardian. timberland = true
- enable_guardian. wizard = false
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(process, game, persistent)
- if game == true or game == "PC" then
- GAME = "PC"
- Map = readstring(0x698F21)
- else
- GAME = "CE"
- Map = readstring(0x61D151)
- end
- GAME = game
- for i=0,15 do
- if getplayer(i) then
- foot_time[i], warned[gethash(i)] = 0, nil
- end
- end
- end
- function OnNewGame(map)
- if GAME == "PC" then
- Map = readstring(0x698F21)
- else
- Map = readstring(0x61D151)
- end
- for i=0,15 do
- if getplayer(i) then
- foot_time[i], warned[gethash(i)] = 0, nil
- end
- end
- if enable_guardian[Map] then
- timer = registertimer(1000, "Timer")
- end
- end
- function OnScriptUnload()
- if timer then
- removetimer(timer)
- timer = nil
- end
- if timeout then
- removetimer(timeout)
- timeout = nil
- end
- end
- function OnPlayerJoin(player)
- if getplayer(player) then
- foot_time[player] = 0
- warned[gethash(player)] = nil
- announce = registertimer(6000, "timedannounce", player)
- end
- end
- function OnPlayerSpawn(player, m_objectId)
- if getplayer(player) then
- foot_time[player] = 0
- warned[gethash(player)] = nil
- end
- end
- function OnPlayerSpawnEnd(player, m_objectId)
- if getplayer(player) then
- last_damage[gethash(player)] = nil
- end
- end
- function OnPlayerLeave(player)
- if getplayer(player) then
- warned[gethash(player)] = nil
- end
- end
- function Timeout(id, count)
- for i = 0,15 do
- if getplayer(i) and warned[gethash(i)] then
- warned[gethash(i)] = nil
- end
- end
- return false
- end
- function Timer(id, count)
- for i=0,15 do
- if getplayer(i) then
- local m_objectId = getplayerobjectid(i)
- if m_objectId and not isinvehicle(i) then
- foot_time[i] = (foot_time[i] or 0) + 1
- else
- foot_time[i] = 0
- end
- if m_objectId and not isinvehicle(i) and warned[gethash(i)] and foot_time[i] > (max_time + timeout_time) then
- applydmgtag(m_objectId, gettagid("jpt!", "vehicles\\scorpion\\bullet"), 1, m_objectId) -- m_objectId is causer, can also be 0xFFFFFFFF which causes no death message in onplayerkill
- elseif m_objectId and isinvehicle(i) and warned[gethash(i)] then
- foot_time[i] = 0
- warned[gethash(i)] = nil
- elseif m_objectId and not isinvehicle(i) and warned[gethash(i)] == nil and foot_time[i] > max_time then
- warn = registertimer(timeout_time * 1000, "Warn", i)
- end
- end
- end
- return true
- end
- function Warn(id, count, player)
- if count == 1 then
- if getplayer(player) and warned[gethash(player)] == nil and not isinvehicle(player) then
- local name = getname(player)
- warned[gethash(player)] = true
- foot_time[player] = foot_time[player] - timeout_time
- sendconsoletext(player, name .. ": Get in a vehicle immediately and race, or face death.")
- sendconsoletext(player, "You have " .. timeout_time .. " seconds(s) to comply.")
- timeout = registertimer(timeout_time * 1000, "Timeout")
- end
- end
- return false
- end
- function OnVehicleEntry(player, m_vehicleId, seat, mapId, relevant)
- if getplayer(player) then
- foot_time[player] = 0
- warned[gethash(player)] = nil
- end
- return nil
- end
- function OnDamageApplication(receiving, causing, tagid, hit, backtap)
- if receiving then
- local r_object = getobject(receiving)
- if r_object then
- local receiver = objectaddrtoplayer(r_object)
- if receiver then
- local r_hash = gethash(receiver)
- local tagname,tagtype = gettaginfo(tagid)
- last_damage[r_hash] = tagname
- end
- end
- end
- end
- function OnPlayerKill(killer, victim, mode)
- local response = false
- if mode == 6 and last_damage[gethash(victim)] == "vehicles\\scorpion\\bullet" then
- response = false
- say(getname(victim) .. " was killed by the guardians for not racing in a vehicle.")
- return response
- end
- end
- function timedannounce(id, count, player)
- if getplayer(player) then
- if enable_guardian[Map] then sendconsoletext(player, "Race Guardian is Enabled.") end
- end
- return false
- end
- function OnGameEnd(stage)
- if stage == 1 then
- if timer then
- removetimer(timer)
- timer = nil
- end
- if timeout then
- removetimer(timeout)
- timeout = nil
- end
- if warn then
- removetimer(warn)
- warn = nil
- end
- if announce then
- removetimer(announce)
- announce = nil
- end
- end
- end
- -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
- -- Visit http://halorace.org/forum/index.php?topic=514.0 or
- -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment