AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Making a door take damage (https://forums.alliedmods.net/showthread.php?t=74585)

EagleEye 07-21-2008 13:51

Making a door take damage
 
I am working on a plugin that I need to make doors take damage and then be destroyed after taking so much. I also need to have the amount of health of the doors to vary and also be edited in the game. This plugin is for The Specialists mod.

So far, I have gotten windows in the game(func_breakable) to do what I needed, but I can't get the doors (func_door and func_door_rotating) to do the same. I made a simple plugin to test the things and here is the code for changing the doors and windows health:

Code:

public sethp()
{
 new arg1[32],arg2[32],arg3[32],arg4[32]
 read_argv(1,arg1,31)
 read_argv(2,arg2,31)
 read_argv(3,arg3,31)
 read_argv(4,arg4,31)
 
 new Float:maxhp = str_to_float(arg1)
 new Float:hp = str_to_float(arg2)
 new Float:dmg = str_to_float(arg3)
 new Float:takedmg = str_to_float(arg4)
 
 new iEnts = entity_count()
 for(new i = 0; i < iEnts ; i++)
 {
      if(!is_valid_ent(i)) continue
      new text[32]
      entity_get_string(i,EV_SZ_classname,text,31)
      if( equali(text,"func_door" ) || equali(text,"func_door_rotating"))
      {
          entity_set_float(i,EV_FL_max_health,maxhp)
          entity_set_float(i,EV_FL_health,hp)
          entity_set_float(i,EV_FL_dmg,dmg)
          entity_set_float(i,EV_FL_takedamage,takedmg)
      }
      if(equali(text,"func_breakable"))
      {
          entity_set_float(i,EV_FL_max_health,maxhp)
          entity_set_float(i,EV_FL_health,hp)
          entity_set_float(i,EV_FL_dmg,dmg)
          entity_set_float(i,EV_FL_takedamage,takedmg)
      }
 }
 return PLUGIN_HANDLED
}

Even after I change the health of the door with
Code:

entity_set_float(i,EV_FL_health,hp)
it still destroys the door in the same amount of hits. When I do this to the window it destroys it depending on the health. Any suggestions on how to fix it or alternative methods?

danielkza 07-21-2008 21:04

Re: Making a door take damage
 
Hook TakeDamage using Ham Sandwich, count the damage yourself, ignore damages made by the engine,and when your count reaches the target,destroy the door manualy.


All times are GMT -4. The time now is 05:34.

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