Lorder Posted June 28, 2017 Author Share Posted June 28, 2017 1 minute ago, IIYAMA said: answer my question. yes 10% 10% Link to comment
Moderators IIYAMA Posted June 28, 2017 Moderators Share Posted June 28, 2017 If it sets your health to 90, then you still haven't set the 90 to 0. local newHealth = math.max(playerOriginalHealth - headshotDamage, 0) ... Link to comment
Lorder Posted June 28, 2017 Author Share Posted June 28, 2017 1 minute ago, IIYAMA said: If it sets your health to 90, then you still haven't set the 90 to 0. local newHealth = math.max(playerOriginalHealth - headshotDamage, 0) ... I did so function onPlayerHeadshot( attacker, _, bodypart, loss ) local playerOriginalHealth = getElementHealth( source ) + loss -- get the player's original health local newHealth = math.max(playerOriginalHealth - headshotDamage, 0) setElementHealth( localPlayer, newHealth) -- set the player's new health iprint("playerOriginalHealth:", playerOriginalHealth, ", newHealth:", newHealth) end addEventHandler( "onClientPlayerDamage", localPlayer, onPlayerHeadshot ) Link to comment
Moderators IIYAMA Posted June 28, 2017 Moderators Share Posted June 28, 2017 restarted the resource? And: headshotDamage = 200? Link to comment
kikos500 Posted June 28, 2017 Share Posted June 28, 2017 (edited) local multiply = 5 function checkHeadDamage(attacker, weapon, part, loss) if not attacker or not ( getElementType( attacker ) == "player" ) then return false end if part == 9 then setElementHealth(localPlayer, (getElementHealth(localPlayer) - (loss * multiply))) end end addEventHandler( "onClientPlayerDamage", localPlayer, checkHeadDamage) if this doesn't work try addEventHandler( "onClientPlayerDamage", getRootElement(), checkHeadDamage) but try the code i posted up first Edited June 28, 2017 by kikos500 Link to comment
Lorder Posted June 28, 2017 Author Share Posted June 28, 2017 @IIYAMA @kikos500 I've tried it twice, but it did not work, it does not get much damage from his head Link to comment
kikos500 Posted June 28, 2017 Share Posted June 28, 2017 local multiply = 5 function checkHeadDamage(attacker, weapon, part, loss) if not attacker or not ( getElementType( attacker ) == "player" ) then return false end if part == 9 then outputChatBox("This is a test output the player u shot at should be dead now", root) setElementHealth(localPlayer, 0) end end addEventHandler( "onClientPlayerDamage", localPlayer, checkHeadDamage) try this function damage( attacker, weapon, bodypart, loss ) if ( bodypart == 9 ) then outputChatBox ( "Headshot!", getRootElement (), 255, 170, 0 ) setElementHealth(source, (getElementHealth(source)/2)) end end addEventHandler ( "onPlayerDamage", getRootElement (), damage) try this one too but try this one server sided Link to comment
Moderators IIYAMA Posted June 28, 2017 Moderators Share Posted June 28, 2017 Send me the full script in a zip file. Your poor debug skills are getting the better of me, looking at the freaking debug console isn't enough. Link to comment
Lorder Posted June 28, 2017 Author Share Posted June 28, 2017 3 minutes ago, IIYAMA said: Send me the full script in a zip file. Your poor debug skills are getting the better of me, looking at the freaking debug console isn't enough. Download link Link to comment
kikos500 Posted June 28, 2017 Share Posted June 28, 2017 man look at my code carefully.. replace this one addEventHandler( "onClientPlayerDamage", localPlayer, onPlayerHeadshot ) with addEventHandler( "onClientPlayerDamage", localPlayer, checkHeadDamage ) Link to comment
Moderators IIYAMA Posted June 28, 2017 Moderators Share Posted June 28, 2017 http://s6.dosya.tc/server9/ssefpp/hs.zip.html Working. 1 Link to comment
Lorder Posted June 28, 2017 Author Share Posted June 28, 2017 4 minutes ago, IIYAMA said: http://s6.dosya.tc/server9/ssefpp/hs.zip.html Working. I will try Link to comment
xMKHx Posted June 29, 2017 Share Posted June 29, 2017 You can check MTA Resources Directory You find headshot script Here is the code addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then if ( getPlayerWeapon(attacker) == wepID ) killPed(source, attacker, weapon, bodypart) -- This to kill the player with one shot setElementHealth(source, HowMuchHealYouWant) -- This will damage him how much you want end end end ) 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