AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Make all players drop all weapons except knife (https://forums.alliedmods.net/showthread.php?t=147470)

Pantheon 01-09-2011 15:26

Make all players drop all weapons except knife
 
How can i do this?

sibox 01-09-2011 15:28

Re: Make all players drop all weapons except knife
 
loop through all players and then strip_user_weapons();

Elusive138 01-10-2011 00:35

Re: Make all players drop all weapons except knife
 
And then give_item(id, "weapon_knife")

drekes 01-10-2011 00:46

Re: Make all players drop all weapons except knife
 
That's stripping weapons, not dropping.

Elusive138 01-10-2011 00:59

Re: Make all players drop all weapons except knife
 
True.. maybe client_cmd(id, slot1;+attack;-attack;drop;slot2;+attack;-attack;drop)

That won't work if there's a multi-weapon plugin (or some other way of getting more than 1 weapon each slot). And slot5 for bomb and grenades can't be dropped.

In any case, there isn't much point to dropping weapons only to have them picked up a second later. If you only want the player to be holding a knife, stripping is better.

ConnorMcLeod 01-10-2011 02:16

Re: Make all players drop all weapons except knife
 
You can take code from here : http://forums.alliedmods.net/showthread.php?p=761924

If you don't care about bpammo, here are 2 other simpler ways :

PHP Code:

const NODROP_WPNS_BITSUM = (1<<CSW_KNIFE)|(1<<CSW_HEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_SMOKEGRENADE)

#define FIRST_WEAPON = CSW_P228
#define LAST_WEAPON = CSW_P90

DropPlayerWeaponsid )
{    
    new 
iWeapons[32], iNumiWeapon
    get_user_weapons
(idiWeaponsiNum)
    new 
szWeaponName[22]
    for(--
iNumiNum>=0iNum--)
    {
        
iWeapon iWeapons[iNum]
        if( 
iWeapons & (1<<iWeapon) && ~NODROP_WPNS_BITSUM & (1<<iWeapon) )
        {
            
get_weaponname(iWeaponszWeaponNamecharsmax(szWeaponName))
            
engclient_cmd(id"drop"szWeaponName)
        }
    }
}

DropPlayerWeapons2id )
{
    new 
iWeapons pev(idpev_weapons)
    new 
szWeaponName[22]
    for(new 
iWeapon FIRST_WEAPONiWeapon<=LAST_WEAPONiWeapons++)
    {
        if( 
iWeapons & (1<<iWeapon) && ~NODROP_WPNS_BITSUM & (1<<iWeapon) )
        {
            
get_weaponname(iWeaponszWeaponNamecharsmax(szWeaponName))
            
engclient_cmd(id"drop"szWeaponName)
        }
    }




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

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