Advertisement
Combreal

VehiCollision.lua

Jan 27th, 2014
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. -- For vehicle collision off - inspired from Eliteprime, Wizard, Shaft and Bugs's works --
  2.                         -- Whith the great help of A§H»Wizard --
  3.  
  4. playerRunoverCounter = {}
  5. playerIsHit = {}
  6. survives = 3  -- Number of times +1 the player will die before surviving by runovers
  7.  
  8. function GetRequiredVersion()
  9.     return 200
  10. end
  11.  
  12.  
  13. function OnScriptLoad(processid, game, persistent)end
  14.  
  15. function OnDamageLookup(receiving, causing, mapId, tagdata)
  16.     if causing and receiving then
  17.         local c_player = objectidtoplayer(causing)
  18.         local r_player = objectidtoplayer(receiving)
  19.         if c_player and r_player and isinvehicle(c_player) then
  20.             if not isinvehicle(r_player) then
  21.                 local dmg = gettaginfo(mapId)
  22.                 if dmg == "globals\\vehicle_collision" then
  23.                     if not playerIsHit[r_player] then
  24.                         if not playerRunoverCounter[r_player] then playerRunoverCounter[r_player] = 0 end
  25.                         playerRunoverCounter[r_player] = playerRunoverCounter[r_player] + 1
  26.                         if playerRunoverCounter[r_player] >= survives then
  27.                             return false
  28.                         else
  29.                             playerIsHit[r_player] = true
  30.                             registertimer(1000, "Alrdycrashed", r_player)
  31.                         end
  32.                     end
  33.                 end
  34.             end
  35.         end
  36.     end
  37.     return true
  38. end
  39.  
  40. function getplayervehicleid(player)
  41.     local m_objectId = getplayerobjectid(player)
  42.     if m_objectId then return readdword(getobject(m_objectId) + 0x11C) end
  43. end
  44.  
  45.  
  46. function Alrdycrashed(id, count, player)
  47.     playerIsHit[player] = nil
  48.     return false
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement