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

pev_skin on grenades


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-25-2014 , 08:55   pev_skin on grenades
Reply With Quote #1

There are some topics about this on the forums, but none have definite answers.

I want to change the skin of a grenade. The weapon is active when I'm calling set_pev( iWpnIndex, pev_skin, 2 ), where iWpnIndex is the saved weapon ID from give_item call. The model has 8 skins in total, so it should work fine. The problem is it doesn't do anything.

Is it definitely impossible to change the skin of a v_ model of a weapon? I want to know this before I convert the model to different bodies and use the SVC_WEAPONANIM message instead. Changing skins is more optimal solution, but if it just won't work, there's no way around it.

Thanks.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-25-2014 , 09:21   Re: pev_skin on grenades
Reply With Quote #2

You should hook Ham_Item_Deploy and using entity passed with pev_skin. There is no reason it doesn't work.
__________________
Arkshine is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-25-2014 , 16:33   Re: pev_skin on grenades
Reply With Quote #3

I went with body anyway, because I'll probably use completely different models too.

PHP Code:
/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"


const ANIM_DEPLOY 3

new g_body

public plugin_init() 
{
    
register_pluginPLUGINVERSIONAUTHOR )
    
    
register_clcmd"gettestnade""gettestnade" )
    
register_clcmd"changeskin""changeskin" )
    
    
register_forwardFM_UpdateClientData"UpdateClientData")
}

public 
UpdateClientDataidsendweaponscd )
{
    if( 
sendweapons && get_user_weaponid ) == CSW_HEGRENADE )
    {
        
        static 
iAnimPrevious
        
new iAnim get_cdcdCD_WeaponAnim )
    
        if( 
iAnimPrevious != iAnim )
        {
            if( 
iAnim == ANIM_DEPLOY )
            {
                
set_pevidpev_viewmodel2"models/traxxrp/v_combined.mdl" )
            }
        
            
client_printidprint_chat"UpdateClientData iAnim: %d"iAnim )
            
flushanimationidiAnimg_body )
        
            
iAnimPrevious iAnim
        
}
    
    }
}  

public 
plugin_precache( )
{
    
precache_model"models/traxxrp/v_combined.mdl" )
}

public 
gettestnadeid )
{
    
give_itemid"weapon_hegrenade" )
}

public 
changeskinid )
{
    new 
szArgs]
    
read_argsszArgscharsmaxszArgs ) )
    
    
remove_quotesszArgs )
    
trimszArgs )
    
    
g_body str_to_numszArgs )
    
    
flushanimationidANIM_DEPLOYg_body )
    
    
client_printidprint_console"Setting animation with pev_body: %d"g_body )
}

flushanimationidiAnimiBodyValue )
{
    
set_pevidpev_weaponanimiAnim )
    
message_beginMSG_ONESVC_WEAPONANIM, {000}, id )
    
write_byteiAnim )
    
write_byteiBodyValue )
    
message_end( )

It works more or less, but for some reason, the deploy animation never gets the correct body value. I actually need to wait for the idle animation swap, then it gets properly changed. Also when another animation's played, the model flickers back to it's original body value for one frame, then it goes back to the correct one. Do you have any idea? I'm attaching the model as well in case you want to try it. The "other" body value is 3, so use changeskin 3.

The code is bad but it's enough for testing. Didn't feel like using Ham_Item_Deploy.

Edit: I think that the animation flicker is caused by the fact FM_UpdateClientData is a post forward, however it's impossible to replace the animation in a pre call.
Attached Files
File Type: zip v_combined.zip (235.2 KB, 175 views)
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 04-25-2014 at 16:40.
Backstabnoob is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-25-2014 , 16:41   Re: pev_skin on grenades
Reply With Quote #4

I'm not sure to understand what you are trying to achieve here.
__________________

Last edited by Arkshine; 04-25-2014 at 16:41.
Arkshine is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-25-2014 , 16:44   Re: pev_skin on grenades
Reply With Quote #5

I'm having problems with precache limit due to huge map on my roleplaying server. As there will be around 20 grenades, it'd be really handy to have all the models in one model as submodels and seamlessly switch between them.

The problem with this is that whenever another animation is sent by the server, the submodel immediately changes back to its original value.

I'm trying to hook when the animation is sent and send the exactly same animation again, except with a different body value in the SVC_WEAPONANIM message.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 04-25-2014 at 16:45.
Backstabnoob is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 04-25-2014 , 21:20   Re: pev_skin on grenades
Reply With Quote #6

Are you doing pev_body in viewmodel?
__________________
What are you looking for here?
DavidJr is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-26-2014 , 06:48   Re: pev_skin on grenades
Reply With Quote #7

Yes and I'm having the same problems as you in your thread, the submodel flickers back to it's original value right when the animation is started.

I don't think there's anything we can do, it flickers due to the animation being played on client side exactly for 1 frame until the server sends another animation.

Not sure but it might be somehow possible with Orpheu, as in not telling the client that a certain event has happened (i.e. grenade throw), so the client won't know it needs to play an animation. That could lead itno some serious issues, though, but probably not in my case since I only want to do this with grenades.

All this talk is a little beyond my programming skills as I don't have an idea how to use Orpheu or if it's even remotely possible, so I could use a help hand.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 04-26-2014 , 07:19   Re: pev_skin on grenades
Reply With Quote #8

There's nothing to do, everytime you use IN_ATTACK1, it will be reset to its default body. Others are fine like draw, idle, etc, but not for attack anim in this case (throwing grenade). It is because client side, isn't it?
__________________
What are you looking for here?
DavidJr is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-26-2014 , 08:20   Re: pev_skin on grenades
Reply With Quote #9

It goes for the grenade as well. It doesn't matter what action you do, whenever an animation is played, it's first played on client-side, then you can send a message from the server to play another one. The time before the animation is replaced is exactly 1 frame, which is the time it shows the default body (as the body is specified in the animation message). I have problems with draw too, as I sometimes don't even get a different body at all.

Guess I'll have to stick to using more models.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 04-26-2014 , 09:14   Re: pev_skin on grenades
Reply With Quote #10

Take a look here: https://forums.alliedmods.net/showpo...9&postcount=13

All work fine except for shoot one, maybe you use my method for draw.
__________________
What are you looking for here?
DavidJr is offline
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 23:11.


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