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

[CSGO] Weird behaviour with 'm_szArmsModel'


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 11-02-2016 , 18:40   [CSGO] Weird behaviour with 'm_szArmsModel'
Reply With Quote #1

Hi everyone,

I'm trying to set a new arm model for the T. I'm using this method that everyone seems to use:

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_spawn"OnPlayerSpawnPost);
}

public 
void OnMapStart()
{
    
PrecacheModel("models/player/custom_player/hekut/talizorah/talizorah.mdl");
    
PrecacheModel("models/player/custom_player/hekut/talizorah/talizorah_arms.mdl");
    
    
AddFileToDownloadsTable("models/player/custom_player/hekut/talizorah/talizorah.dx90.vtx");
    
AddFileToDownloadsTable("models/player/custom_player/hekut/talizorah/talizorah.mdl");
    
AddFileToDownloadsTable("models/player/custom_player/hekut/talizorah/talizorah.phy");
    
AddFileToDownloadsTable("models/player/custom_player/hekut/talizorah/talizorah.vvd");
    
AddFileToDownloadsTable("models/player/custom_player/hekut/talizorah/talizorah_arms.dx90.vtx");
    
AddFileToDownloadsTable("models/player/custom_player/hekut/talizorah/talizorah_arms.mdl");
    
AddFileToDownloadsTable("models/player/custom_player/hekut/talizorah/talizorah_arms.vvd");
    
    
AddFileToDownloadsTable("materials/models/player/custom_player/hekut/talizorah/glow_sheet.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/hekut/talizorah/mask_normal.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/hekut/talizorah/mask_sheet.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/hekut/talizorah/mask_sheet.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/hekut/talizorah/tali_normal.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/hekut/talizorah/tali_phong.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/hekut/talizorah/tali_sheet.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/hekut/talizorah/tali_sheet.vtf");
}

public 
void OnPlayerSpawnPost(Handle hEvent, const char[] szNamebool bDontBroadcast)
{
    
int iPlayer GetClientOfUserId(GetEventInt(hEvent"userid"));
    
    if (
IsPlayerAlive(iPlayer))
    {
        switch (
GetClientTeam(iPlayer))
        {
            case 
CS_TEAM_T:
            {
                
SetEntityModel(iPlayer"models/player/custom_player/hekut/talizorah/talizorah.mdl");
                
SetEntPropString(iPlayerProp_Send"m_szArmsModel""models/player/custom_player/hekut/talizorah/talizorah_arms.mdl");
                
                
PrintToChat(iPlayer"OnPlayerSpawnPost T");
            }
            case 
CS_TEAM_CT:
            {
                
            }
        }
    }

Everything works fine if I die as CT and respawn as T.
The issue is: if I survive the round as CT and switch team using 'CS_SwitchTeam()' --> I will still have the CT arm model after the 1st respawn (Everything works fine after the 2nd respawn as T...)!

The funny thing is: after the 1st respawn, if I fast-switch to my desktop, and then go back to the game: tadaaaaaaa --> The arm model is updated.

What am I missing? CS_SwitchTeam() needs something else?
Thank you
__________________
micapat is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-02-2016 , 18:53   Re: [CSGO] Weird behaviour with 'm_szArmsModel'
Reply With Quote #2

Try switch team then respawn player
__________________

Last edited by Neuro Toxin; 11-02-2016 at 18:53.
Neuro Toxin is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 11-02-2016 , 18:53   Re: [CSGO] Weird behaviour with 'm_szArmsModel'
Reply With Quote #3

This should help you.
More to the point, you are setting it on the client spawning, which CS_SwitchTeam never does.
Maxximou5 is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 11-02-2016 , 19:07   Re: [CSGO] Weird behaviour with 'm_szArmsModel'
Reply With Quote #4

@Neuro Toxin: I will need to kill the player, right?

---
@Maxximou5: I don't understand your point.

All the examples I found with 'm_szArmsModel' are done like above, but it seems that it works only when the player has been killed.

What I'm trying to do is: switch the player team (Without killing him if he's alive), then modify its model + arm model (When he respawns is ok --> I switch the players only during the round end).
The model is always fine, but the arm model isn't updated at the 1st respawn.

----------
==> I would like to avoid to use ChangeClientTeam().
__________________
micapat is offline
dilalmon
AlliedModders Donor
Join Date: Apr 2013
Old 11-02-2016 , 19:16   Re: [CSGO] Weird behaviour with 'm_szArmsModel'
Reply With Quote #5

I've spent two days trying to find a workaround, but I had no luck.
So yes, you need to kill the player and respawn them in order for the change to get applied.
dilalmon is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 11-02-2016 , 19:38   Re: [CSGO] Weird behaviour with 'm_szArmsModel'
Reply With Quote #6

I tried to solved or reduce that bug in my arms plugin
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 11-03-2016 , 15:42   Re: [CSGO] Weird behaviour with 'm_szArmsModel'
Reply With Quote #7

Thank you for your help.

I will continue to dig with IDA. I found the function 'CCSPlayer::SetViewModelArms', it can help to understand how everything works. I need to search more .
__________________
micapat 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 19:54.


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