AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   funny consequences [armor problem] (https://forums.alliedmods.net/showthread.php?t=221734)

avril-lavigne 07-25-2013 17:19

funny consequences [armor problem]
 
Im my plugin I use armor calculations. so it takes 2/3 of damage like this

Code:

 

iDamage = DAMAGE / 3
set_pev(i, pev_armorvalue,Armor-floatround(damage) / 1.5)

as you see if some one dealt 100 damage to me, 100/3=33.33 , I would have - 100-33=77hp
and armor 100-66=33.

the problem is when damage is too high (100-120) and I have Low armor (10-30) after hit I have armor with negative values like -20, -30 ...

avril-lavigne 07-25-2013 17:52

Re: funny consequences [armor problem]
 
Bos93 < i know you are god of scripting. but shut your mouth and go away from this thread.

should I use "min" or "max" ? max(val1,val2)

ConnorMcLeod 07-25-2013 19:27

Re: funny consequences [armor problem]
 
Just make sure final value is not < 0
set_pev(i, pev_armorvalue, floatmax(YOUR_CALCULATION, 0.0))

Anyway, if it is for cs, you should use cs_set_user_armor, so you can set armortype to 0 when armorvalue is 0, and if, before calcultion, armor amount is > 0 but armortype is 0 (can happen if a bad plugin is used), do nothing.

avril-lavigne 07-28-2013 22:53

Re: funny consequences [armor problem]
 
your floatmax works well. tnhx


All times are GMT -4. The time now is 06:23.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.