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

Hook player model change


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 10-09-2022 , 08:50   Hook player model change
Reply With Quote #1

Hi. Does somebody have that player model change hook code snippet?
I just want to store all current models in
PHP Code:
new g_currentMdl[MAX_PLAYERS][]; 
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 10-09-2022 at 10:03.
kww is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-09-2022 , 09:35   Re: Hook model change
Reply With Quote #2

which type of model you want to hook?
Player Model? Weapon View Model?
__________________
My plugin:
Celena Luna is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 10-09-2022 , 10:02   Re: Hook model change
Reply With Quote #3

Quote:
Originally Posted by Celena Luna View Post
which type of model you want to hook?
Player Model? Weapon View Model?
player model
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951
kww is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-09-2022 , 10:08   Re: Hook player model change
Reply With Quote #4

Show the models please.
__________________
DJEarthQuake is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 10-09-2022 , 10:27   Re: Hook player model change
Reply With Quote #5

Quote:
Originally Posted by DJEarthQuake View Post
Show the models please.
Default cs models -_-
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951
kww is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-09-2022 , 10:56   Re: Hook player model change
Reply With Quote #6

usually you can just get model from cs_get_user_model

But if you need to hook when the model change, I think you might need to work with Ham_Keyvalue but I am not sure since there ain't any document or thread about this. Or even worse, use Orpheu

Edit: In ReAPI, there is RG_CBasePlayer_SetClientUserInfoModel that you can use RegisterHookChain to hook it
__________________
My plugin:

Last edited by Celena Luna; 10-09-2022 at 11:03.
Celena Luna is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 10-09-2022 , 11:04   Re: Hook player model change
Reply With Quote #7

Quote:
Originally Posted by Celena Luna View Post
usually you can just get model from cs_get_user_model

But if you need to hook when the model change, I think you might need to work with Ham_Keyvalue but I am not sure since there ain't any document or thread about this
I just do something depending on current player model and every time I do this, I retrieve player model with natives. I thought that I could minimize unnecessary calls by getting model name only when it was set or changed and read it from array.
PHP Code:
new szModel[33];
get_user_info(id"model"szModelcharsmax(szModel)); 
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 10-09-2022 at 11:09.
kww is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 10-11-2022 , 20:52   Re: Hook player model change
Reply With Quote #8

Quote:
Originally Posted by kww View Post
I just do something depending on current player model and every time I do this, I retrieve player model with natives. I thought that I could minimize unnecessary calls by getting model name only when it was set or changed and read it from array.
PHP Code:
new szModel[33];
get_user_info(id"model"szModelcharsmax(szModel)); 
You can hook player spawn or round start, then u can save the string with that function, but with the global variable

PHP Code:
new __str_Model[33][33]; // global


public plugin_init() {
        
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
}
public 
fwHamPlayerSpawnPost(id) {
        
get_user_info(id"model"__str_Model[id], 32 );


Last edited by MrPickles; 10-11-2022 at 20:52.
MrPickles is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-11-2022 , 21:12   Re: Hook player model change
Reply With Quote #9

Quote:
Originally Posted by MrPickles View Post
You can hook player spawn or round start, then u can save the string with that function, but with the global variable

PHP Code:
new __str_Model[33][33]; // global


public plugin_init() {
        
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
}
public 
fwHamPlayerSpawnPost(id) {
        
get_user_info(id"model"__str_Model[id], 32 );

I think what he mean is he want to hook the moment the model changed.
For example, when your character class change in middle of the round, you can't update the array by anymean, except by using native (if the model change is from other plugins)
__________________
My plugin:

Last edited by Celena Luna; 10-11-2022 at 21:14.
Celena Luna is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 10-11-2022 , 21:16   Re: Hook player model change
Reply With Quote #10

Quote:
Originally Posted by Celena Luna View Post
I think what he mean is he want to hook the moment the model changed.
For example, when your character class change in middle of the round, you can't update the array by anymean, except by using native (if the model change is from other plugins)
I don't think there is something specific for that, what I wrote was so that every time it respawned, it would take the current model, so it will always check if the model changed, what I could also do is take the change team event, but independently of that, each team has different characters, and if you also only want to change the character and not the team, it would not detect it, so the code I wrote is more secure, there is (I think) no event or message to register that model change
MrPickles 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:18.


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