Raised This Month: $ Target: $400
 0% 

How to change Sub-Model on player model?


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-14-2011 , 17:56   Re: How to change Sub-Model on player model?
Reply With Quote #21

I can't seem to make it work.

Try to set pev_body 1, then play an animation. Basically, do what HLSDK does.

this way I think it won't be set per player

Please think, do you think a same entity can be used at the same time with different players ? No. One entity by player.
__________________
Arkshine is offline
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-14-2011 , 18:00   Re: How to change Sub-Model on player model?
Reply With Quote #22

I tried sending anim, I mean after I had it drawn, I shot it a few times, so the fire1 anim was sent, but no laser sight. I guess then the problem is in the weapon entity index. How do you get it? I tried get_user_weapon(id) as you see, but that returns 29, which is the same as CSW_KNIFE, so it probably is the same for all players, but you said it's different for each player, so I guess you are talking about a different entity index? So, how should I get that index?
__________________
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-14-2011 , 18:04   Re: How to change Sub-Model on player model?
Reply With Quote #23

get_user_weapon(id) returns CSW_* constants, so the weapon ID, not the weapon entity index... To get the active weapon index, use get_pdata_cbase( playerId, 373 ), 373 being m_pActiveItem.
__________________
Arkshine is offline
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-14-2011 , 18:21   Re: How to change Sub-Model on player model?
Reply With Quote #24

set_pev(get_pdata_cbase(id, 373), pev_body, 1);
still in the draw event, still I fire a few shots after that to send fire1 anim, still no laser sight... anyways, this get_pdata_cbase(id, 373) returns 128, which is probably right, but something else is wrong...
__________________
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-14-2011 , 18:21   Re: How to change Sub-Model on player model?
Reply With Quote #25

How you send animation ?
__________________
Arkshine is offline
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-14-2011 , 18:22   Re: How to change Sub-Model on player model?
Reply With Quote #26

well, you know how weaponmod weapons work, right? when I fire a few shots, the fire anim is sent with wpn_playanim, which is some func in weaponmod that plays an anim...

edit: just checked it in weaponmod's code, it's pretty much the standard way:
PHP Code:
set_pev(playerpev_weaponanimanim)
    
message_begin(MSG_ONESVC_WEAPONANIM, {000}, player)
write_byte(anim)
write_byte(pev(playerpev_body))
message_end() 
__________________

Last edited by SeriousSam; 04-14-2011 at 18:25.
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-14-2011 , 18:27   Re: How to change Sub-Model on player model?
Reply With Quote #27

message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
write_byte(anim)
write_byte(pev(player, pev_body))
message_end()

In write_byte(pev(player, pev_body)), player should be replaced by the weapon index.
__________________
Arkshine is offline
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-14-2011 , 18:36   Re: How to change Sub-Model on player model?
Reply With Quote #28

so, you're saying devcones wrote it wrong? Ok, I tried your way
PHP Code:
public ev_draw(id)
{
    
//wpn_playanim(id, anim_draw);
    
gtime[id] = get_gametime();
    
set_pev(get_pdata_cbase(id373), pev_body1);
    
    
set_pev(idpev_weaponanimanim_draw);
    
    
message_begin(MSG_ONESVC_WEAPONANIM, {000}, id);
    
write_byte(anim_draw);
    
write_byte(pev(get_pdata_cbase(id373), pev_body));
    
message_end();
    
    
client_print(idprint_center"index: %d"get_pdata_cbase(id373));
    
    return 
PLUGIN_CONTINUE;

this gave me some results, but... If I pull out knife, then switch to 357, there is a laser sight. If I pull out the usp, then switch to the 357 - no laser sight...
__________________
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-14-2011 , 18:49   Re: How to change Sub-Model on player model?
Reply With Quote #29

Yes, it's wrong. You can confirm with HLSDK. Also, it's logic, you set pev_body of the weapon entity to 1, how getting player's pev_body is related here ?

You should be aware of 2 things :

- WeaponMod is tricky, all weapons on knife may lead to animations problems. I know well, it's really a poor way.
- It's known that submodel and such is buggy, where client doesn't update always as it should.

So, good luck !
__________________
Arkshine is offline
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-14-2011 , 19:06   Re: How to change Sub-Model on player model?
Reply With Quote #30

Is there another better way of adding new weapons to the game, other than weaponmod? One that wouldn't cause me so much trouble?

BTW I have a backup idea if submodel attachments doesn't work - try to add them as new animations, for example having the standard anim_fire1, then having anim_fire1_laser which has the laser sight attached, pretty much like the silencer on m4a1... but that will be harder to do since I have to mess with the skeletal animations...

EDIT: I improved on it a little now that I know how it works. Instead of
PHP Code:
set_pev(get_pdata_cbase(id373), pev_body1);
    
set_pev(idpev_weaponanimanim_draw);
    
message_begin(MSG_ONESVC_WEAPONANIM, {000}, id);
write_byte(anim_draw);
write_byte(pev(get_pdata_cbase(id373), pev_body));
message_end(); 
now I use directly
PHP Code:
set_pev(idpev_weaponanimanim_draw);
    
message_begin(MSG_ONESVC_WEAPONANIM, {000}, id);
write_byte(anim_draw);
write_byte(1);
message_end(); 
in other words, no need to set pev_body, I can directly put the value in the message. I replaced all of the animations - draw, reload, fire, with messages like this one, and now although when I draw the 357 after drawing a weapon other than the knife there is still no laser sight, after the first other anim - for example I fire a shot, the laser sight appears and stays until I holster it again I guess it's not that bad, although not perfect, so I will use it like that.

I shall use this submodel method to add different sights, silencers, bigger mags, tac lights, and other attachments as purchasable mods for the weapons. For example you buy a G36C with iron sights, and after that you buy an acog scope for it Now I only need to make pev_skin work as well in order to add purchasable camo skins, and cs will become more like the newer call of duty games
__________________

Last edited by SeriousSam; 04-14-2011 at 20:20.
SeriousSam is offline
Send a message via Skype™ to SeriousSam
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 07:25.


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