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

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


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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, 567 views)
File Type: zip skin_menu.zip (1.0 KB, 580 views)
File Type: zip HL-Player-Models-API-1.2.zip (18.5 KB, 571 views)
__________________

Last edited by rtxa; 07-02-2020 at 01:16. Reason: Update to version 1.2
rtxa is offline
 



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 17:22.


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