AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detect brokeable things (https://forums.alliedmods.net/showthread.php?t=51914)

NoobInAmxx 02-26-2007 12:57

Detect brokeable things
 
Is there any way to detect brokeable things like windows, boxes, gratings and also hostages?

mysticssjgoku4 02-26-2007 14:11

Re: Detect brokeable things
 
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 }

NoobInAmxx 02-26-2007 15:02

Re: Detect brokeable things
 
Quote:

Originally Posted by mysticssjgoku4 (Post 445908)
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..

mysticssjgoku4 02-26-2007 15:28

Re: Detect brokeable things
 
1 Attachment(s)
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 }

NoobInAmxx 02-26-2007 16:42

Re: Detect brokeable things
 
If i want kill all hostages at round start to ? And switch that on/off
PS: that script did work thanks.

Cheap_Suit 02-26-2007 20:53

Re: Detect brokeable things
 
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)



Hawk552 02-26-2007 21:44

Re: Detect brokeable things
 
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.

Cheap_Suit 02-26-2007 22:46

Re: Detect brokeable things
 
- Personal reasons even if its redundant and useless :mrgreen:. 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.

NoobInAmxx 02-27-2007 02:32

Re: Detect brokeable things
 
Thanks its working... hawk NoobInEverything would suit u actually better than for me..

Hawk552 02-27-2007 06:53

Re: Detect brokeable things
 
Quote:

Originally Posted by NoobInAmxx (Post 446130)
Thanks its working... hawk NoobInEverything would suit u actually better than for me..

Oh great one, "this generic degrading title may fit me quite well, but it fits you better!"

Quote:

Originally Posted by Cheap_Suit (Post 446087)
- Personal reasons even if its redundant and useless :mrgreen:. Unless it does something really terrible, then Ill change it.

Do you even understand that there actually is a difference? Declaring it in plugin_init means that it's destroyed when the function ends - there's not a bunch of garbage sitting there throughout the entire time the plugin is running. It has nothing to do with personal preference, it's just stupid.

Quote:

Originally Posted by Cheap_Suit (Post 446087)
- It's a [sic] modified [sic] right from fakemeta_util.

That doesn't change the fact that you're doing unnecessary operations. It's a stock in fakemeta_util because it won't necissarily be used by the plugin including it. Here, you're 100% sure it's going to be used, thus the stock tag is redundant and useless.

Quote:

Originally Posted by Cheap_Suit (Post 446087)
#edit:Trying to make it readable for me and thank you, I try my best not to make any of my scripts confusing.

Apparently you failed here. You managed to confuse me.


All times are GMT -4. The time now is 00:37.

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