AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
|
10-20-2014
, 15:18
Entity Resources Replacement[ V 1.4 ]
|
#1
|
Entity Resources Replacement 1.4
Release: 20.10.2014 | Last Update: 29.06.2016
IF YOU ARE UPDATING FROM VERSION 1.3: REMOVE YOUR OLD CONFIGURATION FILES AND DOWNLOAD NEW ONES(INSIDE ARCHIVE). THEY WERE REWRITTEN, ALSO A TYPO IN DYNAMIC REPLACEMENT FILE NAME WAS FIXED.
Table of Contents
Description top
Even if the name may be confusing, this is a very simple and easy-to-use plugin. The aim is to be the ultimate solution for changing models/sprites/sounds.
It provide two ways of replacing:- Complete replacement
- Pros
- Work in all HL mods.
- Using better methods to accomplish the same results. The memory is patched at map start, just one time. This brings some drawbacks, you can read them below.
- All-In-One, you can change sprites,sound and models. It's not only for weapons.
- Easy to configure.
- The old resources are not precached, so it won't increase the precache list, it won't over 512
- Cons
- The string that will replace another one must have a size lower or equal than the original one. Not a big deal, just rename it if it's too long.
- You can't change things per player, you can't have resources for vips and another resources for normal players or stuff like that. Everything is global.
- DynamicReplacement
- Pros
- Allow you to change dynamically player models, weapon models & sounds]
- You can change them only for a player, only for a team, for admins or for all.
- You can also replace a specific model with another one.
- As you can see, all the cons from the complete replacement become pros here. By combining this two ways I'm sure you won't need another replacement plugin.
- Cons
- It will increase the precache limit
Please read the full post, if you want to be able to run this plugin properly and to take advantage of all features that it's providing.
From version 1.3 a version checker was included. This mean that the plugin will connect to http://hamletplugins.comyr.com/test.html to get the lastest version and inform you if you are running the latest one or you should update. It also gets the changelog for the next version. If you are running an older one the plugin will automatically print the changelog for latest version so you know what changes were done.
Example:
Code:
L 06/28/2015 - 10:21:10: [test2.amxx] Your version 1.2 is outdated. Last version is: 1.3
L 06/28/2015 - 10:21:10: [test2.amxx] Changelog for V 1.3:
L 06/28/2015 - 10:21:10: [test2.amxx] + Added version checker
L 06/28/2015 - 10:21:10: [test2.amxx] + Better filtering for wrong configurations, missing models/sounds
L 06/28/2015 - 10:21:10: [test2.amxx] + Added changelog display for suggested version
L 06/28/2015 - 10:21:10: [test2.amxx] + Filtering mp3 files to prevent user input errors
L 06/28/2015 - 10:21:10: [test2.amxx] + Added a new identifier for replacement - admin flags
L 06/28/2015 - 10:21:10: [test2.amxx] + Flags are now additive for player & weapon models
L 06/28/2015 - 10:21:10: [test2.amxx] + Code cleaned
L 06/28/2015 - 10:21:10: [test2.amxx] + Fixed some tipos
Requirements top
This doesn't require much special things, only:- Orpheu module.
- A server without dproto.
This is not generally needed, but I won't help you if you are running an outdated server with dproto. If you are experiencing problems, update your server/ fix the erros by yourself.
Installation top[INDENT]
To install the plugin:- Download the resources from this post. You need to get the source and compile it locally.
- Put entities_resources_replacement.amxx in addons/amxmodx/plugins
- Put entities_resources_dyn_replace.ini in addons/amxmodx/configs
- Put entities_resources_comp_replace.ini in addons/amxmodx/configs
- Open addons/amxmodx/configs/plugins.ini and add at the end of this file entities_resources_replacement.amxx
- You can put the sma file into addons/amxmodx/sources but this is not mandatory.
- Copy the content from orpheu folder to addons/amxmodx/configs/orpheu
- Restart the server/change map.
To install orpheu:- Download orpheu_files-2.5.1.zip and extrat the arhive.
- Copy orpheu_amxx.dll/orpheu_amxx_i386.so depending on your operation system into addons/amxmodx/modules
- The module will be auto-loaded, you don't need to add it into modules.ini
To compile locally:- First way:
- Download AMX Mod X for windows/linux from main site
- Extract somewhere the arhive and remember the folder!
- Copy the content from include folder from the orpheu arhive into addons/amxmodx/scripting/include( in the folder created in the step 2 ).
- Download celltravtrie.inc that is attached to this post and put it inside include. The one from Hawk post seems to be changed and is missing a stock.
- Download the source of the plugin( entities_resources_replacement.sma) from this post and drag it over the compile.exe(scripting folder from the arhive created at step 2)
- It will create a new folder called compiled. Open it and you will find your compiled plugin( entities_resources_replacement.amxx )
- Second way:
- Go to http://spider.limetech.org/
- Copy/paste the code from the .sma file into the website.
- Under the big blue Compile button you see a box which Drop .inc files here
- Then press Compile and Download
Configuration top
You can use complete replacement file, dynamic replacement or both at the same time! In order to switch from one to other you need to change the cvar ToggleReplacementType.
Change this value to 1 for complete replacement, to 2 for dynamic replacement or to 3 for both replacements. Note that this cvar in cached, so new values are read after map change.
To configure complete replacement file:
Open entities_resources_comp_replace.ini and you will see some instructions on how you should use the plugin.
You need to know that you can change resources in all maps, or they can be map specific. In order to acquire this:- Map specific: rename the file, including the map name: entities_resources_comp_replace.ini -> entities_resources_comp_replace-map_name.ini. If you want the resources to be change only in de_dust2 you would do entities_resources_comp_replace-de_dust2.ini. It's very important to write the map name correctly!
- Global changes: just let the name as entities_resources_comp_replace.ini. There is no problem if you have a global config and some configs that are map specific. If the needed map is running it will load the map config, otherwise it will load the default one.
- No configuration file: if no configuration file is found, the plugin will be paused in the current map.
To change resources one would do
Code:
new_resource old_resource
You can replace sprites, sound and models. A path should look like
Code:
models/sound/sprites/file_name.mdl/wav/spr
For sounds, you still need to write sound/ in path, it will be automatically removed inside the plugin.
Some examples:
- To change models:
Code:
models/v_ak47.mdl models/v_m4a1.mdl
models/p_ak47.mdl models/p_m4a1.mdl
models/w_ak47.mdl models/w_m4a1.mdl
This will change all the ak47 models to m4a1 models. Silly, but it's a clear example.
- To change sounds:
Code:
sound/weapons/knife_hitwall1.wav sound/weapons/ak7-1.wav
This will change knife_hitwall1.wav sound to ak47-1.wav sound. You are not allowed to use mp3 files, PLEASE only .wav sounds.
- To change sprites:
Code:
sprites/old.spr sprites/new.spr
You will do the same as for sounds and models, too lazy to write an example. This feature is very good, as you no longer need plugins as "he explosion sprite changer" and so.
To configure dynamic replacement file:
Open entites_resources_dyn_replace.ini and you'll have full instruction with examples.
You need to know that you can change resources in all maps, or they can be map specific. In order to acquire this:- Map specific: rename the file, including the map name: entites_resources_dyn_replace.ini -> entites_resources_dyn_replace-map_name.ini. If you want the resources to be change only in de_dust2 you would do entites_resources_dyn_replace-de_dust2.ini. It's very important to write the map name correctly!
- Global changes: just let the name as entites_resources_dyn_replace.ini. There is no problem if you have a global config and some configs that are map specific. If the needed map is running it will load the map config, otherwise it will load the default one.
- No configuration file: if no configuration file is found, the plugin will be paused in the current map.
As from version 1.3, some interesting things were added:
- For both weapons & player models new type of replacement was added, by admin flags. You must write Flag_letters. If you want to give a model to all admins that have ban acces you must do Flag_d and the rest is the same, write the model as for any other replacement type(team/steam etc)
- Example:
Code:
Flag_d models/v_ak47.mdl models/v_m4a1.mdl models/p_m4a1.mdl models/w_m4a1.mdl
Flag_abcdefghijklmnopqrstu models/v_m4a1.mdl models/v_ak47.mdl models/p_ak47.mdl models/w_ak47.mdl
- A new cvar was added: AdminFlagsReadType -> change the way in which admins flags are checked.
- 0 means contain - the flags from file must be contained in user flags.
- 1 means equal - flags from file must be the same as the user flags.
- Example: in the file we have the flags abc and a user with flags abcdefghijklmnopqrstu
- If the cvar value is 0, he will get the model, because abc is contained in abcdefghijklmnopqrstu
- If the cvar value is 1, he won't getthe model, because abc is not equal to abcdefghijklmnopqrstu
- The biggest and most interesting part, flags are now additive, this mean you can combine them with "+".
- Example:
Code:
STEAM+TEAM_CT some_model
STEAM+TEAM_TERRORIST some_other_model
Flag_abcd+TEAM_CT+STEAM_ some_model
You are not limited at only two flags, you can combine as many as you want, but without ALL flag. Also, the same thing can be done for weapon models.
- Change Weapon Models
- Go to [WEAPON MODELS]
- Read the instructions from file, I'm not going to repost here
- Under ;Add your models below: add your new resources
- Example: ALL models/v_ak47.mdl models/v_m4a1.mdl models/p_m4a1.mdl NULL
- Use NULL in order to skip a model from the syntax.
- Syntax:
- STEAM_...... v_old_model v_new_model p_new_model w_new_model
- Flag_acces v_old_model v_new_model p_new_model w_new_model
- TEAM_TERRORIST model v_old_model v_new_model p_new_model w_new_model
- TEAM_CT model v_old_model v_new_model p_new_model w_new_model
- ALL model v_old_model v_new_model p_new_model w_new_model
- Change Player Models
- Go to [PLAYER MODELS]
- You have full instructions, please pay attention on them.
- Under ;Add your models below: add your custom models
- Example: TEAM_CT antifurien
- Use NULL in order to skip a model from the syntax.
- Syntax:
- STEAM_...... model
- Flag model
- TEAM_TERRORIST model
- TEAM_CT model
- ALL model
- OldModel modell
- Change Sounds
- Find [SOUND SECTION]
- Again, read the instructions from the file.
- Under ;Add your sounds below: add your custom sounds
- Syntax: old_sound new_sound
- Change sprites
- Find [SPRITE SECTION]
- Again, read the instructions from the file.
- Under ;Add your sprites below: add your custom sprites
- Syntax: old_sprite new_sprite
Important:If you see that some of your resources are not replaced check server console & logs file, when some files are skipped, you will find there the full reason.
API top
What mean API ? API stands from Application Programming Interface and it's here for compatibility purpose.
INC file:
PHP Code:
#if defined _err_api_included #endinput #endif #define _err_api_included
/** * This native is for compatibility purpose. * You search for a default string and it will point you to the new one. * Example: → models/v_ak47.mdl(old string) models/v_m4a1.mdl(new string) → By searching for models/v_ak47.mdl you will get models/v_m4a1.mdl * * @param Input The string that you want to search for. * @param Output The buffer in which the found string will be saved. * @return -1 on failure, 1 otherwise */ native err_find_replaced_string(const Input[], const Output[])
/** * Return replacement type * Check replacement type before using err_find_replaced_string
* @return → -1 on failure. → 1 for complete replace → 2 for dynamic replace → 3 for both */ native err_find_replace_type()
As you can see it has two natives. The inc file is self explanatory, just read the documentation.
Plugin Example
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx> #include <err_api> //include the custom library
public plugin_init() { if(err_find_replace_type() != 2) { new szString[128] //this will be the buffer in which the output will be stored. err_find_replaced_string("models/v_ak47.mdl", szString) //find what replaced models/v_ak47.mdl string server_print("Searched models/v_ak47.mdl | Found:%s", szString) //print it to server console. } }
err_find_replaced_string native will return -1 on failure, it's up to you to check this before working with the output.
The native is usefull when you want to run other plugins that do stuffs in FM_SetModel and check for default model name. To be sure you check the right model, search with this native for the original one, if it was replaced it will point you to the other one.
Credits top- Arkshine: some ideeas
- BackStabNoob: topic design
ChangeLog top- V 0.1:
- V 0.2:
- Added support for sounds.
- Removed an useless cvar.
- Minor improvements.
- V 0.3:
- Fixed some stuffs.
- Added more checks to prevent user errors.
- V 0.4:
- Added support for sprites.
- Added more and more checks to prevent user errors.
- V 0.5:
- Removed some useless checks, plugin will be paused in that situations
- Fixed another silly mistake
- V 0.6:
- Remove some useless arrays
- Added a native for campatibility purpose
- Code optimized, less checks.
- V 0.7:
- Added DefaultDeploy() hook
- Using orpheu to hook DefaultDeploy(), some troubles with okapi
- Added dynamic replacement way
- Added support for dynamic changind player models, sounds and weapon models
- Changed a bit my code style
- Added more checks to prevent user errors
- Fixed the encoding bug with complete replacement file
- V 1.0:
- Fixed some bugs.
- Now you can use both replacement types at the same time.
- V 1.1:
- Fixed bugs with model setup
- Added new option: replace a model with another one
- Code optimized
- V 1.2:
- Fixed identation
- Code cleaned a bit.
- Removed something left here by mistake after testing.
- V 1.3:
- Added version checker
- Better filtering for wrong configurations, missing models/sounds | Added changelog display for suggested version
- Filtering mp3 files to prevent user input errors
- Added a new identifier for replacement - admin flags
- Flags are now additive for player & weapon models
- Code cleaned
- Fixed some tipos
- V 1.4:
- Fixed DefaultDeploy() signature, it should be more reliable now.
- Fixed a crash with unpatching memory in certain situations.
- Fixed a crash that happened when plugin was paused.
- Fixed a typo in dynamic replacement file name.
- Fixed a bug that occured while trying to get the changelog. Plugin was priting error messages when it was not the case.
- Code was completely rewritten, now it's easier to maintain and understand. Also it makes more sense now.
- Added sprite replacement in dynamic replacement mode.
- Proper checks are enforced on resources.
- Configuration files were rewritten, instructions are much more clear, for the sake of usability.
- Probably much more things that I can't remember.
Downloads top- V 0.1: 23 downloads
- V 0.2+0.3: 20 downloads
- V 0.6: 45 downloads
- V 1.0: 128 downloads
- V 1.2: 64 downloads
- V 1.3: 242 downloads
__________________
Last edited by HamletEagle; 07-31-2016 at 08:20.
|
|