Raised This Month: $ Target: $400
 0% 

cs_set_user_model — place for call


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 11-17-2013 , 05:51   cs_set_user_model — place for call
Reply With Quote #1

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 is offline
Send a message via ICQ to Phant
Old 11-17-2013, 06:06
LordOfNothing
This message has been deleted by LordOfNothing. Reason: wrong
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 11-17-2013 , 06:19   Re: cs_set_user_model — place for call
Reply With Quote #3

Quote:
Originally Posted by LordOfNothing View Post
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.
Phant is offline
Send a message via ICQ to Phant
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-17-2013 , 06:20   Re: cs_set_user_model — place for call
Reply With Quote #4

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.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Old 11-17-2013, 06:20
LordOfNothing
This message has been deleted by LordOfNothing. Reason: i dont connor post , sorry :D
Bos93
Veteran Member
Join Date: Jul 2010
Old 11-17-2013 , 06:54   Re: cs_set_user_model — place for call
Reply With Quote #6

Patching strings in memory more efficient https://forums.alliedmods.net/showthread.php?t=117930
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-17-2013 , 06:57   Re: cs_set_user_model — place for call
Reply With Quote #7

Quote:
Originally Posted by Bos93 View Post
Patching strings in memory more efficient https://forums.alliedmods.net/showthread.php?t=117930
Not really, would be trivial for this.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 11-17-2013 , 08:34   Re: cs_set_user_model — place for call
Reply With Quote #8

ConnorMcLeod, thanks you very much! You're master .

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

Phant is offline
Send a message via ICQ to Phant
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-17-2013 , 08:43   Re: cs_set_user_model — place for call
Reply With Quote #9

supercede should be for the whole "sas" matching block.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 12-07-2013 , 10:02   Re: cs_set_user_model — place for call
Reply With Quote #10

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?
Phant is offline
Send a message via ICQ to Phant
Reply



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 23:20.


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