Raised This Month: $51 Target: $400
 12% 

Why Can I Not Replace Weapons On L4D2?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jackpf
Senior Member
Join Date: Dec 2009
Location: Uhm...
Old 12-21-2009 , 14:51   Why Can I Not Replace Weapons On L4D2?
Reply With Quote #1

Hi all,

I'm having trouble replacing weapons on left 4 dead 2.

I've had a look through some other mods, such as frustian (for l4d1) and seen how they did it, and used that as a basis. However, I just can't get it to work.

My code is below, and I have commented the functions that are/aren't working. If someone could possibly show me how they would accomplish this, or point me in the right direction, that would be awesome!

PHP Code:
//sdk tools
#include <sourcemod>
#include <sdktools>

//plugin version
#define PLUGIN_VERSION "0"

//plugin info
public Plugin:myinfo 
{
    
name        "Jackpf's Test",
    
author        "jackpf",
    
description    "Testing",
    
version        PLUGIN_VERSION,
    
url            "http://jackpf.co.uk"
}

//plugin setup
public OnPluginStart()
{
    
//console cmds
    
RegAdminCmd("sm_test"testADMFLAG_BAN);
    
RegAdminCmd("sm_test2"test2ADMFLAG_BAN);
}

public 
Action:test(clientargs)
{
    
/*
        This should replace all kits/defibs with pills - this works!!
    */
    
new string:EdictName[128];
    
    for(new 
0<= GetEntityCount(); i++)
    {
        if(
IsValidEntity(i))
        {
            
GetEdictClassname(iEdictNamesizeof(EdictName));
            
            if(    
StrContains(EdictName"weapon_first_aid_kit"false) != -||
                
StrContains(EdictName"weapon_defibrillator"false) != -1)
            {
                new 
index CreateEntityByName("weapon_pain_pills_spawn");
                if(
index != -1)
                {
                    new 
Float:Angle[3];
                    new 
Float:Location[3];
                    
                    
GetEntPropVector(iProp_Send"m_angRotation"Angle);
                    
GetEntPropVector(iProp_Send"m_vecOrigin"Location);
                    
                    
TeleportEntity(indexLocationAngleNULL_VECTOR);
                    
DispatchSpawn(index);
                }
                
                
AcceptEntityInput(i"Kill");
            }
        }
    }
    
    return 
Plugin_Handled;
}

public 
Action:test2(clientargs)
{
    
/*
        This should replace all auto shotguns with pump shotguns.
        However, it only removes shotguns that have been picked up, and not spawned ones.
        I tried adding the line (line 80) StrContains(EdictName, "weapon_autoshotgun_spawn", false) != -1
        But this crashes my server for some reason :/
    */
    
new string:EdictName[128];
    
    for(new 
0<= GetEntityCount(); i++)
    {
        if(
IsValidEntity(i))
        {
            
GetEdictClassname(iEdictNamesizeof(EdictName));
            
            if(    
StrContains(EdictName"weapon_autoshotgun"false) != -||
                
StrContains(EdictName"weapon_autoshotgun_spawn"false) != -1)
            {
                new 
index CreateEntityByName("weapon_pumpshotgun_spawn");
                if(
index != -1)
                {
                    new 
Float:Angle[3];
                    new 
Float:Location[3];
                    
                    
GetEntPropVector(iProp_Send"m_angRotation"Angle);
                    
GetEntPropVector(iProp_Send"m_vecOrigin"Location);
                    
                    
TeleportEntity(indexLocationAngleNULL_VECTOR);
                    
DispatchSpawn(index);
                }
                
                
AcceptEntityInput(i"Kill");
            }
        }
    }
    
    return 
Plugin_Handled;

Any help is much appreciated.

Thanks,
Jack.
jackpf is offline
Reply



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 01:53.


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