knightscript Posted January 21, 2016 Share Posted January 21, 2016 Hello, im trying to create a new damage system, first by Setting all weapon´s properties damage to 0, and afterwards, and then getelementdata of the player, if he is in group "Everyone" then get the damage in the element, etc, but what I want to do is this: 1.) check if the player has armor, 2.) if he has armor, check how much is it, 3.) if the damage specified in getelementdata of the attacker is for example, 20, and the player has 10% armor, i want to be able to remove 10% armor and 10% health. I don´t know if im explaining myself. I hope yes, what functions should i use? thanks. Link to comment
tosfera Posted January 21, 2016 Share Posted January 21, 2016 getElementData getPedArmor setPedArmor getElementHealth setElementHealth That's most likely everything you should use. Link to comment
knightscript Posted January 21, 2016 Author Share Posted January 21, 2016 Alright, thanks, one more thing, when i set all weapons properties damage to 0, also the accuracy goes to maximum, do you know how can i fix this? Link to comment
knightscript Posted January 21, 2016 Author Share Posted January 21, 2016 hey tosfera, if for example, i have shoot a player with 100% health and 10% armor, and my weapon does 20% per shot, how can set it to delete the players armor and if there is any number of damage left, remove it from the health? Link to comment
ViRuZGamiing Posted January 21, 2016 Share Posted January 21, 2016 What you could do is check if the amount going off of the armor (ex. 20) is greater then the remaining armor (ex. 10). Then do; (if 20 > 10 then), In that case you could do (20 - 10) and then 10 is your difference. Set armor to 0 and take the remaining 10 off of the health. Example in LUA (might not be the best solution) function damageFunc (attacker, attackerweapon, bodypart, loss) cancelEvent() -- Not sure but I think if not cancelling it the damage is doubled local armor = getPedArmor(source) -- example. no armor, armor is 0 if (loss > armor) then loss = loss - armor -- Loss example 20, loss = 20 - 0 = 20 setPedArmor(source, 0) setElementHealth(source, (getElementHealth(source) - loss) -- health - 20 else setPedArmor(source, (armor - loss)) end end addEventHandler("onPlayerDamage", getRootElement(), damageFunc) Link to comment
knightscript Posted January 21, 2016 Author Share Posted January 21, 2016 Nice ViRuZ, i will test it out, so canceling the event would null the damage by default right? that is great, because i was having problems with setweaponproperty! Link to comment
tosfera Posted January 22, 2016 Share Posted January 22, 2016 setWeaponProperty requires more than just editing the damage. You can better cancel the event and create a table in lua with all the weapons and their damages. Just know that if you want to make it more realistic, you should count in body parts too. Link to comment
ViRuZGamiing Posted January 22, 2016 Share Posted January 22, 2016 setWeaponProperty requires more than just editing the damage. You can better cancel the event and create a table in lua with all the weapons and their damages. Just know that if you want to make it more realistic, you should count in body parts too. I was actually thinking the same but thought that the weapon property would be easier. 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