AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [L4D2]Remove attached entities (https://forums.alliedmods.net/showthread.php?t=338838)

King_OXO 07-28-2022 17:01

[L4D2]Remove attached entities
 
does anyone know any script in which to remove all entities attached to the client with one command?

EXEAMPLE: !delete_attach
delete: Wings, LMC and Hats

I tried with my script, but the game crashes

Spoiler


who knew please help me

Marttt 07-28-2022 18:16

Re: [L4D2]Remove attached entities
 
You can try using the function made by Silvers in [ANY] Dev Cmds

Test first using "sm_attachments <client>" and check the output, if it does work the code is based on the snipper below.

Note: You may filter other stuff like weapons etc that may be attached as well.

PHP Code:

void GetAttachments(int clientint target)
{
    
char classname[64];

    for( 
int i 12048i++ )
    {
        if( 
IsValidEntity(i) && HasEntProp(iProp_Send"moveparent") && GetEntPropEnt(iProp_Send"moveparent") == target )
        {
            
GetEdictClassname(iclassnamesizeof(classname));
            if( 
target <= MaxClients )
            {
                
ReplyToCommand(client"Attachment %N: %d %s"targeticlassname);
            } else {
                
ReplyToCommand(client"Attachment %d: %d %s"targeticlassname);
            }
        }
    }



King_OXO 07-28-2022 18:55

Re: [L4D2]Remove attached entities
 
Quote:

Originally Posted by Marttt (Post 2785125)
You can try using the function made by Silvers in [ANY] Dev Cmds

Test first using "sm_attachments <client>" and check the output, if it does work the code is based on the snipper below.

Note: You may filter other stuff like weapons etc that may be attached as well.

PHP Code:

void GetAttachments(int clientint target)
{
    
char classname[64];

    for( 
int i 12048i++ )
    {
        if( 
IsValidEntity(i) && HasEntProp(iProp_Send"moveparent") && GetEntPropEnt(iProp_Send"moveparent") == target )
        {
            
GetEdictClassname(iclassnamesizeof(classname));
            if( 
target <= MaxClients )
            {
                
ReplyToCommand(client"Attachment %N: %d %s"targeticlassname);
            } else {
                
ReplyToCommand(client"Attachment %d: %d %s"targeticlassname);
            }
        }
    }



thank you, you always help me

Dragokas 08-05-2022 15:35

Re: [L4D2]Remove attached entities
 
It's better to use plugin-specific commands to clear its stuff, instead of forcibly remove them on your own. You risk having crash if the dependent plugin coded with not enough safety.


All times are GMT -4. The time now is 02:32.

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