AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Precache Models, Materials and Sound for replacing weapon model (https://forums.alliedmods.net/showthread.php?t=295235)

RumbleFrog 03-19-2017 22:24

Precache Models, Materials and Sound for replacing weapon model
 
I have the following directory structures, how would I go about caching these and replace a weapon's model with it? It uses custom materials as well.

I've tried SetEntityModel() but no luck with that.

Code:

|

+---materials
|  +---models
|  |  \---weapons
|  |      \---c_items
|  |              c_motor_flaregun.vmt
|  |              c_motor_flaregun.vtf
|  |              c_motor_flaregun_balloon.vtf
|  |              c_motor_flaregun_balloon_orange.vtf
|  |              c_motor_flaregun_c_flaregun_shell.vmt
|  |              c_motor_flaregun_c_flaregun_shell.vtf
|  |              c_motor_flare_shiny.vmt
|  |             
|  \---vgui
|      \---replay
|          \---thumbnails
+---models
|  \---weapons
|      +---c_models
|      |  +---c_flaregun_pyro
|      |  |      c_flaregun_pyro.dx80.vtx
|      |  |      c_flaregun_pyro.dx90.vtx
|      |  |      c_flaregun_pyro.mdl
|      |  |      c_flaregun_pyro.sw.vtx
|      |  |      c_flaregun_pyro.vvd
|      |  |     
|      |  \---c_motor_flaregun
|      |          c_motor_flaregun.dx80.vtx
|      |          c_motor_flaregun.dx90.vtx
|      |          c_motor_flaregun.mdl
|      |          c_motor_flaregun.sw.vtx
|      |          c_motor_flaregun.vvd
|      |         
|      \---w_models
|              w_flaregun_shell.dx80.vtx
|              w_flaregun_shell.dx90.vtx
|              w_flaregun_shell.mdl
|              w_flaregun_shell.sw.vtx
|              w_flaregun_shell.vvd
|             
\---sound
    \---weapons
            flaregun_shoot.wav
            flaregun_shoot_crit.wav


cravenge 03-20-2017 00:30

Re: Precache Models, Materials and Sound for replacing weapon model
 
This is for the models and sounds but I don't know what to do with the materials.
PHP Code:

PrecacheModel("models/weapons/c_models/c_flaregun_pyro/c_flaregun_pyro.mdl"true);
PrecacheModel("models/weapons/c_models/c_motor_flaregun/c_motor_flaregun.mdl"true);
PrecacheModel("models/weapons/w_models/w_flaregun_shell.mdl"true);

PrecacheSound("sound/weapons/flaregun_shoot.wav"true);
PrecacheSound("sound/weapons/flaregun_shoot_crit.wav"true); 


RumbleFrog 03-20-2017 06:39

Re: Precache Models, Materials and Sound for replacing weapon model
 
Quote:

Originally Posted by cravenge (Post 2505028)
This is for the models and sounds but I don't know what to do with the materials.
PHP Code:

PrecacheModel("models/weapons/c_models/c_flaregun_pyro/c_flaregun_pyro.mdl"true);
PrecacheModel("models/weapons/c_models/c_motor_flaregun/c_motor_flaregun.mdl"true);
PrecacheModel("models/weapons/w_models/w_flaregun_shell.mdl"true);

PrecacheSound("sound/weapons/flaregun_shoot.wav"true);
PrecacheSound("sound/weapons/flaregun_shoot_crit.wav"true); 


Thanks, any idea how to set the model for a weapon? I also seen PrecacheMaterial on SMLib but I never tried it

cravenge 03-20-2017 06:55

Re: Precache Models, Materials and Sound for replacing weapon model
 
Unfortunately, no, unless you're talking about CS:GO, I definitely remember numerous posts about it. Look up for something like world model, view model, etc. using Search above.

RumbleFrog 03-20-2017 10:35

Re: Precache Models, Materials and Sound for replacing weapon model
 
Quote:

Originally Posted by cravenge (Post 2505062)
Unfortunately, no, unless you're talking about CS:GO, I definitely remember numerous posts about it. Look up for something like world model, view model, etc. using Search above.

I found this: https://forums.alliedmods.net/showthread.php?t=164630 but not sure how it works, but I also found this:

Code:

new index = PrecacheModel("models/weapons/w_fire_rapier.mdl")
SetEntData(weapon, FindSendPropOffs("CBaseCombatWeapon", "m_iWorldModelIndex"), index, 4, true)
SetEntData(weapon, FindSendPropOffs("CBaseEntity", "m_nModelIndex"), index, 4, true)

But I heard it cause some problems.

Airkish 03-20-2017 10:47

Re: Precache Models, Materials and Sound for replacing weapon model
 
EDIT: my mistake

RumbleFrog 03-20-2017 14:56

Re: Precache Models, Materials and Sound for replacing weapon model
 
Can anyone link me a plugin that could do this in TF2? Natives would be a nice bonus. I've tried TF2Items Give Weapons

RumbleFrog 03-20-2017 19:40

Re: Precache Models, Materials and Sound for replacing weapon model
 
Never mind, I totally forgot about Valve's policy on attachments.


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

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