![]() |
[CZ] Changing model directory "on the fly"?
Hi there
Just a quick question for those more knowledgable than I :) Is it possible to make a dll which will change CS or CZ's default model directory? Now.. the explanation... A while ago "PAF" released the Hostitron which is a plugin for Meta Mod which changes the Hostage models dependant on which map is loaded. Last year sometime (with help from these forums) Dead_Bwoy released Environskin for CZ which, using a new botprofile.db file, allowed you to choose map specific skins for player models after running a server cfg file. What I want to know is, rather than using Botprofile.db etc, is it not possible to tell the CZ executable that the default model directory is "czero/models/player/cs_downed_cz/" rather than "czero/models/player"? This would just be for offline play, so any "hooking" would not interfere with VAC2. Can anyone help with this? |
Re: [CZ] Changing model directory "on the fly"?
Perhaps yes, if you hook pfnSetModel(), when you detect that the model being passed is something like "*/*/player" just concatenate the map name
Code:
sprintf (model_name, "old_model_base_path/%s/player/etc.", STRING (gpGlobals->mapname)); |
Re: [CZ] Changing model directory "on the fly"?
Hmm.. I see what you mean, and that is how I envisaged it (I think!) but i truly have no idea how to achieve this...
Ideally it would look for a "map/player/whatever..." models. I had thought it would be easier with cl_minmodels set to 1 so you would only need two models per map (i.e. Leet and GIGN). If it does not find the correct map folder, then perhaps it would default to the original model directories... not sure how this would work though. Is this a big thing for a knowledgable person to achieve? (i.e.... not me! ???:( ) <edit> If this IS possible, I presume it would only be a matter of adding a new directory for hostages to be map specific too? |
Re: [CZ] Changing model directory "on the fly"?
It should be very simple to do, at least in the form of a metamod plugin. It could be a matter of 20 minutes.
Yes you can start writing it yourself and post here when you get into trouble, we'll gladly help you out. |
Re: [CZ] Changing model directory "on the fly"?
So it would have to be part of Meta Mod?
Could it not be done with the original dll files or something similar? |
Re: [CZ] Changing model directory "on the fly"?
You have to program it somehow. There are two ways: either you do a metamod plugin that does that, either you do the same thing with a hook DLL, that is, a DLL that will sit between the engine and the game DLL (like the early HPB_bot did). This will be a server-side thingy, anyway.
|
Re: [CZ] Changing model directory "on the fly"?
Looks like I'm going to have to do a lot of reading up :)
..any pointers to a good place to start? Cheers for now |
Re: [CZ] Changing model directory "on the fly"?
Download a simple metamod plugin from our filebase that comes with source code, and use it as an example on how to build yours :)
|
Re: [CZ] Changing model directory "on the fly"?
Now then... after much discussion with PM it seems that I would need a basic knowledge of programming to understand the plug-in concept... and I am completely lost now :)
I wonder if anybody here might like to assist me by writing a plug-in for me? Basically, what it should do is - On map load... check map name... then make the default player model and hostage model directory used for that map something like "%s/player" or "%s/hostage", if there is no directory like that then it should use defaults... Meta Mod would be good, but I was wondering about some kind of modified dll file. Though I guess Meta Mod is safer as far as VAC2 goes... If anyone is able to help I'd be much obliged. Cheers for now PS - Thanks to PM for all his help/explanations so far :) |
Re: [CZ] Changing model directory "on the fly"?
So basically you want it to change models/player/terrorist/terrorist.mdl to models/mapname/terrorist/terrorist.mdl?
It may be possible but an inconvenience if you don't have a fast download server, I don't have CS installed anymore so I have no idea how many models there are to change. If you can be very specific on what you want to happen I will write a plugin to do this for you. I gotta write a team balancer for someone anyway so might aswell grab some coffee and work on both. *goes off to write new mm plugin framework* [Added] Damn, I read the z backwards. I don't have CZ but that shouldn't be a problem, I'll test it on another mod but you'd have to let me know how it works. There shouldn't be any problems though :) |
Re: [CZ] Changing model directory "on the fly"?
Superb Lazy... thanks :)
I will make a list and post it soon (just got up and eyes not focusing properly yet!!) Cheers for now <edit> Okay... the eyes are now working after a quick sugar and coffee hit :) The models used in CZ are as follows - models/player/arctic/arctic.mdl models/player/gign/gign.mdl models/player/gsg9/gsg9.mdl models/player/guerilla/guerilla.mdl models/player/leet/leet.mdl models/player/militia/militia.mdl models/player/sas/sas.mdl models/player/spetsnaz/spetsnaz.mdl models/player/terror/terror.mdl models/player/urban/urban.mdl models/player/vip/vip.mdl It is a little difficult to add the hostages into an updated CZ install as the models have been changed from standard CS type ones. But would it be possible (not to sound greedy!) to make a second dll which could be used by a standard CD install of CZ and CS? This would need to change the models for - models/player/arctic/arctic.mdl models/player/gign/gign.mdl models/player/gsg9/gsg9.mdl models/player/guerilla/guerilla.mdl models/player/leet/leet.mdl models/player/sas/sas.mdl models/player/terror/terror.mdl models/player/urban/urban.mdl models/player/vip/vip.mdl models/hostage.mdl Now then, I had intended that this be used with "cl_minmodels 1" on, so you would actually only have to change the leet and gign models, but I'm not sure that you can change just the variable "models/player" to "models/mapname/player/". Does it have to be the full path to each model? I shall leave that to you :) Thanks again for your offer. If you need any more information, just give me a shout! Cheers for now </edit> |
Re: [CZ] Changing model directory "on the fly"?
Posting just to add a new "timestamp" in case you already read my reply..
Doh me! By the way, added your AOL, so I'll try to catch you online too. |
Re: [CZ] Changing model directory "on the fly"?
Hmmm... actually, this may be of some use.
Just for interest, the XBox version of CS uses a "cfg" file to decide which models to use on which map. It refers to a file called "playermodels.txt" which contains this information - Code:
de_dust models/player/de_dust/leet.mdl models/player/de_dust/seal.mdl |
Re: [CZ] Changing model directory "on the fly"?
The one dll I create should work across all mods, all it needs to do is adjust some paths.
ie. from "models/hostage.mdl" to "models/cs_office/hostage.mdl" It doesn't get any easier than creating a directory with the same name of the map in your models directory. When the model is being precached, I'll tell it to look for it in models/mapname/ first. If that doesn't work ( pfnPrecacheModel returns <= 0 ) then it will use the default model instead. No config files needed :) |
Re: [CZ] Changing model directory "on the fly"?
Ah right.. I understand :)
That will be excellent as it will work with the spetsnaz and militia for CZ also. Thanks again!! :D |
Re: [CZ] Changing model directory "on the fly"?
Shouldn't be too much longer, the code to change models is already complete.
I just have to figure out why the version of gcc that comes with cygwin won't compile it. |
Re: [CZ] Changing model directory "on the fly"?
Sounds good Lazy!
But.... I had a thought earlier about the updated Hostages in CZ. It seems that instead of just being called hostage.mdl they are called hostageA.mdl, hostageB.mdl, hostageC.mdl and hostageD.mdl Would this cause an issue if it were to be added in a possible future release? Then there are the hostage sound files to consider :) I will have to check it all out once you have figured your compile problem. Good luck and good night!! |
Re: [CZ] Changing model directory "on the fly"?
Well, to override a default model all you'd need to do is put the replacement in models/mapname/ and it should be done automatically.
|
Re: [CZ] Changing model directory "on the fly"?
Ah yes of course. I had forgotn that you were making "global" changes to the path :)
Just another question then, would it be to much of an issue to add a change to sounds? So that it would look in "sound/mapname/player or hostage" and then check "sound/player or hostage"? Or is this a big change? Cheers for now |
Re: [CZ] Changing model directory "on the fly"?
Not at all, the only problem may be with playermodels but that can be fixed easily ( models on the server are models/player.mdl for everyone ).
I'm just going to install visual studio for now, I've spent all the time I should have been coding on trying to get it to compile under cygwin. |
Re: [CZ] Changing model directory "on the fly"?
Okay. Thanks for going to all this trouble, it's much appreciated :)
|
Re: [CZ] Changing model directory "on the fly"?
Np, though hl is fighting me along the way though lol.
I have it at the point where it should work but then I get a "bad character in client command" error when I join my server. That makes absolutely no sense at all, the path only gets the mapname added to the start :/ What goes in: weapons/emp_1.wav What comes out: 2fort/weapons/emp_1.wav All is good, no precache errors, the file was checked to exist and I even unhooked EmitSound to be sure. Heres it so far, I did some re-designing so only the sound stuff is in right now. The plugin framework is turning out nice too, so much easier now :) Code:
#include <stdio.h> I put a breakpoint just before PrecacheSound returns, the updated path is normal with no unusual characters of any kind. That is whats bothering me so much. Only a small delay though, this will get fixed. |
Re: [CZ] Changing model directory "on the fly"?
Hmm.. not being knowledgable about these things I had a look at Steampowered about this...and there was a particular support query about this...
Does this help? http://steampowered.custhelp.com/cgi...i=&p_topview=1 |
Re: [CZ] Changing model directory "on the fly"?
Thanks but the server is running on the same machine I play/develop on and the problem goes away when my code is disabled.
I'm going to take another look at it now but I can't see anything wrong. |
Re: [CZ] Changing model directory "on the fly"?
Lazy, for the player models, you will certainly need to set them in the client's key/value data.
Another tip, don't bother converting forward slashes to backwards slashes, even on Windows. Always use forward slashes, everywhere. And at least one big mistake: define your local character arrays as static if you return pointers to them, else they are deallocated when the function exits. |
Re: [CZ] Changing model directory "on the fly"?
I never return pointers to local variables, what I did is make the caller pass a pointer to it's own local variable which gets the new string copied into it.
And the only time I convert to backslashes is when I use fopen to check if the file exists or not, but I still have no idea why I'm getting this error. OR, is hl keeping a pointer to szNewpath when I call PRECACHE_SOUND? That would explain a lot but I'd assume it makes a copy first. [Added] Well, it looks like HL needs a copy of the string. The problem was solved by changing szNewpath to STRING( ALLOC_STRING( szNewpath ) ). Bah, I would never keep a string pointer like that. Thanks PMB, now I can get back to finishing this thing http://forums.bots-united.org/images...es/biggrin.gif |
Re: [CZ] Changing model directory "on the fly"?
...And dont worry about register thingy. c & cpp copilers are "smart" enough to do it automaticaly. Check youreself by compiling & re-engeneering the output code. Btw why dont make those lil func's inline or macros?
|
Re: [CZ] Changing model directory "on the fly"?
The only time I read code output was when I was trying to make my function hooking class, took me a long time to get it right but I finally got that JMP instruction to work :)
Anyway, which functions are you talking about? The BEGIN_xxx functions are just macros that handle setting up the dll automatically and hooking various APIs. |
Re: [CZ] Changing model directory "on the fly"?
Quote:
Having the directory structure like this will mean that your mod root directory will be rather full of "extra" entries... Would it be better to have a new directory to dump your map specific models/sounds into? Something like "MOD ROOT / lazy / %s / weapons / ..." etc or is that a different kettle of fish entirely? Cheers for now |
Re: [CZ] Changing model directory "on the fly"?
I don't think its possible for sounds since hl will only play whats inside the sound directory and its subdirectories.
It used to be possible under won, in tfc I would have it speak sounds from cs under tfc by using something like ../../../../cstrike/sound/terwin and it worked for those who had cs installed. But since steam that sort of thing wont work, which is why I chose that layout. |
Re: [CZ] Changing model directory "on the fly"?
yea sound changing is still possible
8.3.5.155:27015 -highly modded server.. this server dumps all of it's own server's sounds into a folder in the sound folder. |
Re: [CZ] Changing model directory "on the fly"?
Well I guess whatever works will be good :D
I'm quite looking forward to this! <edit> That server only seems to have custom sounds for "say" commands and "round win", which are usually just different "Terrorist Win" wav files. It also has skin selection, but this isn't automatic. http://www.radclan.net/index.php?page=Plugins |
Re: [CZ] Changing model directory "on the fly"?
Quote:
MOD ROOT / sound / %s / hostage / or MOD ROOT / models / %s / player / or MOD ROOT / models / %s / etc.... PS - If you need any testing doing, just hit me up :) |
Re: [CZ] Changing model directory "on the fly"?
I have finished the normal model changing and the sound should be done today.
The player models will require me to research it first since I have never changed them in a server-side plugin. Also, new player models have to be precached manually so players download them and won't be invisible due to the missing model. But the playermodel changing shouldn't be too hard, it does seem odd though. If I change the client's model keyvalue to "models/rock2/player/demo/demo.mdl" the model dissappears. I know it's been done so it shouldn't be too hard to get it working. |
Re: [CZ] Changing model directory "on the fly"?
Can anyone confirm that you can change a player's model in cs/cz by changing the "model" keyvalue on the client?
It doesn't work that way in tfc and I'm still downloading CS from steam so I can't test it for myself. I hope this works out for player models, if it doesn't then I apologize for suggesting it could be done. Though the gameplay models and sounds will have no problems at all being switched. |
Re: [CZ] Changing model directory "on the fly"?
yes it seems possible.
as here is some code from VexdUM module for amx VexdUM.cpp: Code:
static cell AMX_NATIVE_CALL CS_SetModel(AMX *amx, cell *params) { Code:
// pfnPlayerPostThink, this code is to set the model at a specified time. Code:
// Engine message functions. |
Re: [CZ] Changing model directory "on the fly"?
Thanks alot, I'll get around to finishing this once I get a test server set up.
[Update] I have it partially working, though it will only load models if it has its own directory under models/player. What this means is that models/player/cs_assault/blah will not work, what will work is if you make the "blah" directory in your models/player folder. I have tried to get it to work the other way but it _really_ screws up the path, something like "models/player/cs_assault/onos/onos.mdl/cs_as". I'm guessing config files will be needed for each map but for player models only, it will also setup precaching so that all clients have the new models. |
Re: [CZ] Changing model directory "on the fly"?
So, if I understand this properly -
If CS/CZ wants to load the leet.mdl for instance, it will now try to load - mod root/models/player/mapname/leet/leet.mdl ? If that's correct, what will the path be to the other models and the sounds directory? Would it even be easier to just have a config frile for each map so you don't need to make global changes? If there is no config, then standard models apply etc... |
Re: [CZ] Changing model directory "on the fly"?
The way CS works is the "model" value on the client specifies a directory and model name in the "models/player" folder.
Unfortunately this means that you cannot just create a "mapname" subdirectory and redirect model paths to use it since the path gets messed up somehow. So if you want to change a model you need to do this: NOTE: This is only for player models! Normal ones are automatic! - Create the "modchange_cfgs" directory in the mod root ( ie. "cstrike" ) - For each map you want to switch the models on create a new file called "mapname".txt - Make a new directory in your models/player folder with a name you can remember ( ie. "cs_assault_onos" ) - Copy your replacement model into that folder and rename it to the folder name The format of the config file is very simple, all it is is this - original_model=new_model. Example: Code:
All the replacement models in the config will be precached to make sure they download to all the clients. Still working on it now, will have a screenshot soon. |
Re: [CZ] Changing model directory "on the fly"?
Okay, so that is a bit clearer :)
Just to recap (in CZ terms!) I will have a folder in my czero directory named "modchange_cfgs" or something a little easier to remember :) In that folder I will have various .txt files named after each map I want to alter. In, for example, de_piranesi_cz.txt I will need to type something like - sas=ct gign=ct gsg9=ct urban=ct spetsnaz=ct leet=t terror=t guerilla=t militia=t arctic=t Then in my models/player directory I need two directories called - models/player/de_piranesi_cz_ct and models/player/de_piranesi_cz_t with models in them called - de_piranesi_cz_ct.mdl and de_piranesi_cz_t.mdl PHEW!! (I've made a CZ map an example as they have the most confusing mapnames yet! If I can understand that, then I am set!) ....or am I a bit tired from being in the sun too long? 8D <edit> Oh yes, and will the other models and sounds take the same structure? |
All times are GMT +2. The time now is 08:34. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.