Raised This Month: $ Target: $400
 0% 

Detect brokeable things


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NoobInAmxx
Senior Member
Join Date: Mar 2006
Location: Turku Finland
Old 02-26-2007 , 12:57   Detect brokeable things
Reply With Quote #1

Is there any way to detect brokeable things like windows, boxes, gratings and also hostages?
__________________
..Im not smart and im not stupid..
NoobInAmxx is offline
Send a message via MSN to NoobInAmxx
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-26-2007 , 14:11   Re: Detect brokeable things
Reply With Quote #2

How do you want to detect them, and why?

----
The code below finds the breakable entity around a player, and returns the Entity ID of the first find.
Code:
stock find_breakable_thing(id) {     new ent, Float:origin[3],Float:radius = 64.0, classname[64]     entity_get_vector(id,EV_VEC_origin,origin)     while((ent = find_ent_in_sphere(ent,origin,radius)) != 0)     {         entity_get_string(ent,EV_SZ_classname,classname,63)         if(equali(classname,"func_breakable"))         {             //Code here                         return ent;         }     }     return 0 }
__________________


Last edited by mysticssjgoku4; 02-26-2007 at 14:15.
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
NoobInAmxx
Senior Member
Join Date: Mar 2006
Location: Turku Finland
Old 02-26-2007 , 15:02   Re: Detect brokeable things
Reply With Quote #3

Quote:
Originally Posted by mysticssjgoku4 View Post
How do you want to detect them, and why?

----
The code below finds the breakable entity around a player, and returns the Entity ID of the first find.
Code:
stock find_breakable_thing(id) {     new ent, Float:origin[3],Float:radius = 64.0, classname[64]     entity_get_vector(id,EV_VEC_origin,origin)     while((ent = find_ent_in_sphere(ent,origin,radius)) != 0)     {         entity_get_string(ent,EV_SZ_classname,classname,63)         if(equali(classname,"func_breakable"))         {             //Code here                         return ent;         }     }     return 0 }
because i want blow them up when round starts in (freezetime) because if user got stripped out of weapons they can't broke them..
__________________
..Im not smart and im not stupid..
NoobInAmxx is offline
Send a message via MSN to NoobInAmxx
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-26-2007 , 15:28   Re: Detect brokeable things
Reply With Quote #4

Not sure if this works because of the EVENT in CS, but try this:

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #define PLUGIN "Breakable Ent Destroyer" #define VERSION "1.0" #define AUTHOR "Remo Williams" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_event("ResetHUD","client_spawn","b") } public client_spawn(id) {     new ent     while((ent = find_ent_by_class(0,"func_breakable")) != 0)     {         remove_entity(ent)     }     return PLUGIN_HANDLED }
Attached Files
File Type: sma Get Plugin or Get Source (breakable_ent_destroyer.sma - 684 views - 444 Bytes)
__________________


Last edited by mysticssjgoku4; 02-26-2007 at 15:31.
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
NoobInAmxx
Senior Member
Join Date: Mar 2006
Location: Turku Finland
Old 02-26-2007 , 16:42   Re: Detect brokeable things
Reply With Quote #5

If i want kill all hostages at round start to ? And switch that on/off
PS: that script did work thanks.
__________________
..Im not smart and im not stupid..

Last edited by NoobInAmxx; 02-26-2007 at 16:49.
NoobInAmxx is offline
Send a message via MSN to NoobInAmxx
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 02-26-2007 , 20:53   Re: Detect brokeable things
Reply With Quote #6

Reference:http://forums.alliedmods.net/showthread.php?t=42159

Note: Untested
PHP Code:
#include <amxmodx>
#include <fakemeta>

static const PLUGIN_NAME[]     = "Remove Breakable Stuff & Hostages"
static const PLUGIN_AUTHOR[]     = "Cheap_Suit"
static const PLUGIN_VERSION[]    = "1.0"

public plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
    
register_cvar(PLUGIN_NAMEPLUGIN_VERSIONFCVAR_SPONLY|FCVAR_SERVER)
    
register_event("HLTV""event_hltv""a""1=0""2=0")
}

public 
event_hltv()
{
    
remove_entity_by_classname("func_breakable")
    
remove_entity_by_classname("hostage_entity")
    
remove_entity_by_classname("scientist_entity")
}

stock remove_entity_by_classname(const classname[]) 
{
    new 
ent = -1
    
while((ent engfunc(EngFunc_FindEntityByStringent"classname"classname)))
        
engfunc(EngFunc_RemoveEntityent)

__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.

Last edited by Cheap_Suit; 02-27-2007 at 06:20.
Cheap_Suit is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-26-2007 , 21:44   Re: Detect brokeable things
Reply With Quote #7

Okay Cheap_Suit, you got me here.

Why did you declare the global variables as static? It's redundant, it's like calling it "global global". The best thing to do would be to just declare them in plugin_init, like so:

Code:
//... public plugin_init() {     new PLUGIN_NAME[]     = "Remove Breakable Stuff & Hostages"     new PLUGIN_VERSION[]    = "1.0"     new PLUGIN_AUTHOR[]     = "Cheap_Suit"     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)     register_cvar(PLUGIN_NAME, PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER) //...


Also, why did you make the remove_entity_by_classname function a stock? All that does is slow the compiler down and make it look like crap. Just make it a private function. If you were trying to make your script look nice and confusing, you failed.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 02-26-2007 , 22:46   Re: Detect brokeable things
Reply With Quote #8

- Personal reasons even if its redundant and useless . Unless it does something really terrible, then Ill change it.
- It's a modified right from fakemeta_util.

#edit:
Quote:
If you were trying to make your script look nice and confusing, you failed.
Trying to make it readable for me and thank you, I try my best not to make any of my scripts confusing.
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.

Last edited by Cheap_Suit; 02-27-2007 at 06:18. Reason: P.S. Im still a noob
Cheap_Suit 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 00:37.


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