View Single Post
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 11-21-2010 , 06:45   Re: [l4d2] single pickup weapons
Reply With Quote #16

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

static const String:t2strings[][] = {
                                    
"weapon_autoshotgun",
                                    
"weapon_shotgun_spas",
                                    
"weapon_hunting_rifle",
                                    
"weapon_sniper",
                                    
"weapon_rifle"
                                    
};
                                    
static const        
t2weaponIDs[] = {
                                    
4,
                                    
5,
                                    
6,
                                    
9,
                                    
10,
                                    
11,
                                    
26,
                                    
34,
                                    
35,
                                    
36
                                    
};

/*
#define PISTOL                     1
#define SMG                     2
#define PUMPSHOTGUN             3
#define AUTOSHOTGUN             4
#define RIFLE                     5
#define HUNTING_RIFLE             6
#define SMG_SILENCED             7
#define SHOTGUN_CHROME             8
#define RIFLE_DESERT             9
#define SNIPER_MILITARY         10
#define SHOTGUN_SPAS             11
#define MOLOTOV                 13
#define PIPE_BOMB                 14
#define VOMITJAR                 25
#define RIFLE_AK47                 26
#define PISTOL_MAGNUM             32
#define SMG_MP5                 33
#define RIFLE_SG552             34
#define SNIPER_AWP                 35
#define SNIPER_SCOUT             36
*/

static const String:GENERIC_WEAPON[]         = "weapon_spawn";
static const 
String:WEAPON_ID_ENTPROP[]        = "m_weaponID";


public 
OnPluginStart()
{
    
HookEvent("player_use"Event_PlayerUse);
}

public 
Action:Event_PlayerUse(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
item GetEventInt(event"targetid");
    
    if (
IsValidEdict(item)
    && 
IsT2Gun(item))
    {
        
RemoveEdict(item);
    }
}

static 
bool:IsT2Gun(item)
{
    
decl String:itemname[64];
    
GetEdictClassname(itemitemnamesizeof(itemname));
    
    if (
StrEqual(itemnameGENERIC_WEAPONfalse))
    {
        new 
gunid GetEntProp(itemProp_SendWEAPON_ID_ENTPROP);
        
        for (new 
0sizeof(t2weaponIDs); x++)
        {
            if (
gunid == t2weaponIDs[x])
            {
                return 
true;
            }
        }
        
        return 
false;
    }
    
    for (new 
0sizeof(t2strings); i++)
    {
        if (
StrContains(t2strings[i], itemnamefalse) != -1)
        {
            return 
true;
        }
    }
    
    return 
false;

You expected me to playtest this?! I had a string pair the wrong way around. For an added bonus ive put the weapon_spawn stuff into it now aswell, which covers saferooms etc
Attached Files
File Type: sp Get Plugin or Get Source (l4d2_singlet2guns.sp - 1050 views - 1.9 KB)
AtomicStryker is offline