Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- For vehicle collision off - inspired from Eliteprime, Wizard, Shaft and Bugs's works --
- -- With the great help of A§H»Wizard --
- playerRunoverCounter = {}
- playerIsHit = {}
- survives = 3 -- Number of times +1 the player will die before surviving by runovers
- eject = {}
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(processid, game, persistent)
- first_timer = registertimer(20, "IsEjectVehi")
- end
- function OnDamageLookup(receiving, causing, mapId, tagdata)
- if causing and receiving then
- local c_player = objectidtoplayer(causing)
- local r_player = objectidtoplayer(receiving)
- if c_player and r_player and isinvehicle(c_player) then
- if not isinvehicle(r_player) then
- local dmg = gettaginfo(mapId)
- if dmg == "globals\\vehicle_collision" then
- if not playerIsHit[r_player] then
- if not playerRunoverCounter[r_player] then playerRunoverCounter[r_player] = 0 end
- playerRunoverCounter[r_player] = playerRunoverCounter[r_player] + 1
- if playerRunoverCounter[r_player] >= survives then
- return false
- else
- playerIsHit[r_player] = true
- second_timer = registertimer(1000, "Alrdycrashed", r_player)
- end
- end
- end
- end
- end
- end
- return true
- end
- function OnServerCommand(player, command)
- local t = tokenizecmdstring(command)
- local count = #t
- if count > 0 then
- if t[1] == "sv_ejectvehi" and count == 2 then
- local player = t[2]
- player = rresolveplayer(player)
- if getplayer(player) then
- EjectVehi(player)
- return false
- end
- end
- end
- end
- function OnPlayerJoin(player)
- eject[gethash(player)] = false
- end
- function OnPlayerLeave(player)
- eject[gethash(player)] = false
- end
- function IsEjectVehi(id, count)
- for player = 0, 15 do
- if getplayer(player) then
- if eject[gethash(player)] == true then
- if player and isinvehicle(player) then
- exitvehicle(player)
- eject[gethash(player)] = false
- end
- end
- end
- end
- return true
- end
- function EjectVehi(player)
- if eject[gethash(player)] ~= nil then
- if eject[gethash(player)] ~= true then
- eject[gethash(player)] = true
- sendconsoletext(player, "You have been ejected from your vehicle, stop camping!")
- end
- end
- end
- function OnGameEnd(stage)
- if stage == 1 then
- if first_timer then
- removetimer(first_timer)
- end
- if second_timer then
- removetimer(second_timer)
- end
- for player = 0, 15 do
- if getplayer(player) then
- eject[gethash(player)] = false
- playerIsHit[player] = false
- playerRunoverCounter[player] = false
- end
- end
- end
- end
- function getplayervehicleid(player)
- local m_objectId = getplayerobjectid(player)
- if m_objectId then return readdword(getobject(m_objectId) + 0x11C) end
- end
- function Alrdycrashed(id, count, player)
- playerIsHit[player] = nil
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement