AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   all ent affected by func_button (https://forums.alliedmods.net/showthread.php?t=140957)

GuessWhat 10-18-2010 01:49

all ent affected by func_button
 
how can i get all the ent affected/moved by a func_button. like in deathrun maps, i wanna know all the ents moved/affected after the player press the button

Schwabba 10-19-2010 03:48

Re: all ent affected by func_button
 
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <engine> 

PHP Code:

public plugin_init()
{
    
RegisterHam(Ham_Use"func_button""hamUseButton_Pre");


PHP Code:

public hamUseButton_Pre(buttonid)
{
    new 
szTarget[32]
    
pev(buttonpev_targetszTarget31)
    new 
ent = -1
    
while(ent find_ent_by_tname(entszTarget))
    {
        
// do something
    
}



GuessWhat 10-19-2010 04:13

Re: all ent affected by func_button
 
this code isn't working well, i wanna detect all ent affected by this button and set their pev_iuser4 to the id. but this code doesn't detect the affected ent well.

edit: the ent found was the ent that affect all other buttons so if i understand it well it looks like this :
func_button press > ent of the func_button is active > this ent active all other ents.

katna 10-20-2010 01:21

Re: all ent affected by func_button
 
try to detect how the "ent of the func_button" affect all the other ents

Schwabba 10-20-2010 02:28

Re: all ent affected by func_button
 
Ah now i know what you want.

It's because the multi_manager, the targets there can't be found with find_ent_by_target.

GuessWhat 10-20-2010 16:08

Re: all ent affected by func_button
 
yea multi_manager targets, but find_ent_in_shpere doesn't help in my cause i dont need the to ent in a certain distance i need ent affected.

Schwabba 10-21-2010 00:24

Re: all ent affected by func_button
 
It took my nerves, but finally i found a way how to do that. It's not the best way i think, but it works..

Example to remove all entities got triggered by the button:

PHP Code:

public affect(ent)
{
    
remove_entity (ent



PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <engine>

new PLUGIN[]  = "Buttons affect"
new AUTHOR[]  = "Schwabba"
new VERSION[] = "1.0"

new mIDmID2
new manager[100][100];
new 
manager_name[100][100];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Use"func_button""hamUseButton_Pre");
}

public 
hamUseButton_Pre(buttonid)
{
    new 
szTarget[32]
    
pev(buttonpev_targetszTarget31)
    new 
ent = -1
    
while((ent find_ent_by_tname(entszTarget)))
    {
        
affect(ent)
    }
    for(new 
i=0;i<mID;i++)
    {
        if(
manager[i][1] && equal(szTargetmanager_name[i]))
        {
            new 
ent = -1
            
while((ent find_ent_by_tname(entmanager[i])))
            {
                
affect(ent)
            }
        }
    }
}

public 
pfn_keyvalue(entid
{
    if(
is_valid_ent(entid))
    {
        new 
classname[33]
        new 
keyname[33]
        new 
keyvalue[33]
        
copy_keyvalue(classname,32,keyname,32,keyvalue,32)
        if(
equal(classname"multi_manager"))
        {
            if(!
equal(keyname"origin") && !equal(keyname"targetname") && !equal(keyname"spawnflags"))
            {
                
mID++
                
copy(manager[mID], 99keyname)
            }
            if(
equal(keyname"targetname"))
            {
                for(new 
i;i<mID;i++)
                {
                    if(
mID2-i)
                    {
                        
mID2 i+1
                        copy
(manager_name[mID2], 99keyvalue)
                    }
                }
            }
        }
    }
}

public 
affect(ent)
{
    
// Do something




All times are GMT -4. The time now is 10:22.

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