Skarbonke 7 Posted June 28, 2017 (edited) So hey there, it's me again :D, how to make a guns (ex. deagle, sniper) damage, like if you hit the head you do 50 damage, if you hit in the legs you do 20 damage, chest 30 damage, arms 10 damage ? Edited June 28, 2017 by Skarbonke Word correction :c Share this post Link to post
xMKHx 17 Posted June 29, 2017 local BodyPart = -- Add you Body part here for the shot part, Ex: Head, Leg if bodypart == BodyPart then if ( getPlayerWeapon(theAttacker) == wepID ) setElementHealth(theVectim, health ) Share this post Link to post
Skarbonke 7 Posted June 29, 2017 2 hours ago, xMKHx said: local BodyPart = -- Add you Body part here for the shot part, Ex: Head, Leg if bodypart == BodyPart then if ( getPlayerWeapon(theAttacker) == wepID ) setElementHealth(theVectim, health ) local BodyPart = Head if bodypart == BodyPart then if ( getPlayerWeapon(theAttacker) == 24 ) then setElementHealth(theVectim, 50 ) end end That gave me an error: 3: Bad argument "getPlayerWeapon"[expected ped at argument 1, got nil] Share this post Link to post
xMKHx 17 Posted June 29, 2017 I didn't give you a full or working functions If you want a working one use this Its Server Side addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then if ( getPlayerWeapon(attacker) == wepID ) killPed(source, attacker, weapon, bodypart) end end end ) Share this post Link to post
Skarbonke 7 Posted June 29, 2017 3 minutes ago, xMKHx said: I didn't give you a full or working functions If you want a working one use this Its Server Side addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then if ( getPlayerWeapon(attacker) == wepID ) killPed(source, attacker, weapon, bodypart) end end end ) I don't need 1 shot kill Share this post Link to post
xMKHx 17 Posted June 29, 2017 Try This addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then if ( getPlayerWeapon(attacker) == wepID )² setElementHealth(source -50) end end end ) Share this post Link to post
Skarbonke 7 Posted June 29, 2017 addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then if then ( getPlayerWeapon(attacker) == 24 )² setElementHealth(source -50) end end end ) I get an error that says:5: unexpected symbol near "then" , and i can't get it right Share this post Link to post
pa3ck 207 Posted June 29, 2017 (edited) addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then if getPlayerWeapon(attacker) == 24 then setElementHealth(source, getElementHealth(source) -50) end end end ) 15 minutes ago, xMKHx said: Try This addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then if ( getPlayerWeapon(attacker) == wepID )² setElementHealth(source -50) end end end ) Man, please at least look at your code again and double check it, I know you're trying to help but try to make sure you're not making at least syntax mistakes.. Edited June 29, 2017 by pa3ck 2 Share this post Link to post
Skarbonke 7 Posted June 29, 2017 4 minutes ago, pa3ck said: addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then if getPlayerWeapon(attacker) == 24 then setElementHealth(source, getElementHealth(source) -50) end end end ) Man, please at least look at your code again and double check it, I know you're trying to help but try to make sure you're not making at least syntax mistakes.. Thank u, it worked :3 Share this post Link to post
pa3ck 207 Posted June 29, 2017 (edited) local weaponTable = { -- populate this list by adding weapons: -- [weap_id] = { torso, ass, left_arm, right_arm, left_leg, right_leg, head } [24] = { 45, 35, 30, 30, 25, 25, 70 }, } addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if getElementType(attacker) == "player" and getPlayerWeapon(attacker) and weaponTable[ getPlayerWeapon(attacker) ] then setElementHealth(source, getElementHealth(source) - weaponTable[ getPlayerWeapon(attacker) ] [ bodyPart - 2] + loss) end end ) You're welcome, you can use the following code to create a fully dynamic system. You can set each body part for each weapon using the weaponTable, just follow the current layout of weapon ID 24. Edited June 29, 2017 by pa3ck 1 Share this post Link to post