AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting w_ Grenade Models (https://forums.alliedmods.net/showthread.php?t=86111)

Mlk27 02-20-2009 22:11

Setting w_ Grenade Models
 
How do we set custom models for w_ models?

If v_ and p_ i could just use pev_viewmodel2 and pev_weaponmodel2

Exolent[jNr] 02-20-2009 23:20

Re: Setting w_ Grenade Models
 
The w_ model is the weapon entity's model, so just use this:
Code:
engfunc(EngFunc_SetModel, entity, "models/w_yourmodel.mdl");

Mlk27 02-21-2009 01:01

Re: Setting w_ Grenade Models
 
when do we set it? and in which forward?

Bugsy 02-21-2009 02:09

Re: Setting w_ Grenade Models
 
This will turn your hegrenades into awps when thrown.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "hegrenade to awp"
#define VERSION "1.0"
#define AUTHOR "bugsy"

new g_MaxClients;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_forward(FM_SetModel"fw_SetModel");

    
g_MaxClients get_maxplayers();
}

public 
fw_SetModel(ent, const model[])
{
    if ( !
pev_valid(ent))
        return 
FMRES_IGNORED;
    
    new 
id pev(entpev_owner);

    if ( !(
<= id <= g_MaxClients) )
        return 
FMRES_IGNORED;

    if( 
equal(model"models/w_hegrenade.mdl" ) )
    {
        
engfunc(EngFunc_SetModelent"models/w_awp.mdl");
        return 
FMRES_SUPERCEDE;
    }

    return 
FMRES_IGNORED;



Mlk27 02-21-2009 10:08

Re: Setting w_ Grenade Models
 
lol. thanks Bugsy!

btw what does this mean?

if ( !(1 <= id <= g_MaxClients) )

Exolent[jNr] 02-21-2009 14:32

Re: Setting w_ Grenade Models
 
That checks if "id" is given a valid player index, because player indexes range from 1 -> (max players allowed in server).

ConnorMcLeod 02-21-2009 14:49

Re: Setting w_ Grenade Models
 
I would do somethinkg like this :
Won't work with thrown nades (can be done in Ham_Spawn forward) and won't work for planted c4.
PHP Code:

/*    Copyright © 2009, ConnorMcLeod

    World Models is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with World Models; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "World Models"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"

#define    m_iId            43

new const m_rgpPlayerItems_wpnbx[] = {343536373839}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_forward(FM_SetModel"SetModel")
}

public 
SetModel(iEnt, const szModel[])
{
    if( 
pev_valid(iEnt) != )
    {
        return 
FMRES_IGNORED
    
}

    if( 
szModel[0] == '*' )
    {
        return 
FMRES_IGNORED
    
}

    new 
szClassName[11]
    
pev(iEntpev_classnameszClassNamecharsmax(szClassName))
    if( !
equal(szClassName"weaponbox") )
    {
        return 
FMRES_IGNORED
    
}

    new 
iWeaponiId
    
for(new ii<=sizeof(m_rgpPlayerItems_wpnbx); i++)
    {
        
iWeapon get_pdata_cbase(iEntm_rgpPlayerItems_wpnbx[i], 4)
        if( 
iWeapon && pev_valid(iWeapon) == )
        {
            
iId get_pdata_int(iWeaponm_iId4)
            if( 
Set_Custom_World_Model(iEntiId) )
            {
                return 
FMRES_SUPERCEDE
            
}
            else
            {
                return 
FMRES_IGNORED
            
}
        }
    }
    return 
FMRES_IGNORED
}

Set_Custom_World_Model(iEntiId)
{
    new 
szModel[64]
    switch( 
iId )
    {
        case 
CSW_M4A1:formatex(szModelcharsmax(szModel), "models/custom/w_m4a1.mdl")
        case 
CSW_AK47:formatex(szModelcharsmax(szModel), "models/custom/w_ak47.mdl")
        case 
CSW_MP5NAVY:formatex(szModelcharsmax(szModel), "models/custom/w_mp5.mdl")
        case 
CSW_DEAGLE:formatex(szModelcharsmax(szModel), "models/custom/w_deagle.mdl")
        default:return 
0
    
}

    
engfunc(EngFunc_SetModeliEntszModel)
    return 
1




All times are GMT -4. The time now is 17:09.

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