Combreal icon

VehiCollision.lua

Combreal | PRO | 01/27/14 07:32:44 PM UTC | 0 ⭐ | 1271 👁️ | Never ⏰ | []
Lua |

1.44 KB

|

None

|

0 👍

/

0 👎

-- For vehicle collision off - inspired from Eliteprime, Wizard, Shaft and Bugs's works --
                        -- Whith the great help of A§H»Wizard --
 
playerRunoverCounter = {}
playerIsHit = {}
survives = 3  -- Number of times +1 the player will die before surviving by runovers
 
function GetRequiredVersion()
    return 200
end
 
 
function OnScriptLoad(processid, game, persistent)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
                            registertimer(1000, "Alrdycrashed", r_player)
                        end
                    end
                end
            end
        end
    end
    return true
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

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎