Raised This Month: $7 Target: $400
 1% 

HL Player Models API 1.2 [Last Update: 02/07/2020]]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rtxa
Senior Member
Join Date: Mar 2018
Location: Argentina
Old 11-21-2019 , 10:31   HL Player Models API 1.2 [Last Update: 02/07/2020]]
Reply With Quote #1

HL Player Models API



☉ Introduction

This API for Half-Life was made with the aim in mind of being able to use differents skins in Teamplay mode. Normally this is not possible without breaking the gameplay or making a lot of changes that will imply modify every plugin making it unpractical.

Now with this you can add classes for a Zombie Mod, etc.

☉ Description

This let you set custom models to the players and reset them to the default model. The custom model will stay until the player disconnects or you reset it manually.

☰ Natives

PHP Code:
/**
 * Sets a custom player model.
 *
 * @param id      Player index
 * @param model   Model path
 */
native hl_set_player_model(id, const model[])

/**
 * Restores default model of player.
 *
 * @param id    Player index
 */
native hl_reset_player_model(id)

/**
 * Returns the team id of the player, and optionally retrieves the name of
 * the team.
 *
 * @param id            Player index
 * @param team          Buffer to store team name
 * @param len           Maximum buffer length
 */
native hl_get_player_team(idteam[] = ""len 0)

/**
 * Sets the player's team without killing him.
 *
 * @param id        Player index
 * @param teamid    Team id
 */
native hl_set_player_team(idteamid
☰ Requirements
⚙ Installation
  1. Download the attached files and extract them in your scripting folder, then type #include <hl_player_models_api> in your plugin to be able to use the functions.
  2. Compile hl_player_models_api.sma and add it to your plugin list in plugins.ini to turn on the API.
The API is ready to use.

☉ Notes
  • Remember to install Orpheu or ReAPI (ReHLDS) in order to use the API.
  • Any custom model that is going to be set to the player has to be previously precached.
  • It's not necessary the models to be located in models/player/x/x.mdl. Also, you can use an sprite as a player model if you want.
  • If you want to know what model is using a player, save the number that precache_model() gives you, associate the value with a name. Then, you will be able to know the player's model by his modelindex.
⛏ To do
  • ☑ Add support for ReApi (ReHLDS).
  • ☐ (Debatable) Probably the server will crash if you try to change the team of 32 players at the same time (Fullupdate spam?). Make a queue and delay team changes to avoid any issue (That will make the plugin much more safer for team changing unlike natives from HL Stocks).
⚛ Sample plugin

I leave you this sample plugin called “Skin Menu” so you can test it. The skin list can be set in AMX Mod X config's folder creating this file using following format.

skin-list.cfg

PHP Code:
Normal Barney;  models/player/barney/barney.mdl
Postal
;         models/madskillz/postal.mdl
Banana Dancer
;  models/madskillz/bananadancer.mdl
Bender
;         models/madskillz/bender.mdl
Scream
;         models/madskillz/scream.mdl
Droid
;          models/madskillz/droid.mdl
Cool Barney
;    models/madskillz/clanfn.mdl 
  • say !skins [Displays a menu where he can choose a custom skin]
  • say !rskin [Reset player to his original skin]
Attached Files
File Type: zip hl_player_models_api_11.zip (11.6 KB, 537 views)
File Type: zip skin_menu.zip (1.0 KB, 557 views)
File Type: zip HL-Player-Models-API-1.2.zip (18.5 KB, 538 views)
__________________

Last edited by rtxa; 07-02-2020 at 01:16. Reason: Update to version 1.2
rtxa is offline
rtxa
Senior Member
Join Date: Mar 2018
Location: Argentina
Old 07-02-2020 , 01:11   Re: HL Player Models API 1.1 [Last Update: 21/11/2019]]
Reply With Quote #2

## ☰ Changelog

Version 1.2

- Fixed possible crash with Info_RemoveKeyValue().
- Added ReAPI support (ReHLDS servers).
__________________
rtxa is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-18-2021 , 22:55   Re: HL Player Models API 1.2 [Last Update: 02/07/2020]]
Reply With Quote #3

hl_get_player_team() is unable to get the team index of the player. Returns 0 with a malformed string.

Tested with bugfixed HL 0.2.51 (59a2950), the latest version of ReHLDS.

Tested with both Orpheu (my own signatures) and ReAPI.

Code:
new teambuf[32]; new teamid = hl_get_player_team(id, teambuf, charsmax(teambuf)); server_print("TEAMID %d - %s", teamid, teambuf);

Code:
TEAMID 0 - k Mesa
Code:
"mp_teamlist" is "Black Mesa;HECU"


EDIT: Managed to solve it by editing the offsets-cbaseplayer.txt file. I just shifted the offsets by 4.
Code:
"m_szTeamName"  // char[16]
{
	"type"      "string"
	"size"      "16"

	"windows"   "1532"
	"linux"     "1552"
	"mac"       "1552"
}
__________________

Last edited by gabuch2; 04-21-2021 at 00:00.
gabuch2 is offline
rtxa
Senior Member
Join Date: Mar 2018
Location: Argentina
Old 04-26-2021 , 22:34   Re: HL Player Models API 1.2 [Last Update: 02/07/2020]]
Reply With Quote #4

Quote:
Originally Posted by Gabe Iggy View Post
hl_get_player_team() is unable to get the team index of the player. Returns 0 with a malformed string.

Tested with bugfixed HL 0.2.51 (59a2950), the latest version of ReHLDS.

Tested with both Orpheu (my own signatures) and ReAPI.

Code:
new teambuf[32]; new teamid = hl_get_player_team(id, teambuf, charsmax(teambuf)); server_print("TEAMID %d - %s", teamid, teambuf);

Code:
TEAMID 0 - k Mesa
Code:
"mp_teamlist" is "Black Mesa;HECU"


EDIT: Managed to solve it by editing the offsets-cbaseplayer.txt file. I just shifted the offsets by 4.
Code:
"m_szTeamName"  // char[16]
{
	"type"      "string"
	"size"      "16"

	"windows"   "1532"
	"linux"     "1552"
	"mac"       "1552"
}
Hello gabe, strange error, with last version of ReHlds, can you tell me the exact the build? Also bugfixedhl hasn't been updated for a long time ago, would you mind to try this one from this CI i made a couple days ago? https://github.com/rtxa/BugfixedHL/actions

Strange to me that you just needed to increase that offset, i wonder if there's a new HL Build
__________________
rtxa is offline
jao6622
New Member
Join Date: Mar 2022
Old 03-30-2022 , 03:54   Re: HL Player Models API 1.2 [Last Update: 02/07/2020]]
Reply With Quote #5

Hi, compiled everything but when the API loads still looking for Orpheu and it doesn't works

Running lastest ReHLDS version with ReAPI module running
jao6622 is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 04-05-2022 , 06:09   Re: HL Player Models API 1.2 [Last Update: 02/07/2020]]
Reply With Quote #6

even if you install orpheu and add function file this error is thrown:

Code:
L 04/05/2022 - 13:07:16: [ORPHEU] Function "SV_FullClientUpdate" not found
L 04/05/2022 - 13:07:16: [AMXX] Displaying debug trace (plugin "hl_player_models_api.amxx", version "1.2")
L 04/05/2022 - 13:07:16: [AMXX] Run time error 10: native error (native "OrpheuGetFunction")
L 04/05/2022 - 13:07:16: [AMXX]    [0] hl_player_models_api.sma::plugin_init (line 64)

Last edited by lexzor; 04-05-2022 at 06:09.
lexzor is offline
rtxa
Senior Member
Join Date: Mar 2018
Location: Argentina
Old 04-08-2022 , 22:36   Re: HL Player Models API 1.2 [Last Update: 02/07/2020]]
Reply With Quote #7

Thanks for reporting the issues, lexzor and jao6622. In a few days I should be uploading a new version with the fixes. Also I'm planning to improve the Skin Chooser plugin to show the skin selected in third-person mode.

Lexzor, I can't reproduce your error, make sure you are using latest HLDS build from SteamCMD and AMXX 1.9 or 1.10.

jao6622, seems that my way to detect when ReAPI or Orpheu is available is not working as expected, should be fixed in next release.
__________________
rtxa is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 01-23-2023 , 14:27   Re: HL Player Models API 1.2 [Last Update: 02/07/2020]]
Reply With Quote #8

Hello, I was wondering how did you obtain the client_s_offsets values. I want to do a similar implementation in another mod and thus I need to find the values.
__________________
gabuch2 is offline
rtxa
Senior Member
Join Date: Mar 2018
Location: Argentina
Old 01-23-2023 , 17:25   Re: HL Player Models API 1.2 [Last Update: 02/07/2020]]
Reply With Quote #9

Quote:
Originally Posted by gabuch2 View Post
Hello, I was wondering how did you obtain the client_s_offsets values. I want to do a similar implementation in another mod and thus I need to find the values.
Not sure really, I got the values from SV_FullUpdate and client_s_offsets luckily from ConnorMcLeod. First of all, you need to learn how to get signatures, there're many posts on AlliedMods about this using a program called IDA. Anyway, you should ask this in the Discord server, pretty sure there are some signature experts where you can ask.
__________________
rtxa is offline
jontribs
New Member
Join Date: Dec 2023
Location: texas
Old 12-21-2023 , 12:03   Re: HL Player Models API 1.2 [Last Update: 02/07/2020]]
Reply With Quote #10

im having hl_player_models_api 1.2 crash on server start with a non discript error log, (ophou 2.6.3 and amxx 1.10, build 5467)

pastebin: https://pastebin.com/Ha8XQYME

please lmk if you need more information, im new to amx x
jontribs 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 06:26.


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