yesyesok Posted April 1, 2015 Posted April 1, 2015 Hey does any 1 know how do i make players die when they hit a car. Like when a interanus hits a player he should die. please post an small example, i'm new to scripting.
JR10 Posted April 1, 2015 Posted April 1, 2015 addEventHandler("onPlayerDamage", root, function(attacker) if (getElementType(attacker) == "vehicle") then killPed(source) end end)
WhoAmI Posted April 1, 2015 Posted April 1, 2015 (edited) addEventHandler ( "onPlayerDamage", root, function ( attacker ) if ( getElementType ( attacker ) == "vehicle" ) then killPed ( source ) end end ) @EDIT: Damn man! You was faster. Edited April 1, 2015 by Guest
yesyesok Posted April 1, 2015 Author Posted April 1, 2015 thanks to set a particular vehicle should i do it like this ? vehicle =
WhoAmI Posted April 1, 2015 Posted April 1, 2015 Use if ( getElementModel ( attacker ) == VEHICLE_MODEL_HERE ) then after if ( getElementType ( attacker ) == "vehicle" ) then
yesyesok Posted April 1, 2015 Author Posted April 1, 2015 I just used used jr10's script server side and it's not working.
ALw7sH Posted April 1, 2015 Posted April 1, 2015 addEventHandler("onPlayerDamage", root, function(attacker) if (getElementType(attacker) == "vehicle") then if (getElementModel(attacker) == vehicleID) then -- change it to your vehicle id killPed(source) end end end)
yesyesok Posted April 1, 2015 Author Posted April 1, 2015 debug : bad argument @ 'getelenenttype' expected at argument 1 got nil
Mr.unpredictable. Posted April 1, 2015 Posted April 1, 2015 debug : bad argument @ 'getelenenttype' expected at argument 1 got nil It should be serverside
WhoAmI Posted April 1, 2015 Posted April 1, 2015 addEventHandler("onPlayerDamage", root, function(attacker) if (isElement(attacker) and getElementType(attacker) == "vehicle") then if (getElementModel(attacker) == vehicleID) then -- change it to your vehicle id killPed(source) end end end)
yesyesok Posted April 1, 2015 Author Posted April 1, 2015 not working, now there is no debug but it also not killing me.
Mr.unpredictable. Posted April 1, 2015 Posted April 1, 2015 best way you can do is create a colshape attachElements() ---- to attach the col to the vehicle "onColShapeHit" killPed()
JR10 Posted April 1, 2015 Posted April 1, 2015 @unpredictable More like worst way. Try this client-side: addEventHandler("onClientPlayerDamage", localPlayer, function(attacker) if (isElement(attacker) and getElementType(attacker) == "vehicle") then setElementHealth(localPlayer, 0) end end)
yesyesok Posted April 1, 2015 Author Posted April 1, 2015 debug : bad argument @ 'getelemnenttype' expected at argument 1 got nil
JR10 Posted April 1, 2015 Posted April 1, 2015 Are you sure you're restarting? It shouldn't output a bad argument error.
yesyesok Posted April 1, 2015 Author Posted April 1, 2015 ahhh there is no debug but still it doesn't kill, i want it like when i touch the vehicle it should kill me.
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