AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] [CS] remove multiple C4 (https://forums.alliedmods.net/showthread.php?t=206893)

alonelive 01-27-2013 05:24

[SOLVED] [CS] remove multiple C4
 
Hello all! I have a simple question.

PHP Code:

    new bomb
    
if ((bomb fm_find_ent_by_model(-1"grenade""models/w_c4.mdl")))
    {
        
fm_remove_entity(bomb)
    } 

This code removes a planted C4.

If I have 2 or more C4 (which planted on map) the code removes only LAST PLANTED C4.
How i can remove ALL c4 bombs from map (it's a simple fun mod). ?

ConnorMcLeod 01-27-2013 05:34

Re: [CS] remove multiple C4
 
1st you have to stop using fakemeta_util

Then, use a loop :

PHP Code:

#include <engine>
#tryinclude <cstrike_pdatas>

#if !defined _cbaseentity_included
        #assert Cstrike Pdatas and Offsets library required! Read the below instructions:   \
                
1. Download it at forums.alliedmods.net/showpost.php?p=1712101#post1712101   \
                
2. Put it into amxmodx/scripting/include/ folder   \
                
3. Compile this plugin locallydetailswiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29   \
                
4. Install compiled plugindetailswiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing
#endif

public RemoveC4All()
{
    new 
grenade FM_NULLENT
    
while( (grenade find_ent_by_class(grenade"grenade")) )
    {
        if( 
get_pdata_bool(grenadem_bIsC4XO_CGRENADE) )
        {
            
remove_entity(grenade)
        }
    }


Needed files are there : http://forums.alliedmods.net/showpos...01#post1712101

michal123 01-27-2013 05:35

Re: [CS] remove multiple C4
 
Maybe try this:
Code:

new g_Bomb = fm_find_ent_by_model(-1, "grenade", "models/w_c4.mdl");

while(g_Bomb){
        fm_remove_entity(g_Bomb);
        g_Bomb = fm_find_ent_by_model(-1, "grenade", "models/w_c4.mdl");
}


alonelive 01-31-2013 05:01

Re: [CS] remove multiple C4
 
Thank you all, question is solved.


All times are GMT -4. The time now is 20:38.

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