AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cs_set_user_model — place for call (https://forums.alliedmods.net/showthread.php?t=229931)

Phant 11-17-2013 05:51

cs_set_user_model — place for call
 
Hello.
For example, I have my custom SAS Player model ("sas_super.mdl").
I want use this model on my server as fully replace a default SAS model (for every player, who selects SAS for CT).
Okay, and where I should call cs_set_user_model() function?
In many of plugins, this function called after player spawn, but, it's correct?
Thanks!

Phant 11-17-2013 06:19

Re: cs_set_user_model — place for call
 
Quote:

Originally Posted by LordOfNothing (Post 2061868)

Oh. Read what I write.
I know how to hook player Spawn and I know how to set player model.
I am looking for place better than player spawn where I should call cs_set_model function.

ConnorMcLeod 11-17-2013 06:20

Re: cs_set_user_model — place for call
 
This is not what he wants.

To catch when sas model is applied, hook FM_SetClientKeyValue, filter when key is "model" and when value is "sas", then, check actual user model (get_user_info(id, "model", szModel, charsmax(szModel)), in case you would already have applied the model.

In both cases you supercede the function, and if actual player model is not your custom one, send set_user_info(index, "model", CUSTOM_SAS) on it.
Don't use cs_set_user_model it is buggy.

Bos93 11-17-2013 06:54

Re: cs_set_user_model — place for call
 
Patching strings in memory more efficient https://forums.alliedmods.net/showthread.php?t=117930

ConnorMcLeod 11-17-2013 06:57

Re: cs_set_user_model — place for call
 
Quote:

Originally Posted by Bos93 (Post 2061883)
Patching strings in memory more efficient https://forums.alliedmods.net/showthread.php?t=117930

Not really, would be trivial for this.

Phant 11-17-2013 08:34

Re: cs_set_user_model — place for call
 
ConnorMcLeod, thanks you very much! You're master :D.

I write (done) working code (replase "sas" on "test" model), hope it is okay:
PHP Code:

public SetClientKeyValue(id, const szInfoBuffer[], const szKey[], const szValue[])
{
    if(
equal(szKey"model"))
    {
        if(
equal(szValue"sas"))
        {
            new 
szModel[16]
            
get_user_info(id"model"szModelcharsmax(szModel))
            if(!
equal(szKey"test"))
            {
                
set_user_info(id"model""test")
                return 
FMRES_SUPERCEDE
            
}
        }
    }
    return 
FMRES_IGNORED



ConnorMcLeod 11-17-2013 08:43

Re: cs_set_user_model — place for call
 
supercede should be for the whole "sas" matching block.

Phant 12-07-2013 10:02

Re: cs_set_user_model — place for call
 
I have strange problem with models set and userinfo O_O. My code:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "Admin Models"
#define VERSION "1.0"
#define AUTHOR "Phantomas"

public plugin_precache()
{
    
precache_model("models/player/leet_sp/leet_sp.mdl")
    
precache_model("models/player/gsg9_sp/gsg9_sp.mdl")
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_forward(FM_SetClientKeyValue"SetClientKeyValue")
}

public 
set_model(const id, const szSetModel[])
{
    new 
szModel[16]
    
get_user_info(id"model"szModelcharsmax(szModel))
    if(!
equal(szModelszSetModel))
    {
        
set_user_info(id"model"szSetModel)
    }
    return 
FMRES_SUPERCEDE
}

public 
SetClientKeyValue(const id, const szInfoBuffer[], const szKey[], const szValue[])
{
    if(
equal(szKey"model"))
    {    
        if(
equal(szValue"arctic") || equal(szValue"guerilla") || equal(szValue"leet") || equal(szValue"terror"))
        {
            new 
ns[2]
            
get_user_info(id"sp_model"ns1)
            if(!
equali(ns"0"))
            {
                new 
flags get_user_flags(id)
                if(
flags ADMIN_KICK)
                {
                    return 
set_model(id"leet_sp")
                }            
            }
        }
        
        if(
equal(szValue"gign") || equal(szValue"gsg9") || equal(szValue"sas") || equal(szValue"urban"))
        {
            new 
ns[2]
            
get_user_info(id"sp_model"ns1)
            if(!
equali(ns"0"))
            {
                new 
flags get_user_flags(id)
                if(
flags ADMIN_KICK)
                {
                    return 
set_model(id"gsg9_sp")
                }
            }
        }
    }
    return 
FMRES_IGNORED


It's set gsg9_sp or leet_sp model for admins.
But, I want add disable feature. If ADMIN does not want to use custom (_sp) model, then he write:
Code:

setinfo "sp_model" "0"
It's works at first sight, but:
If admin connect to server without "sp_model" setinfo, join in team, got your custom _sp model (it's okay). And if he alive and he write "sp_model" "0" setinfo right now, then model of admin be changed to default selected (realtime)! Why? How to fix it?

ConnorMcLeod 12-07-2013 13:41

Re: cs_set_user_model — place for call
 
When a player writes setinfo FIELD VALUE in console, that info is set on engine client, and if the field is new, or if the value has changed, ClientInfoChanged is sent to DLL (engine calls cs function).
In ClientInfoChanged code, cs checks player model and tries to set it back to default values is model doesn't match default values.

What you could do is on client_infochanged, check for sp_model info, and don't use that value untill new round / next spawn

Phant 12-07-2013 20:13

Re: cs_set_user_model — place for call
 
ConnorMcLeod, thanks you very much.


All times are GMT -4. The time now is 23:20.

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