AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bomb help (https://forums.alliedmods.net/showthread.php?t=156275)

Doc-Holiday 05-03-2011 17:16

Bomb help
 
Is there a way to locate who has the bomb and strip it from him??

epix 05-03-2011 17:35

Re: Bomb help
 
I'd do something like this to find the right player, not sure how to make him drop it.

Code:
public getBombPlayer() {     new Players[32]     new playerCount, i     get_players(Players, playerCount, "gh")         for (i=0; i < playerCount; i++) {         if(user_has_weapon(Players[i], "weapon_c4"))             return Players[i]     } }

(Not tested)

ConnorMcLeod 05-03-2011 17:54

Re: Bomb help
 
If you use orpheu, i think i have seen some usefull function to retrieve either bomb either bomb carrier.

Method above seems fine though.

EDIT :
Excepted flags wrong usage...

PHP Code:

get_bomb_carrier()
{
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum"ae""TERRORIST")
    for(--
iNumiNum>=0iNum--)
    {
        if( 
user_has_weapon(iPlayers[i], CSW_C4) )
        {
            return 
iPlayers[i]
        }
    }
    return 
0


Note that you could replcae user_has_weapon with cs_get_user_defuse.

Then, do:
engclient_cmd(player, "drop", "weapon_c4")

Doc-Holiday 05-03-2011 18:42

Re: Bomb help
 
I do use orpheu however codeing with it is confusing lol..

And small typo on yours iPlayers[i] should be iPlayers[iNum] :)

PHP Code:

public BombCarrier()
{
    new 
iPlayers[32], iNum;
    
get_players(iPlayersiNum"ae""TERRORIST");
    
    for(--
iNum;iNum>=0;iNum--)
    {
        if( 
user_has_weapon(iPlayers[iNum], CSW_C4) )
        {
            if(
iPlayers[iNum] != g_iLeaderid)
            {
                
engclient_cmd(iPlayers[iNum], "drop""weapon_c4");
                
                new 
bomb = -1
                while( ( 
bomb find_ent_by_modelbomb"weaponbox""models/w_backpack.mdl" ) ) )
                {
                    
remove_entitybomb );
                }

            }
        }
    }
    return 
0;



ConnorMcLeod 05-04-2011 01:39

Re: Bomb help
 
Don't forget to break/end the loop ;)

orpheu would let you do something like this :

Code:

if( (bomber = IsThereABomber()) )
{
 drop
 if( (bomb = IsThereABomb() )
 {
  remove
 }
}



All times are GMT -4. The time now is 04:29.

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