AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Information about destroy objects on maps (https://forums.alliedmods.net/showthread.php?t=125973)

yetj 05-04-2010 07:02

Information about destroy objects on maps
 
I have a question and problem.
How can I make message, when someone destroy any object on map.
For example, on zm_ maps is footbridge and it have id 67 and what i must write in plugin to cause message when someone destroy it?

wrecked_ 05-04-2010 15:31

Re: Information about destroy objects on maps
 
Hook Ham_Killed for the classname of this "footbridge".

Code:
RegisterHam( Ham_Killed, "footbridge_classname", "HAM_Footbridge_Killed_Post", 1 )

yetj 05-04-2010 15:56

Re: Information about destroy objects on maps
 
Hmm good idea ;)
But how can I get classname when i have only ID this item?

wrecked_ 05-04-2010 15:59

Re: Information about destroy objects on maps
 
You shouldn't really use ID's, since they vary by server, but if it's just going to your server, use this.
Code:
#include <amxmodx> #include <fakemeta> #define ITEM_ID 9999 // your item id public plugin_init() {     register_plugin( "Classname Checker", "1.0", "Wrecked" )     register_clcmd( "say /cname", "CMD_Cname" ) } public CMD_Cname( id ) {     new cname[32]     pev( ITEM_ID, pev_classname, cname, 31 )     client_print( id, print_chat, "Classname: %s", cname ) }

Type /cname in all chat to get the classname of the item. Replace ITEM_ID's value of 9999 with the item ID.

yetj 05-04-2010 16:02

Re: Information about destroy objects on maps
 
Nice ;)
Very thanks for you :)

yetj 05-04-2010 18:41

Re: Information about destroy objects on maps
 
;(
This don't work.

I write it:

PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("name""1.0""author");
    
    
RegisterHam(Ham_Killed"func_breakable""Ham_destroy");
    
}

public 
Ham_destroy(itemdestroyershouldgib)
{
    new 
destroyerName[32];
    
get_user_name(destroyerdestroyerNamesizeof(destroyerName)-1);
    
    
client_print(0print_chat"*** %s destroy item ID: %d",destroyerNameitem);


and it never print any message when I destroy footbridge or window or etc. :(

drekes 05-05-2010 13:14

Re: Information about destroy objects on maps
 
i'm interested at this to, i've spend 3 houres figuring this out, but the function isn't called no matter what i do.
I'm curious what the asnwer will be

yetj 05-05-2010 13:17

Re: Information about destroy objects on maps
 
I found it:

PHP Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init() {
    
register_plugin("break_alert""1.0""commonbullet")
    
register_message(SVC_TEMPENTITY"check_breakable"
    
}

public 
check_breakable(msgid) {
    if(
get_msg_arg_int(1) != TE_BREAKMODEL)
        return 
PLUGIN_CONTINUE
    
    
new Float:br_origin[3]
    new 
Float:br_size[3]    
    new 
Float:tempvector[3]
    new 
Float:health
    
new classname[32]
    new 
ent

    br_origin
[0] = get_msg_arg_float(2)
    
br_origin[1] = get_msg_arg_float(3)
    
br_origin[2] = get_msg_arg_float(4)
    
br_size[0] = get_msg_arg_float(5)
    
br_size[1] = get_msg_arg_float(6)
    
br_size[2] = get_msg_arg_float(7)
    
    while((
ent engfunc(EngFunc_FindEntityInSphereentbr_origin0))) {
        
pev(entpev_classnameclassname31)
        if(
equal(classname"func_breakable")) {
            
pev(entpev_healthhealth)
            if(
health && !(pev(entpev_spawnflags) & SF_BREAK_TRIGGER_ONLY))
                continue            
            
// breakable is still solid when this message is thrown
            // so it'll block already broken entities
            
if(pev(entpev_solid) == SOLID_NOT
                continue
            
fm_get_brush_entity_origin(enttempvector)
            if(!
equal_vector(tempvectorbr_origin))
                continue
            
pev(entpev_sizetempvector)
            if(!
equal_vector(tempvectorbr_size))
                continue            
            
            
// ------ ADD HANDLE CODE... --------
            
client_print(0print_chat"Entity %d has been broken."ent)
            
// ----------------------------------
            
            
break
        }
    }
    return 
PLUGIN_CONTINUE  
}

fm_get_brush_entity_origin(entFloat:orig[3]) {
    
// converted to fm from engine stocks
    
new Float:Min[3]
    new 
Float:Max[3]
    
pev(entpev_minsMin)
    
pev(entpev_maxsMax)
    
    
orig[0] = (Min[0] + Max[0]) * 0.5
    orig
[1] = (Min[1] + Max[1]) * 0.5
    orig
[2] = (Min[2] + Max[2]) * 0.5

    
return 1
}

equal_vector(const Float:vector1[3], const Float:vector2[3]) {
    return ((
vector1[0] == vector2[0]) && (vector1[1] == vector2[1]) && (vector1[2] == vector2[2]))


and this work fine, but I don't have any idea how check who destroy it?
Any Ideas?


All times are GMT -4. The time now is 03:48.

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