Dzsozi (h03) Posted December 25, 2014 Share Posted December 25, 2014 Hello community! I want to make script which is removes health if you crash with your vehicle and I don't want to use setElementHealth, I want to define it as a PlayerDamage and use onPlayerDamage event, because I have other scripts which are works with onPlayerDamage, and if I use setElementHealth they wont work. So how can I define something as a player damage? I've tried this, but I have headshot resource running and if I crash a little bit I die immediately, but if I define bodypart for example as torso (number 3) the crash script is not working. Debugscript doesn't show me errors, but I can't fix it. I would be happy if someone could help me! function lossHealthOnHurt(loss) if getVehicleOccupant(source) then player = getVehicleOccupant(source) health = getElementHealth(player) if loss >= 50 and loss < 349 then --setElementHealth(player, health - loss/10) triggerEvent("onPlayerDamage", player, nil, nil, 9, loss/10) elseif loss >= 350 then killPed(player) end end end addEventHandler("onVehicleDamage", getRootElement(), lossHealthOnHurt) Thanks in advance! Link to comment
#DRAGON!FIRE Posted December 25, 2014 Share Posted December 25, 2014 test this : function lossHealthOnHurt ( loss ) if ( getVehicleController ( source ) ) then local player = getVehicleController ( source ) local health = getElementHealth ( player ) if ( loss >= 50 and loss < 349 ) then setElementHealth ( player, health - loss/10 ) elseif ( loss >= 350 ) then killPed ( player ) end end end addEventHandler( "onVehicleDamage", getRootElement ( ), lossHealthOnHurt ) Link to comment
Dzsozi (h03) Posted December 25, 2014 Author Share Posted December 25, 2014 I don't want to use setElementHealth, I want to define it as a PlayerDamage and use onPlayerDamage event, because I have other scripts which are works with onPlayerDamage, and if I use setElementHealth they wont work. Link to comment
Buffalo Posted December 25, 2014 Share Posted December 25, 2014 If it's so important to use onPlayerDamage then do this: setElementHealth ( player, health - loss/10 ) triggerEvent("onPlayerDamage", player, nil, nil, 9, loss/10) No other way on serverside, write it on clientside then, onClientVehicleDamage. This or rewrite all your damage scripts to be compatible with your new scripts. 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