Raised This Month: $51 Target: $400
 12% 

Giving a model a weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 11-12-2004 , 08:21   Giving a model a weapon
Reply With Quote #1

Code:
// Create the weapon entity new iEntWeapon = create_entity( "info_target" ); // Set the entity's class entity_set_string( iEntWeapon, EV_SZ_classname, "weaponbox" ); // Set it to follow (so it will follow its owner) entity_set_int( iEntWeapon, EV_INT_movetype, MOVETYPE_FOLLOW ); // Make the weapon solid entity_set_int( iEntWeapon, EV_INT_solid, SOLID_NOT ); // Set the owner of the weapon to be the entity you want to have the weapon entity_set_edict( iEntWeapon, EV_ENT_aiment, iEntOwner ); // Assign the weapon entity a model entity_set_model( iEntWeapon, "models/p_m4a1.mdl" );

I put a list of the models in this array so you guys can use this to give it a random weapon or something (BUT YOU MUST change the model's sequence to match the weapon).


Code:
new szWeaponModels[31][32] =     {         "models/p_knife.mdl",            // 0         "models/p_deagle.mdl",            // 1         "models/p_glock18.mdl",            // 2         "models/p_p228.mdl",            // 3         "models/p_usp.mdl",                // 4         "models/p_flashbang.mdl",        // 5         "models/p_hegrenade.mdl",        // 6         "models/p_smokegrenade.mdl",    // 7         "models/p_xm1014.mdl",            // 8  CT T                  "models/p_m3.mdl",                // 9  CT T                  "models/p_m3super90.mdl",        // 10 CT T                "models/p_awp.mdl",                // 11 CT T                  "models/p_m249.mdl",            // 12 CT T                  "models/p_scout.mdl",            // 13 CT T                  "models/p_ump45.mdl",            // 14 CT T                  "models/p_mp5.mdl",                // 15 CT T                  "models/p_p90.mdl",                // 16 CT T                  "models/p_c4.mdl",                // 17                      "models/p_elite.mdl",            // 18                          "models/p_galil.mdl",            // 19 T                  "models/p_ak47.mdl",            // 20 T                  "models/p_sg552.mdl",            // 21 T                  "models/p_g3sg1.mdl",            // 22 T                  "models/p_mac10.mdl",            // 23 T                  "models/p_shield.mdl",            // 24                      "models/p_fiveseven.mdl",        // 25                          "models/p_famas.mdl",            // 26 CT                    "models/p_aug.mdl",                // 27 CT                        "models/p_m4a1.mdl",            // 28 CT                    "models/p_sg550.mdl",            // 29 CT                    "models/p_tmp.mdl"                // 30 CT            };

I'm posting this because I was trying to figure this out for a long time, then I found a resource on google that talked about MOVETYPE_FOLLOW and it explained the above. So enjoy
__________________
Need war3ft help? DO NOT PM ME... Check the forums

Last edited by Geesu; 07-07-2006 at 13:53. Reason: taking off caps
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
Peli
Veteran Member
Join Date: Mar 2004
Location: San Diego, CA
Old 11-12-2004 , 13:00  
Reply With Quote #2

GJ Pimp Daddy. Would the same thing work with DoD? Using a DoD gun model I mean.
Peli is offline
Send a message via MSN to Peli
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 11-12-2004 , 13:09  
Reply With Quote #3

Added into helpful / useful stuff
__________________
hello, i am pm
PM is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 11-12-2004 , 16:15  
Reply With Quote #4

So this means that the gun appears in the right spot in the player's hands. But what you said about model animation, what do you mean?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
GamerXR72
New Member
Join Date: Nov 2004
Location: With Avalanches Mom
Old 11-12-2004 , 16:33  
Reply With Quote #5

Could this be used to let someone buy the rocket launcher from single player half-life, from a custom menu like the warcraft 3 shopmenu, or is this just replacing the weapon model the player sees?
__________________
Some people would say that I can be immature at times. They're right.
GamerXR72 is offline
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 11-14-2004 , 19:14  
Reply With Quote #6

you have to make sure the model's sequence is correct. I think I used 4 to hold the m4a1 and ak, etc... mp5...

Only some weapons look correct, you'll have to play with it.

And yes it works for dod...

And no this doesn't allow to add a rocket launcher.
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
LynX
Veteran Member
Join Date: Oct 2004
Old 11-15-2004 , 06:40  
Reply With Quote #7

Actually, if you change your model, and make plugin fires rocket when that model is enabled, sure, why not?
__________________
Current plugin : SoulPunisher anti-cheat
Percentage done : {||--------} 20%

If you think v3x is a PIMP, paste this into your sig!

If you think Bailopan is DA BOMB, paste this into your sig
LynX is offline
Send a message via ICQ to LynX
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 11-15-2004 , 09:03  
Reply With Quote #8

Well yea you could make someone hold a rocket launcher. What I'm saying is that the code provided above won't have the functionality to shoot it. You'd just be "holding" a non-functioning rocket launcher.
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
[DoD]GoldenEagle
Member
Join Date: Nov 2005
Location: In Front Of Computer Sys
Old 07-23-2006 , 01:21   Re: Giving a model a weapon
Reply With Quote #9

Do you have to make a new...

Code:
 

entity_set_model( iEntWeapon, "models/p_m4a1.mdl" );
Such as...

Code:
// Assign the weapon entity a model
entity_set_model( iEntWeapon, "models/p_mp5.mdl" );
__________________

Last edited by [DoD]GoldenEagle; 07-23-2006 at 01:28. Reason: Forogt code
[DoD]GoldenEagle is offline
Major_victory
Member
Join Date: Nov 2005
Location: Illinois
Old 08-02-2006 , 14:52   Re: Giving a model a weapon
Reply With Quote #10

how would you go about making the animations work? this is something i've always had problems with...
__________________
Games i've screwed with:
Battlefield 1942, CNC Generals, Red Faction, Incoming/Incoming Forces, The Sims, Sim City 3k, Unreal Tournament, Fallout 1/2, Ragnarok, Goonzu, and CS 1.6.
Major_victory is offline
Send a message via AIM to Major_victory Send a message via Yahoo to Major_victory
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 15:53.


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