Raised This Month: $404 Target: $400
 101% 

Global weapons substitution [ Under HL ]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MayroN
Member
Join Date: Aug 2017
Location: Kyiv
Old 10-09-2018 , 07:12   Global weapons substitution [ Under HL ]
Reply With Quote #1

Got A Good Connor Code.
PHP Code:
#define VERSION "0.2.3"

// #define DONT_BLOCK_PRECACHE

#include <amxmodx>
#include <fakemeta_stocks>
#include <hamsandwich>

#pragma semicolon 1

const MAX_MODEL_LENGTH 64;

new const 
m_rgpPlayerItems_CBasePlayer[6] = {367368, ...};
const 
m_pActiveItem 373;

const 
XO_WEAPON 4;
const 
m_pPlayer 41;

new 
Trie:g_tszWorldModels// handles new models strings (all excepted v_ and w_ models)
new Trie:g_tiPrecacheReturns// handles all new models precache returns integers
new Trie:g_tiszViewModels;
new 
Trie:g_tiszWeaponModels;

public 
plugin_precache()
{
    new 
szModelsFile[128];
    
get_localinfo("amxx_configsdir"szModelsFilecharsmax(szModelsFile));
    
add(szModelsFilecharsmax(szModelsFile), "/new_weapons_HD.ini");

    new 
iFile fopen(szModelsFile"rt");
    if(!
iFile)
    {
        return;
    }

    new 
szDatas[192], szOldModel[MAX_MODEL_LENGTH], szNewModel[MAX_MODEL_LENGTH];
    new 
szWeaponClass[32], Trie:tRegisterWeaponDeploy TrieCreate(), iId;

    new 
Trie:tWeaponsIds TrieCreate();
    
TrieSetCell(tWeaponsIds"p228"CSW_P228);
    
TrieSetCell(tWeaponsIds"scout"CSW_SCOUT);
    
TrieSetCell(tWeaponsIds"hegrenade"CSW_HEGRENADE);
    
TrieSetCell(tWeaponsIds"xm1014"CSW_XM1014);
    
TrieSetCell(tWeaponsIds"c4"CSW_C4);
    
TrieSetCell(tWeaponsIds"mac10"CSW_MAC10);
    
TrieSetCell(tWeaponsIds"aug"CSW_AUG);
    
TrieSetCell(tWeaponsIds"smokegrenade"CSW_SMOKEGRENADE);
    
TrieSetCell(tWeaponsIds"elite"CSW_ELITE);
    
TrieSetCell(tWeaponsIds"fiveseven"CSW_FIVESEVEN);
    
TrieSetCell(tWeaponsIds"ump45"CSW_UMP45);
    
TrieSetCell(tWeaponsIds"sg550"CSW_SG550);
    
TrieSetCell(tWeaponsIds"galil"CSW_GALIL);
    
TrieSetCell(tWeaponsIds"famas"CSW_FAMAS);
    
TrieSetCell(tWeaponsIds"usp"CSW_USP);
    
TrieSetCell(tWeaponsIds"glock18"CSW_GLOCK18);
    
TrieSetCell(tWeaponsIds"awp"CSW_AWP);
    
TrieSetCell(tWeaponsIds"mp5navy"CSW_MP5NAVY);
    
TrieSetCell(tWeaponsIds"m249"CSW_M249);
    
TrieSetCell(tWeaponsIds"m3"CSW_M3);
    
TrieSetCell(tWeaponsIds"m4a1"CSW_M4A1);
    
TrieSetCell(tWeaponsIds"tmp"CSW_TMP);
    
TrieSetCell(tWeaponsIds"g3sg1"CSW_G3SG1);
    
TrieSetCell(tWeaponsIds"flashbang"CSW_FLASHBANG);
    
TrieSetCell(tWeaponsIds"deagle"CSW_DEAGLE);
    
TrieSetCell(tWeaponsIds"sg552"CSW_SG552);
    
TrieSetCell(tWeaponsIds"ak47"CSW_AK47);
    
TrieSetCell(tWeaponsIds"knife"CSW_KNIFE);
    
TrieSetCell(tWeaponsIds"p90"CSW_P90);

    new 
cbool:bServerDeactivateRegisterediExtPosbShieldModel;
    while(!
feof(iFile))
    {
        
fgets(iFileszDatascharsmax(szDatas));
        
trim(szDatas);
        if(!(
c=szDatas[0]) || == ';' || == '#' || (== '/' && szDatas[1] == '/'))
        {
            continue;
        }

        if(        
parse(szDatasszOldModelcharsmax(szOldModel), szNewModelcharsmax(szNewModel)) == 2
        
&&    file_exists(szNewModel)    )
        {
            
// models/[p/v]_
            // models/shield/[p/v]_shield_
            
bShieldModel equal(szOldModel"models/shield/"14);
            if( ( (
c=szOldModel[bShieldModel 14 7]) == 'p' || == 'v' ) && szOldModel[bShieldModel 15 8] == '_' )
            {
                if( 
equal(szOldModel[9], "mp5") )
                {
                    
copy(szWeaponClasscharsmax(szWeaponClass), "weapon_mp5navy");
                }
                else
                {
                    
iExtPos strlen(szOldModel) - 4;
                    
szOldModeliExtPos ] = EOS;
                    
formatex(szWeaponClasscharsmax(szWeaponClass), "weapon_%s"szOldModel[bShieldModel 23 9]);
                    
szOldModeliExtPos ] = '.';
                }
                
                if( !
TrieGetCell(tWeaponsIdsszWeaponClass[7], iId) )
                {
                    continue;
                }

                if( 
== 'v' )
                {
                    if( !
g_tiszViewModels )
                    {
                        
g_tiszViewModels TrieCreate();
                    }

                    
TrieSetCell(g_tiszViewModelsszOldModelEF_AllocStringszNewModel ) );
                }
                else
                {
                    if( !
g_tiszWeaponModels )
                    {
                        
g_tiszWeaponModels TrieCreate();
                    }
                    
                    
TrieSetCell(g_tiszWeaponModelsszOldModelEF_AllocStringszNewModel ) );
                }
                
                if( !
TrieKeyExists(tRegisterWeaponDeployszWeaponClass) )
                {
                    
TrieSetCell
                    
(
                        
tRegisterWeaponDeploy,
                        
szWeaponClass,
                        
RegisterHam(Ham_Item_DeployszWeaponClass"OnCBasePlayerWeapon_Deploy_P"true)
                    );
                }
            }
            else
            {
                if( !
bServerDeactivateRegistered && equal(szOldModel"models/w_backpack.mdl") )
                {
                    
bServerDeactivateRegistered true;
                    
register_forward(FM_ServerDeactivate"OnServerDeactivate");
                }

                if( !
g_tszWorldModels )
                {
                    
g_tszWorldModels TrieCreate();
                }
                else if( 
TrieKeyExists(g_tszWorldModelsszOldModel) )
                {
                    new 
szModel[MAX_MODEL_LENGTH];
                    
TrieGetString(g_tszWorldModelsszOldModelszModelcharsmax(szModel));
                    
log_amx("%s world model is already set to %s, can't set it to %s !!"szWeaponClassszModelszNewModel);
                    continue;
                }
                
TrieSetString(g_tszWorldModelsszOldModelszNewModel);
            }

            if( !
g_tiPrecacheReturns )
            {
                
g_tiPrecacheReturns TrieCreate();
            }
            
TrieSetCell(g_tiPrecacheReturnsszOldModelEF_PrecacheModel(szNewModel));
#if defined DONT_BLOCK_PRECACHE
            
EF_PrecacheModel(szOldModel);
#endif
        
}
    }
    
fclose(iFile);

    
TrieDestroy(tRegisterWeaponDeploy);
    
TrieDestroy(tWeaponsIds);

    if( 
g_tiPrecacheReturns )
    {
        
register_forward(FM_PrecacheModel"OnPrecacheModel");

        if( 
g_tszWorldModels )
        {
            
register_forward(FM_SetModel"OnSetModel");
        }
    }
}

public 
plugin_init()
{
    
register_plugin("Weapons Models"VERSION"ConnorMcLeod");
}

public 
OnServerDeactivate()
{
    static 
bool:bDontPassThisTwice false;
    if( 
bDontPassThisTwice // unregister this would be waste of time
    
{
        return;
    }
    
bDontPassThisTwice true;

    new 
idc4 FM_NULLENT;
    while( (
c4 EF_FindEntityByString(c4"classname""weapon_c4")) > )
    {
        
id get_pdata_cbase(c4m_pPlayer);
        if( 
id )
        {
            
// can't use set_pdata_cbase on players at this point
            
set_pdata_int(idm_rgpPlayerItems_CBasePlayer[5], 0);
            
set_pdata_int(idm_pActiveItem0);
            
// tried to remove c4 entity but server just stucks
        
}
    }
}

public 
OnPrecacheModel(const szModel[])
{
    static 
iReturn;
    if( 
TrieGetCell(g_tiPrecacheReturnsszModeliReturn) )
    {
        
forward_return(FMV_CELLiReturn);
        return 
FMRES_SUPERCEDE;
    }
    return 
FMRES_IGNORED;
}

public 
OnCBasePlayerWeapon_Deploy_PiWeapon )
{
    new 
id get_pdata_cbase(iWeaponm_pPlayerXO_WEAPON);
    if( 
pev_valid(id) == && get_pdata_cbase(idm_pActiveItem) == iWeapon )
    {
        new 
iszNewModelszOldModel[MAX_MODEL_LENGTH];
        if( 
g_tiszViewModels )
        {
            
pev(idpev_viewmodel2szOldModelcharsmax(szOldModel));
            if( 
TrieGetCell(g_tiszViewModelsszOldModeliszNewModel) )
            {
                
set_pev(idpev_viewmodeliszNewModel);
            }
        }
        if( 
g_tiszWeaponModels )
        {
            
pev(idpev_weaponmodel2szOldModelcharsmax(szOldModel));
            if( 
TrieGetCell(g_tiszWeaponModelsszOldModeliszNewModel) )
            {
                
set_pev(idpev_weaponmodeliszNewModel);
            }
        }
    }
}

public 
OnSetModel(const iEnt, const szModel[])
{
    new 
szNewModel[MAX_MODEL_LENGTH];
    if( 
TrieGetString(g_tszWorldModelsszModelszNewModelcharsmax(szNewModel)) )
    {
        
EF_SetModel(iEntszNewModel);
        return 
FMRES_SUPERCEDE;
    }
    return 
FMRES_IGNORED;

In Half-life unfortunately other weapons
Managed to find the Code

PHP Code:
    TrieSetCell(g_WeaponNames"weapon_crowbar"HLW_CROWBAR)
    
TrieSetCell(g_WeaponNames"weapon_9mmhandgun"HLW_GLOCK)
    
TrieSetCell(g_WeaponNames"weapon_357"HLW_PYTHON)
    
TrieSetCell(g_WeaponNames"weapon_9mmAR"HLW_MP5)
    
TrieSetCell(g_WeaponNames"weapon_shotgun"HLW_SHOTGUN)
    
TrieSetCell(g_WeaponNames"weapon_crossbow"HLW_CROSSBOW)
    
TrieSetCell(g_WeaponNames"rpg_rocket"HLW_RPG)
    
TrieSetCell(g_WeaponNames"weapon_gauss"HLW_GAUSS)
    
TrieSetCell(g_WeaponNames"weapon_egon"HLW_EGON)
    
TrieSetCell(g_WeaponNames"hornet"HLW_HORNETGUN)
    
TrieSetCell(g_WeaponNames"grenade"HLW_HANDGRENADE)
    
TrieSetCell(g_WeaponNames"monster_satchel"HLW_SATCHEL)
    
TrieSetCell(g_WeaponNames"monster_tripmine"HLW_TRIPMINE)
    
TrieSetCell(g_WeaponNames"monster_snark"HLW_SNARK)
    
TrieSetCell(g_WeaponNames"bolt"HLW_BOLT)
    
TrieSetCell(g_WeaponNames"tank"HLW_TANK)
    
TrieSetCell(g_WeaponNames"ARgrenade"HLW_HANDGRENADE)
    
TrieSetCell(g_WeaponNames"func_tank"HLW_TANK)
    
TrieSetCell(g_WeaponNames"func_tankmortar"HLW_TANK)
    
TrieSetCell(g_WeaponNames"func_tankrocket"HLW_TANK)
    
TrieSetCell(g_WeaponNames"func_tanklaser"HLW_TANK
Tried stupidly to replace this code with that in the COP on the weapon.
Everything is compiled there, but there is no substitution.

Well it is possible even then to cut the shield

Probably need something else.
Tell me and help
MayroN is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 10-09-2018 , 07:59   Re: Global weapons substitution [ Under HL ]
Reply With Quote #2

There is a lot of difference
The first thing & most important to me is Offsets
Quote:
new const m_rgpPlayerItems_CBasePlayer[6] = {367, 368, ...};
const m_pActiveItem = 373;

const XO_WEAPON = 4;
const m_pPlayer = 41;
http://aghl.ru/forum/viewtopic.php?f=39&t=30

It's better to write your own new one
__________________

Last edited by abdobiskra; 10-09-2018 at 08:00. Reason: add link
abdobiskra is offline
Send a message via Skype™ to abdobiskra
MayroN
Member
Join Date: Aug 2017
Location: Kyiv
Old 10-09-2018 , 08:11   Re: Global weapons substitution [ Under HL ]
Reply With Quote #3

Quote:
Originally Posted by abdobiskra View Post
There is a lot of difference
The first thing & most important to me is Offsets


http://aghl.ru/forum/viewtopic.php?f=39&t=30

It's better to write your own new one

Thanks.very useful
MayroN 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 17:20.


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