AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can use armor as health? (https://forums.alliedmods.net/showthread.php?t=98968)

Kation 07-31-2009 09:15

How can use armor as health?
 
I only can do this:
Code:

register_event("Damage", "event_damagechaneg", "be")
 
 
public event_damagechaneg(id) {
 new iDamage = read_data(2)
 new playerap = get_user_armor(id)
 new playerhp = get_user_health(id)
 if (playerap - iDamage >= 0 ) {
  cs_set_user_armor(id, playerap - iDamage ,CS_ARMOR_VESTHELM)
  set_user_health(id ,playerhp + iDamage)
 }
 else if ((playerap - iDamage < 0 ) && (playerap + playerhp - iDamage > 0)) {
  cs_set_user_armor(id,0,CS_ARMOR_VESTHELM)
  set_user_health(id ,playerhp + playerap - iDamage)
 }

But, if iDamage > playerhp , then whatever playerap he will dead...

One 07-31-2009 10:01

Re: How can use armor as health?
 
why u dont get user armor & set_user_health(id, user_armor)? or u mean anything else?

public event_damagechaneg(id)
{
new user_armor = get_user_armor(id)
new g_damage = read_data(2)
new user_health = get_user_health(id)
new new_arm = user_armor + g_damage
if(user_armor - g_damage >= 0)
{
cs_set_user_armor(id,new_arm,CS_ARMOR_VESTHEL M)
}
else if ((user_armor - g_damage <= 0 )&& (user_armor + user_health - g_damage >= 0))
{
cs_set_user_armor(id,0,CS_ARMOR_VESTHELM)
set_user_health(id,new_arm - g_damage)
}
}

test this one. idk if this is realy that what u want. hope could help

Kation 07-31-2009 10:30

Re: How can use armor as health?
 
Thanks.
But I mean that when you attack me, my armor will reduce as health if armor more than damage.

Example:
My HP100, AP50.
You attack me 30 of damage.
Then I have HP100, AP20.

If My HP20, AP50.
You attack me 60 of damage.
Then I have HP10, AP0.

AP is armor.
HP is health.


My English doesn't very well.
Do you know what I was say?

Kation 07-31-2009 22:34

Re: How can use armor as health?
 
Anybody can help me?

Owyn 08-01-2009 07:05

Re: How can use armor as health?
 
use hamdamage prehook get armor there, the use post hook and see armor taken, replenish it, reduce armor by damage number and supercode damage


All times are GMT -4. The time now is 18:20.

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