Half-Life и Adrenaline Gamer форум
http://aghl.ru/forum/

Ways to change player model
http://aghl.ru/forum/viewtopic.php?f=12&t=2937
Страница 1 из 2

Автор:  rtxa [ 06 окт 2018, 01:29 ]
Заголовок сообщения:  Ways to change player model

Hi, I'm currently finishing a zombie mod for HL which I'm going to release soon, I'm looking to add zombie classes, but I really don't know how to change players models properly, I have try some ways but I end up breaking the scoreboard or something else... Any help is appreciated.

Автор:  abdobiskra [ 06 окт 2018, 01:36 ]
Заголовок сообщения:  Re: Ways to change player model

Hi,
viewtopic.php?f=20&t=2225

Автор:  rtxa [ 06 окт 2018, 01:40 ]
Заголовок сообщения:  Re: Ways to change player model

abdobiskra писал(а):
Thanks, I have read it all before, some of the solutions given there are which end up breaking the scoreboard. The thread is old so maybe someone has found a properly solution.

Автор:  abdobiskra [ 06 окт 2018, 01:48 ]
Заголовок сообщения:  Re: Ways to change player model

I remember it was the same problem and I forgot where the solution was put
I found a test might be the solution!
 
If it does not work, I will try to find it tomorrow if God wills :)

Автор:  rtxa [ 06 окт 2018, 03:19 ]
Заголовок сообщения:  Re: Ways to change player model

Thanks, but that is the code that breaks the scoreboard.



When I'm a human and I use /smodel, human bots are trying to kill me and they can hurt me, but the scoreboard isn't affected apparently.
Изображение



After that, I respawn being a human, human bots are trying to kill me yet, but now they can't hurt me, but now the scoreboard gets break. I become a zombie but the scoreboard remains the same.
Изображение

Of course, functions that are dependent of model userinfo get breaks, like hl_get_user_mode, something has to be redone, is ugly how HL handles this.

Автор:  Lev [ 14 фев 2019, 00:22 ]
Заголовок сообщения:  Re: Ways to change player model

I think changing model in AddToFullPack should work. Even if it will be expensive, I still can recommend to try it.

Автор:  rtxa [ 20 фев 2019, 02:40 ]
Заголовок сообщения:  Re: Ways to change player model

Lev писал(а):
I think changing model in AddToFullPack should work. Even if it will be expensive, I still can recommend to try it.
Well, I'm already using a semiclip plugin, so that shouldn't be a problem, but that doesn't work, I change ES_ModelIndex and there are no changes, can you show me some code?

Автор:  rtxa [ 07 мар 2019, 00:33 ]
Заголовок сообщения:  Re: Ways to change player model

Well, I have some news, I have find the way to make the method with AddToFullPack(), you need to remove "model" key info, when player spawns, set his model to "", after that, block any changes with SetClientKeyValue() and client_infochanged() forwards.

After some testing, I realize that AddToFullPack method breaks to lot of things in teamplay mode, and it will be hard to trick the gamedll to make it work fine, so I'm going back to the old method, still there is an issue whenever you set a custom model that is already in mp_teamlist.

Also, with AddToFullPack() method, by removing "model" key info, you are going to break the way bots can tell if player is teammate or not, so it's no sense to use this method because is more hard to trick the gamedll.

Автор:  Lev [ 19 мар 2019, 02:39 ]
Заголовок сообщения:  Re: Ways to change player model

Checked the code. Looks like I was wrong. Let me suppose now that AddToFullPack works for other entites. And players are getting models to render from special svc_updateuserinfo message.
So, let assume that you are playing on the server. Then server sends you svc_updateuserinfo about each other player on the server.
Код:
   MSG_WriteByte(sb, svc_updateuserinfo);
   MSG_WriteByte(sb, cl - g_psvs.clients);
   MSG_WriteLong(sb, cl->userid);
   MSG_WriteString(sb, info);
Your client engine parse these messages into player_info_t structure, and client game dll taskes that data into hud_player_info_t via
Код:
GetPlayerInfo(playerIndex + 1, &g_PlayerInfoList[playerIndex + 1])
And then renders it with
Код:
g_PlayerInfoList[playerIndex + 1].model
Server's game dll uses the same info field "model" to select team for the player.
So your goal is to:
  • tell game dll on the server that each player has one specific team model, for ex. "red" and "blue"
  • tell engine on the server that each player has some unique model to render.
I think this is possible because you are sitting between game dll and engine on the server, so you can control how game dll sees that data.

So, to the action:
  • use engclient_cmd command to set setinfo for the player on the server. Here use your custom models.
  • hook and block FM_ClientUserInfoChanged, so new model info will not pass to the game dll.
  • to let player to change name, for example, or to set his team, use this code inside of blocked FM_ClientUserInfoChanged:
    Код:
    new info = engfunc(EngFunc_GetInfoKeyBuffer, id);
    // change model inside [b]info[/b] variable to required team model name
    ...
    // pass corrected info to the game dll
    dllfunc(DLLFunc_ClientUserInfoChanged, id, info);
I think this should work.

Автор:  rtxa [ 20 мар 2019, 23:26 ]
Заголовок сообщения:  Re: Ways to change player model

A few days ago I finished HL Player Models API, have you take it a look? By removing model info from player, I was able to set any modelindex, so no need to use AddToFullPack, instead, set modelindex on PlayerPostThink_Post(). Unfortunately, that breaks compatibility with anything that uses player's model to distinguish teams.
Interesting solution, but I have some doubts, how can you set player model with engclient_cmd()? I have test some values like "model gina", but it doesn't trigger anything. I show you what I have done.
Код:
SetModel(id) {
   new info[256];
   copy_infokey_buffer(engfunc(EngFunc_GetInfoKeyBuffer, id), info, charsmax(info));

   new idx = contain(info, "model\");
   if (idx != -1) {
      new model[128];
      strtok(info[idx + 6], model, charsmax(model), "", 0, '\');
      replace(info[idx + 6], charsmax(info), model, "gina");
   }

   message_begin(MSG_ALL, SVC_UPDATEUSERINFO);
   write_byte(id - 1);
   write_long(get_user_userid(id));
   write_string(info);
   write_long(0);
   write_long(0);
   write_long(0);
   write_long(0);
   message_end();
}
This method changes player model without too much effort and it doens't break compatability :Yahoo!:.
What remains would be to see in what moments we have to call this. I would like to hook SVC_UPDATEUSERINFO and change values from there, but when I try this from AMX Mod X, it never gets call.

Страница 1 из 2 Часовой пояс: UTC + 5 часов [ Летнее время ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/