Raised This Month: $32 Target: $400
 8% 

[SOLVED]L4D2 Removing all weapons except the ones held


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fleepster99
Senior Member
Join Date: Apr 2010
Old 09-01-2010 , 20:58   [SOLVED]L4D2 Removing all weapons except the ones held
Reply With Quote #1

Ok guys so i have this code to remove all guns,


PHP Code:
new EntCount GetEntityCount();
new 
String:EdictName[128];
for (new 
0<= EntCounti++)
        {
            if (
IsValidEntity(i))
            {
                
GetEdictClassname(iEdictNamesizeof(EdictName));

                    if (
StrContains(EdictName"weapon_pistol"false) != -||
                    
StrContains(EdictName"weapon_autoshotgun"false) != -||
                    
StrContains(EdictName"weapon_hunting_rifle"false) != -||
                    
StrContains(EdictName"weapon_pistol_magnum"false) != -||
                    
StrContains(EdictName"weapon_pumpshotgun"false) != -||
                    
StrContains(EdictName"weapon_rifle"false) != -||
                    
StrContains(EdictName"weapon_rifle_ak47"false) != -||
                    
StrContains(EdictName"weapon_rifle_desert"false) != -||
                    
StrContains(EdictName"weapon_rifle_sg552"false) != -||
                    
StrContains(EdictName"weapon_rifle_m60"false) != -||
                    
StrContains(EdictName"weapon_shotgun_chrome"false) != -||
                    
StrContains(EdictName"weapon_smg"false) != -||
                    
StrContains(EdictName"weapon_smg_mp5"false) != -||
                    
StrContains(EdictName"weapon_smg_silenced"false) != -||
                    
StrContains(EdictName"weapon_sniper_awp"false) != -||
                    
StrContains(EdictName"weapon_sniper_military"false) != -||
                    
StrContains(EdictName"weapon_sniper_scout"false) != -||
                    
StrContains(EdictName"weapon_grenade_launcher"false) != -||
                    
StrContains(EdictName"weapon_autoshotgun_spawn"false) != -)
{
AcceptEntityInput(i"Kill");

And i know this removes all weapons mentioned, what i want to do is remove all weapons other than the ones the players are holding.
Ive looked through a fair amount of threads but none helped.
Any clue on how i would do that?

Thanks for your help.

Last edited by Fleepster99; 09-01-2010 at 21:42.
Fleepster99 is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 09-02-2010 , 09:28   Re: L4D2 Removing all weapons except the ones held
Reply With Quote #2

weapon = GetEntPropEnt(survivor, Prop_Send, "m_hActiveWeapon");
AtomicStryker is offline
Fleepster99
Senior Member
Join Date: Apr 2010
Old 09-02-2010 , 11:15   Re: L4D2 Removing all weapons except the ones held
Reply With Quote #3

Quote:
Originally Posted by AtomicStryker View Post
weapon = GetEntPropEnt(survivor, Prop_Send, "m_hActiveWeapon");
Thanks for that but, the way i have implemented it stops the weapon being held from being removed but all other slots for example the pistols will be taken from me, is there anyways i can check the main weapon and secondary without having them equipped.
Heres my latest script

PHP Code:
public Action:Remove_weapons(Handle:Timer
{
    new 
EntCount GetEntityCount();
    new 
j,i;
    new 
String:EdictName[128];
    new 
String:WeaponName[128];
    new 
weapon;
    
    
//new Float:PlayerLocation[3];

    
    
    
for (1<= MaxClientsj++)
    {
        if (
IsClientInGame(j) && GetClientTeam(j)==&& !IsFakeClient(j))
        {
        
        
weapon GetEntPropEnt(jProp_Send"m_hActiveWeapon");  
        if (
IsValidEdict(weapon))
            {
        
GetEdictClassname(weaponWeaponNamesizeof(WeaponName));
            }
        for (
0<= EntCounti++)
        {
            if (
IsValidEntity(i))
            {
                
GetEdictClassname(iEdictNamesizeof(EdictName));
                if (
StrContains(EdictName"weapon_pistol"false) != -||
                
StrContains(EdictName"weapon_autoshotgun"false) != -||
                
StrContains(EdictName"weapon_hunting_rifle"false) != -||
                
StrContains(EdictName"weapon_pistol_magnum"false) != -||
                
StrContains(EdictName"weapon_pumpshotgun"false) != -||
                
StrContains(EdictName"weapon_rifle"false) != -||
                
StrContains(EdictName"weapon_rifle_ak47"false) != -||
                
StrContains(EdictName"weapon_rifle_desert"false) != -||
                
StrContains(EdictName"weapon_rifle_sg552"false) != -||
                
StrContains(EdictName"weapon_rifle_m60"false) != -||
                
StrContains(EdictName"weapon_shotgun_chrome"false) != -||
                
StrContains(EdictName"weapon_smg"false) != -||
                
StrContains(EdictName"weapon_smg_mp5"false) != -||
                
StrContains(EdictName"weapon_smg_silenced"false) != -||
                
StrContains(EdictName"weapon_sniper_awp"false) != -||
                
StrContains(EdictName"weapon_sniper_military"false) != -||
                
StrContains(EdictName"weapon_sniper_scout"false) != -||
                
StrContains(EdictName"weapon_grenade_launcher"false) != -||
                
StrContains(EdictName"weapon_melee"false) != -)
                {

                    
                    if (
StrEqual(WeaponNameEdictName))
                    {
                    
//PrintToChatAll("Guns =%s and %s  ", EdictName , WeaponName);    
                    
}
                    else
                    {
                    
AcceptEntityInput(i"Kill");
                        
//PrintToChatAll("removing %s", EdictName);
                    
}
                }
            }    
            }
        }    
        
PrintToChatAll("weapon is %s"WeaponName);    
        }

    } 
Appreciate the help.
Fleepster99 is offline
dirka_dirka
Veteran Member
Join Date: Nov 2009
Old 09-02-2010 , 13:16   Re: L4D2 Removing all weapons except the ones held
Reply With Quote #4

in my modification of atomics respawn plugin i remove every weapon slot of players with:
PHP Code:
    // first remove any the player has..
    
new entity;
    for (new 
i=0i<4i++) {
        
entity GetPlayerWeaponSlot(clienti);
        if (
IsValidEdict(entity)) {
            
RemovePlayerItem(cliententity);
            
RemoveEdict(entity);
        }
    } 
you should be able to modify that easily enough for what you need.
dirka_dirka is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 09-03-2010 , 06:05   Re: L4D2 Removing all weapons except the ones held
Reply With Quote #5

Make sure the removed entity is not a m_hActiveWeapon and check it for not being the pistol slot item, too. I dont know right off the bat which one it was, just check.
AtomicStryker is offline
Fleepster99
Senior Member
Join Date: Apr 2010
Old 09-03-2010 , 07:53   Re: L4D2 Removing all weapons except the ones held
Reply With Quote #6

Thanks for your help guys, i solved it using dirka dirka's method.
Fleepster99 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:46.


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