AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hook player model change (https://forums.alliedmods.net/showthread.php?t=339918)

kww 10-09-2022 08:50

Hook player model change
 
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][]; 


Celena Luna 10-09-2022 09:35

Re: Hook model change
 
which type of model you want to hook?
Player Model? Weapon View Model?

kww 10-09-2022 10:02

Re: Hook model change
 
Quote:

Originally Posted by Celena Luna (Post 2790675)
which type of model you want to hook?
Player Model? Weapon View Model?

player model

DJEarthQuake 10-09-2022 10:08

Re: Hook player model change
 
Show the models please.

kww 10-09-2022 10:27

Re: Hook player model change
 
Quote:

Originally Posted by DJEarthQuake (Post 2790679)
Show the models please.

Default cs models -_-

Celena Luna 10-09-2022 10:56

Re: Hook player model change
 
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

kww 10-09-2022 11:04

Re: Hook player model change
 
Quote:

Originally Posted by Celena Luna (Post 2790684)
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)); 


MrPickles 10-11-2022 20:52

Re: Hook player model change
 
Quote:

Originally Posted by kww (Post 2790685)
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 );



Celena Luna 10-11-2022 21:12

Re: Hook player model change
 
Quote:

Originally Posted by MrPickles (Post 2790812)
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)

MrPickles 10-11-2022 21:16

Re: Hook player model change
 
Quote:

Originally Posted by Celena Luna (Post 2790814)
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


All times are GMT -4. The time now is 15:33.

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