yesyesok Posted April 1, 2015 Share 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. Link to comment
JR10 Posted April 1, 2015 Share Posted April 1, 2015 addEventHandler("onPlayerDamage", root, function(attacker) if (getElementType(attacker) == "vehicle") then killPed(source) end end) Link to comment
WhoAmI Posted April 1, 2015 Share 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 Link to comment
yesyesok Posted April 1, 2015 Author Share Posted April 1, 2015 thanks to set a particular vehicle should i do it like this ? vehicle = Link to comment
WhoAmI Posted April 1, 2015 Share Posted April 1, 2015 Use if ( getElementModel ( attacker ) == VEHICLE_MODEL_HERE ) then after if ( getElementType ( attacker ) == "vehicle" ) then Link to comment
yesyesok Posted April 1, 2015 Author Share Posted April 1, 2015 Thanks i will try it like:) Link to comment
yesyesok Posted April 1, 2015 Author Share Posted April 1, 2015 I just used used jr10's script server side and it's not working. Link to comment
WhoAmI Posted April 1, 2015 Share Posted April 1, 2015 It has to work. Any errors in debugscript3? Link to comment
ALw7sH Posted April 1, 2015 Share 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) Link to comment
yesyesok Posted April 1, 2015 Author Share Posted April 1, 2015 debug : bad argument @ 'getelenenttype' expected at argument 1 got nil Link to comment
Mr.unpredictable. Posted April 1, 2015 Share Posted April 1, 2015 debug : bad argument @ 'getelenenttype' expected at argument 1 got nil It should be serverside Link to comment
WhoAmI Posted April 1, 2015 Share 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) Link to comment
yesyesok Posted April 1, 2015 Author Share Posted April 1, 2015 not working, now there is no debug but it also not killing me. Link to comment
Mr.unpredictable. Posted April 1, 2015 Share Posted April 1, 2015 best way you can do is create a colshape attachElements() ---- to attach the col to the vehicle "onColShapeHit" killPed() Link to comment
JR10 Posted April 1, 2015 Share 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) Link to comment
yesyesok Posted April 1, 2015 Author Share Posted April 1, 2015 debug : bad argument @ 'getelemnenttype' expected at argument 1 got nil Link to comment
JR10 Posted April 1, 2015 Share Posted April 1, 2015 Are you sure you're restarting? It shouldn't output a bad argument error. Link to comment
yesyesok Posted April 1, 2015 Author Share 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. Link to comment
Mr.unpredictable. Posted April 1, 2015 Share Posted April 1, 2015 Try my way for that Link to comment
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