TheGrimReaper Posted June 28, 2018 Posted June 28, 2018 (edited) -- client function check( attacker, weapon ) local theVehicle = getPedOccupiedVehicle ( getLocalPlayer ) if getElementType ( weapon ) == "Rammed" then triggerServerEvent ( "kill", resourceRoot, attacker ) else end end addEventHandler("onPlayerDamage"", root, check) -- server function kill(attacker) outputChatBox("Collided.", source) killPed(source, attacker) end addEvent( "kill", true ) addEventHandler( "kill", resourceRoot, kill ) -- Bound to this resource only, saves on CPU usage. addCommandHandler("col", kill )-- this is just to test the kill Hi i am trying to make a script that kills player instantly when hit by a car, can anyone pls help me out nevermind my mistake xDDDDD topic close Edited June 28, 2018 by TheGrimReaper
Mr.Loki Posted June 28, 2018 Posted June 28, 2018 (edited) onPlayerDamage is a server event so you have to use onClientPlayerDamage -- client function check( attacker, weapon ) if getElementType ( attacker ) == "vehicle" and weapon == 49 then -- check if attacker was vehicle and damage type was Rammed (49). triggerServerEvent ( "onVehicleKill", source, getVehicleController( attacker ) ) -- trigger the kill event sending the player that was hit as the source and the attacker (vehicle) controller. end end addEventHandler("onClientPlayerDamage", root, check) -- server function killPlayer(attacker) killPed(source, attacker, 49) --we use the source which is the localPlayer that was rammed -- the attacker is the vehicle's controller -- and we set the weeapon to 49 which is the damage type of being rammed end addEvent( "onVehicleKill", true ) addEventHandler( "onVehicleKill", root, killPlayer ) Edited June 28, 2018 by Mr.Loki 1
TheGrimReaper Posted June 29, 2018 Author Posted June 29, 2018 -- server function check ( attacker, weapon, bodypart, loss ) if ( weapon == 49 ) then killPed ( source, attacker, weapon, bodypart, false ) end end addEventHandler ( "onPlayerDamage", getRootElement (), check ) yes bro i figured out later , and i wrote this more optimized code but thanks for the help man , it was helpful too 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now