TheMagicano Posted January 31, 2019 Share Posted January 31, 2019 hey i was make headshot script for sniper but i was want it when player get headshot just lose 100hp from his heals can anyone help me please? Spoiler addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 and weapon == 34 then local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon, loss) if result == true then killPed(source, attacker, weapon, bodypart) setPedHeadless( source, true ) setTimer( BackUp, 900, 1, source ) end end end ) function BackUp( source ) if getElementType ( source ) == "player" then setPedHeadless ( source, false ) end end Link to comment
AncienT Posted January 31, 2019 Share Posted January 31, 2019 5 hours ago, TheMagicano said: hey i was make headshot script for sniper but i was want it when player get headshot just lose 100hp from his heals can anyone help me please? Hide contents addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 and weapon == 34 then local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon, loss) if result == true then killPed(source, attacker, weapon, bodypart) setPedHeadless( source, true ) setTimer( BackUp, 900, 1, source ) end end end ) function BackUp( source ) if getElementType ( source ) == "player" then setPedHeadless ( source, false ) end end Do you want me to lose 100 hp instead, to die? Link to comment
TheMagicano Posted January 31, 2019 Author Share Posted January 31, 2019 Yes just wanted when a Player shoots with sniper in the head, the other Player gets dmg 100% instead of instantly dying Link to comment
Peti Posted January 31, 2019 Share Posted January 31, 2019 (edited) https://wiki.multitheftauto.com/wiki/SetElementHealth setElementHealth ( thePlayer, getElementHealth(thePlayer) - 100 ) Edited January 31, 2019 by Peti Link to comment
TheMagicano Posted January 31, 2019 Author Share Posted January 31, 2019 28 minutes ago, Peti said: https://wiki.multitheftauto.com/wiki/SetElementHealth setElementHealth ( thePlayer, getElementHealth(thePlayer) - 100 ) I put this line in which function? Link to comment
Peti Posted January 31, 2019 Share Posted January 31, 2019 (edited) 6 minutes ago, TheMagicano said: I put this line in which function? First of all, where did you get the script from? If it is stolen, I'm not going to give you support. It seems that you don't know the basis of scripting, so I assume this is not yours. If it is, I'm sorry Edited January 31, 2019 by Peti Link to comment
TheMagicano Posted January 31, 2019 Author Share Posted January 31, 2019 (edited) 16 minutes ago, Peti said: First of all, where did you get the script from? If it is stolen, I'm not going to give you support. It seems that you don't know the basis of scripting, so I assume this is not yours. If it is, I'm sorry lol? someone shere it in our community https://community.multitheftauto.com/index.php?p=resources and i edited somethings in it like weapon.. Edited January 31, 2019 by TheMagicano Link to comment
Peti Posted January 31, 2019 Share Posted January 31, 2019 Give me the link of the script then. Link to comment
TheMagicano Posted January 31, 2019 Author Share Posted January 31, 2019 Just now, Peti said: Give me the link of the script then. take https://community.multitheftauto.com/index.php?p=resources&s=details&id=12242 Link to comment
Peti Posted January 31, 2019 Share Posted January 31, 2019 (edited) Ok, you're legit. I'm sorry. I was bieng skeptical because you mention that you were making a headshot script, but it wasn't yours. Here you have your needed support: addEvent("onPlayerHeadshot") addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 and weapon == 34 then local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon, loss) if result == true then setElementHealth ( source, getElementHealth(source) - 100 ) if isPlayerDead ( source ) == true then killPed(source, attacker, weapon, bodypart) setPedHeadless( source, true ) setTimer( BackUp, 900, 1, source ) end end end end ) function BackUp( source ) if getElementType ( source ) == "player" then setPedHeadless ( source, false ) end end Edited January 31, 2019 by Peti Link to comment
TheMagicano Posted January 31, 2019 Author Share Posted January 31, 2019 thank you for helping me, but its not working. Link to comment
Peti Posted January 31, 2019 Share Posted January 31, 2019 (edited) Do you have any errors or something to work with? It should work. Did you add the script at mtaserver.conf? Try without brackets like the original addEvent "onPlayerHeadshot" Edited January 31, 2019 by Peti Link to comment
TheMagicano Posted February 1, 2019 Author Share Posted February 1, 2019 3 hours ago, Peti said: Do you have any errors or something to work with? It should work. Did you add the script at mtaserver.conf? Try without brackets like the original addEvent "onPlayerHeadshot" oh sorry, it's working fine. but i was mean it's still same like first time. when i shot player in his head while he using armour he dead directly Link to comment
KillerX Posted February 1, 2019 Share Posted February 1, 2019 8 hours ago, TheMagicano said: oh sorry, it's working fine. but i was mean it's still same like first time. when i shot player in his head while he using armour he dead directly you want player lose his armour instead of dying ?? if you mean that : -- Client addEventHandler( 'onClientPlayerDamage' , root , function( attacker , weapon , bodypart ) if( weapon == 34 and bodypart == 9 )then if( getPedArmor( source ) == 0 ) then setPedHeadless( source , true ) timer = setTimer( function( source ) setPedHeadless( source , false ) ; end , 2000 , 1 , source ) triggerServerEvent( 'killPed' , source , attacker , weapon , bodypart ) else cancelEvent( true ) triggerServerEvent( 'removeArmour' , source ) end end end ) -- Server addEvent( 'removeArmour' , true ) addEventHandler( 'removeArmour' , root , function( ) setPedArmor( source , 0 ) end ) addEvent( 'killPed' , true ) addEventHandler( 'killPed' , root , function( ) killPed( source , attacker , weapon , bodypart ) end ) 1 Link to comment
TheMagicano Posted February 1, 2019 Author Share Posted February 1, 2019 1 hour ago, KillerX said: you want player lose his armour instead of dying ?? if you mean that : -- Client addEventHandler( 'onClientPlayerDamage' , root , function( attacker , weapon , bodypart ) if( weapon == 34 and bodypart == 9 )then if( getPedArmor( source ) == 0 ) then setPedHeadless( source , true ) timer = setTimer( function( source ) setPedHeadless( source , false ) ; end , 2000 , 1 , source ) triggerServerEvent( 'killPed' , source , attacker , weapon , bodypart ) else cancelEvent( true ) triggerServerEvent( 'removeArmour' , source ) end end end ) -- Server addEvent( 'removeArmour' , true ) addEventHandler( 'removeArmour' , root , function( ) setPedArmor( source , 0 ) end ) addEvent( 'killPed' , true ) addEventHandler( 'killPed' , root , function( ) killPed( source , attacker , weapon , bodypart ) end ) thank you so much but theres small bug in it, its make bug in jobs like police can kill police with headshot Link to comment
Peti Posted February 1, 2019 Share Posted February 1, 2019 (edited) Quote thank you so much but theres small bug in it, its make bug in jobs like police can kill police with headshot It isn't a bug, it doesn't even programmed in the code. You need to add teams to your script if you want to cancel the event from certain players to others. Btw, try to give details next time, you didn't mention armour. Instead you said this: Quote hey i was make headshot script for sniper but i was want it when player get headshot just lose 100hp from his heals can anyone help me please? Good luck. Edited February 1, 2019 by Peti 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