Raised This Month: $ Target: $400
 0% 

Making a door take damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EagleEye
New Member
Join Date: Jul 2008
Old 07-21-2008 , 13:51   Making a door take damage
Reply With Quote #1

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?
EagleEye is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 07-21-2008 , 21:04   Re: Making a door take damage
Reply With Quote #2

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.
danielkza is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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