Jump to content

Ramming players with vehicle?


Negriukas

Recommended Posts

I tried this but it didnt work, Debug shows nothing..

server

function onPlayerRammed(target) 
    if target and source then 
        killPed(target, source, 49, 9) 
    end 
end 
addEvent("onPlayerRammed",true) 
addEventHandler ( "onPlayerRammed", getRootElement (), onPlayerRammed) 
  
function onPedRammed(victim) 
    if victim and source then 
        killPed(victim, source, 49, 9) 
    end 
end 
addEvent("onPedRammed",true) 
addEventHandler ( "onPedRammed", getRootElement (), onPedRammed) 

client

addEvent("onClientPedRammed") 
addEvent("onClientPlayerRammed") 
  
function checkForRamming(killer, weapon, bodypart, loss) 
    if wasEventCancelled() then 
    return 
    end 
    if getVehicleOccupant(killer, 0) and getElementType(getVehicleOccupant(killer, 0)) == "player" and getVehicleOccupant(killer, 0) ~= localPlayer then 
    return 
    end 
    if not getVehicleOccupant(killer, 0) and source ~= localPlayer then 
    return 
    end 
    if getElementHealth(source) - loss <= 0 then 
    return 
    end 
    if loss > 7 then 
    setElementHealth(source, 0) 
        if getElementType(source) == "player" then 
        triggerServerEvent("onPlayerRammed", source, killer, weapon, bodypart, loss) 
        else 
        triggerServerEvent("onPedRammed", source, killer, weapon, bodypart, loss) 
        end 
    end 
end 
addEventHandler("onClientPedRammed", root, checkForRamming) 
addEventHandler("onClientPlayerRammed", root, checkForRamming) 
  
function onClientPedRammed(killer, weapon, bodypart, loss) 
    if not getElementType(source) == "ped" then  
    return  
    end 
    if weapon == 49 and getElementType(killer) == "vehicle" then 
    triggerEvent("onClientPedRammed", source, killer, weapon, bodypart, loss) 
    end 
end 
addEventHandler ("onClientPedDamage", root, onClientPedRammed) 
  
function onClientPlayerRammed(killer, weapon, bodypart, loss) 
    if not getElementType(source) == "player" then  
    return  
    end 
    if weapon == 49 and getElementType(killer) == "vehicle" then 
    triggerEvent("onClientPlayerRammed", source, killer, weapon, bodypart, loss) 
    end 
end 
addEventHandler ("onClientPlayerDamage", root, onClientPlayerRammed) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...