Raised This Month: $32 Target: $400
 8% 

Set a weapon's model?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
almcaeobtac
Senior Member
Join Date: Nov 2008
Location: Florida
Old 08-06-2010 , 14:07   Set a weapon's model?
Reply With Quote #1

How would you set a weapon's world model? I'm finding it like this:

Code:
        new Index;
        new String:Classname[64];
    
    	for(new i = 0; i < 128; i = (i + 4))
	{
        	Index = GetEntDataEnt2(Client, FindSendPropOffs("CHL2MP_Player", "m_hMyWeapons") + i);
        
        	if(Index > 0)
		{
        		GetEdictClassname(Index, Classname, 64);

			if(StrEqual(Classname, Weapon, false))
			{
				SetEntityModel(Index, ModelName);
			}
		}
	}
..but it doesn't seem to be showing any results ingame. What's wrong?
__________________
almcaeobtac is offline
almcaeobtac
Senior Member
Join Date: Nov 2008
Location: Florida
Old 08-06-2010 , 16:30   Re: Set a weapon's model?
Reply With Quote #2

By the way, it's the SetEntityModel part that isn't working with the weapon entities, for some reason.
__________________
almcaeobtac is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 08-06-2010 , 17:41   Re: Set a weapon's model?
Reply With Quote #3

http://forums.alliedmods.net/showthread.php?t=76814

Found something for you.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
almcaeobtac
Senior Member
Join Date: Nov 2008
Location: Florida
Old 08-06-2010 , 19:31   Re: Set a weapon's model?
Reply With Quote #4

It doesn't work
__________________
almcaeobtac is offline
Andersso
Member
Join Date: Nov 2009
Location: E8 2A 2A 2A 2A
Old 08-13-2010 , 17:51   Re: Set a weapon's model?
Reply With Quote #5

What about this? I don't know if it works in HL2DM. But if it does, it should replace the crowbars model with "models/props_canal/mattpipe.mdl"

Code:
#include <sourcemod>
#pragma semicolon 1

new g_iWorldModel;

public OnMapStart()
{
        g_iWorldModel = PrecacheModel("models/props_canal/mattpipe.mdl", true);
}

public Action:OnPlayerRunCmd(iClient, &iButtons, &iImpulse, Float:fVelocity[3], Float:fAngles[3], &iWeapon)
{
    new iActiveWeapon = GetEntPropEnt(iClient, Prop_Data, "m_hActiveWeapon");
    
    if (iActiveWeapon != -1)
    {
        decl String:sWeapon[64];
        GetEdictClassname(iActiveWeapon, sWeapon, sizeof(sWeapon));
        
        if (StrEqual(sWeapon, "weapon_crowbar"))
        {
            SetEntProp(iActiveWeapon, Prop_Send, "m_iWorldModelIndex", g_iWorldModel);
        }
    }
}
Andersso is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 08-13-2010 , 23:19   Re: Set a weapon's model?
Reply With Quote #6

i am not sure andersso`s way can work or not.
but weapon model extention is totaly not working.
i was even rebuilded that extension and edited it but it was not able to change model
even server was no error and model hook fucntion was worked fine, it was didnt work.
javalia is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 10-04-2011 , 20:11   Re: Set a weapon's model?
Reply With Quote #7

I made a change but still did not work, what should I have done wrong?

PHP Code:
#include <sourcemod>
#pragma semicolon 1
new g_iWorldModel;
new 
g_iViewModel;

public 
OnMapStart()
{
g_iWorldModel PrecacheModel("models/weapons/w_crowbar.mdl"true);
g_iViewModel PrecacheModel("models/weapons/V_hands.mdl"true);
}

public 
Action:OnPlayerRunCmd(iClient, &iButtons, &ImpulseFloat:fVelocity[3], Float:fAngles[3], &iWeapon)
{
new 
iActiveWeapon GetEntPropEnt(iClientProp_Data"m_hActiveWeapon");
new 
ActiveWeapon GetEntPropEnt(iClientProp_Data"m_hActiveWeapon");

if (
iActiveWeapon != -1)
{
decl String:sWeapon[64];
decl String:Weapon[32];
GetEdictClassname(iActiveWeaponsWeaponsizeof(sWeapon));
GetEdictClassname(ActiveWeaponWeaponsizeof(Weapon));

if (
StrEqual(sWeapon"weapon_knife"))
{
SetEntProp(iActiveWeaponProp_Send"m_iWorldModelIndex"g_iWorldModel);

if (
StrEqual(Weapon"weapon_knife"))
{
SetEntProp(iActiveWeaponProp_Send"m_iViewModelIndex"g_iViewModel);
}
}
}

Regards.
rodrigo286 is offline
cssBOT
Senior Member
Join Date: Apr 2009
Old 02-15-2012 , 10:12   Re: Set a weapon's model?
Reply With Quote #8

Tried andersso's code and it doesn't work. Does anyone have a working version of this?
cssBOT is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-15-2012 , 19:58   Re: Set a weapon's model?
Reply With Quote #9

Quote:
Originally Posted by cssBOT View Post
Tried andersso's code and it doesn't work. Does anyone have a working version of this?
DOnt activate it on PLayerRunCMD, thats the only problem i got it to work after making a timer on player_spawn, HAVE FUN!
Mitchell is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-15-2012 , 19:59   Re: Set a weapon's model?
Reply With Quote #10

Quote:
Originally Posted by rodrigo286 View Post
I made a change but still did not work, what should I have done wrong?

PHP Code:
#include <sourcemod>
#pragma semicolon 1
new g_iWorldModel;
new 
g_iViewModel;

public 
OnMapStart()
{
g_iWorldModel PrecacheModel("models/weapons/w_crowbar.mdl"true);
g_iViewModel PrecacheModel("models/weapons/V_hands.mdl"true);
}

public 
Action:OnPlayerRunCmd(iClient, &iButtons, &ImpulseFloat:fVelocity[3], Float:fAngles[3], &iWeapon)
{
new 
iActiveWeapon GetEntPropEnt(iClientProp_Data"m_hActiveWeapon");
new 
ActiveWeapon GetEntPropEnt(iClientProp_Data"m_hActiveWeapon");

if (
iActiveWeapon != -1)
{
decl String:sWeapon[64];
decl String:Weapon[32];
GetEdictClassname(iActiveWeaponsWeaponsizeof(sWeapon));
GetEdictClassname(ActiveWeaponWeaponsizeof(Weapon));

if (
StrEqual(sWeapon"weapon_knife"))
{
SetEntProp(iActiveWeaponProp_Send"m_iWorldModelIndex"g_iWorldModel);

if (
StrEqual(Weapon"weapon_knife"))
{
SetEntProp(iActiveWeaponProp_Send"m_iViewModelIndex"g_iViewModel);
}
}
}

Regards.
Half your code repeats it's self, you get the entity index twice, and check if the same entity is the same..
Mitchell 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 02:28.


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