Raised This Month: $ Target: $400
 0% 

[:3] TF2_CTFWeaponInfo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 09-15-2010 , 08:45   Re: [:3] TF2_CTFWeaponInfo
Reply With Quote #1

Changes still seem to work for me however I just tested it using a slightly different function.

PHP Code:
CON_COMMAND(wazz_replaceweapon"Wazz Environment :: Weapon info replacing. Format <weapon1> <weapon2>")
{
    if (
args.ArgC() == 1)
    {
        
META_CONPRINTF("Wazz Environment :: Weapon info replacing. Format <weapon1> <weapon2>\n");
        return;
    }

    if (!
g_pWeaponInfoDatabase)
    {
#ifdef _WIN32
        
void *addr;
        
int offset;

        if (!
g_pGameConf->GetMemSig("ReadWeaponDataFromFileForSlot_SubCall_01", &addr) || !addr)
        {
            
META_CONPRINTF("NULL 1\n");
            return;
        }

        if (!
g_pGameConf->GetOffset("WeaponDatabase_Offset", &offset))
        {
            
META_CONPRINTF("NULL 2\n");
            return;
        }
        
        
g_pWeaponInfoDatabase = *(WeaponDatabase **)((uint32)addr offset);
#else
        
void *addr;
        if (!
g_pGameConf->GetMemSig("m_WeaponInfoDatabase", &addr) || !addr)
        {
            
META_CONPRINTF("NULL 1\n");
            return;
        }
        
        
g_pWeaponInfoDatabase = (WeaponDatabase *)addr;
#endif
        
        
META_CONPRINTF("Address: %p\n"g_pWeaponInfoDatabase);
        
META_CONPRINTF("Count: %i\n"g_pWeaponInfoDatabase->Count());
    }

    if (
args.ArgC() != 3)
    {
        
META_CONPRINTF("Not enough args. Format <weapon1> <weapon2>\n");

        return;
    }

    const 
char *pszWpn args.Arg(1);
    const 
char *pszSwap args.Arg(2);

    
int iIndex1 g_pWeaponInfoDatabase->Find(pszWpn);

    if (!
g_pWeaponInfoDatabase->IsValidIndex(iIndex1))
    {
        
META_CONPRINTF("Invalid Name: %s\n"pszWpn);

        return;
    }

    
int iIndex2 g_pWeaponInfoDatabase->Find(pszSwap);

    if (!
g_pWeaponInfoDatabase->IsValidIndex(iIndex2))
    {
        
META_CONPRINTF("Invalid Name: %s\n"pszSwap);

        return;
    }

    
char *pszClassname = new char[80];
    
strncpy(pszClassnameg_pWeaponInfoDatabase->Element(iIndex1)->m_achClassname80);

    
memcpy(g_pWeaponInfoDatabase->Element(iIndex1), g_pWeaponInfoDatabase->Element(iIndex2), sizeof(CTFWeaponInfo));

    
// Player cannot switch to weapon if classname isn't preserved
    
strncpy(g_pWeaponInfoDatabase->Element(iIndex1)->m_achClassnamepszClassname80);
    
delete pszClassname;

    
META_CONPRINTF("Done\n");

    return;


Last edited by Matthias Vance; 09-15-2010 at 08:55. Reason: Fixed code.
Wazz 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 18:14.


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