Skarbonke Posted June 28, 2017 Share 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 Link to comment
Moderators IIYAMA Posted June 28, 2017 Moderators Share Posted June 28, 2017 "onClientPlayerDamage" setElementHealth Link to comment
xMKHx Posted June 29, 2017 Share 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 ) Link to comment
Skarbonke Posted June 29, 2017 Author Share 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] Link to comment
xMKHx Posted June 29, 2017 Share 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 ) Link to comment
Skarbonke Posted June 29, 2017 Author Share 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 Link to comment
Skarbonke Posted June 29, 2017 Author Share Posted June 29, 2017 Just now, xMKHx said: 50% Damage ? Ye Link to comment
xMKHx Posted June 29, 2017 Share 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 ) Link to comment
Skarbonke Posted June 29, 2017 Author Share 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 Link to comment
pa3ck Posted June 29, 2017 Share 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 Link to comment
Skarbonke Posted June 29, 2017 Author Share 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 Link to comment
pa3ck Posted June 29, 2017 Share 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 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