AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   block key 'model' & used it for other case ? (https://forums.alliedmods.net/showthread.php?t=295864)

abdobiskra 04-06-2017 15:34

block key 'model' & used it for other case ?
 
Hi guys
i want block key 'model' for clients and i want used it for othere function change model :
what i try :
PHP Code:

public plugin_init() {
    
    
register_forward(FM_SetClientKeyValue"SetClientKeyValue");
}

new 
changes[32

public 
client_putinserver(id)
{
    
changes[id] = 0;
    
}

public 
SetClientKeyValue(player, const szInfoBuffer[], const szKey[], const szValue[])
{
    if(
equal(szKey"model") && is_user_connected(player) && !equal(g_asModels[player], ""))
    {

        if(
changes[player] >= )
        {
            
client_print(playerprint_chat" ====== Stop  change model ======= ")
            return 
FMRES_IGNORED
        
}
        
client_print(playerprint_chat" ====== Auto  change model ======= ")
        
        
changes[player]++
        
        return 
FMRES_SUPERCEDE

    
}
    return 
FMRES_IGNORED


but the clients still can used this cmd ? is there othere way pleas !

EFFx 04-06-2017 17:17

Re: block key 'model' & used it for other case ?
 
In if(changes[player] >= 1 ) check you should return FMRES_SUPERCEDE and where have FMRES_SUPERCEDE you should change toFMRES_IGNORED

edon1337 04-06-2017 17:51

Re: block key 'model' & used it for other case ?
 
I think FM_SetClientKeyValue is fired after the command is executed so you can't just block it with returns, you need to restore model ( set_user_info() ) .

EFFx 04-06-2017 18:13

Re: block key 'model' & used it for other case ?
 
If is pre or post I do not know, but it can be blocked.

gabuch2 04-07-2017 08:00

Re: block key 'model' & used it for other case ?
 
edon is right, setinfo hooks are always fired after the user changes them. The best way to block a model change is to store the model when the player joins, then re-apply if it changes.

EFFx 04-07-2017 13:05

Re: block key 'model' & used it for other case ?
 
I'm using as I said on my furien and it works.

abdobiskra 04-07-2017 14:51

Re: block key 'model' & used it for other case ?
 
i do pre & post
i do set_user_info()

but why when i want to cheack my name of model i see othere name but model not changed like what i saw in consol

my model name is 'sas'
but when i try consol cmd :
Quote:

] model
"model" is "red"
] model blue
====== Stop change model =======
] model
"model" is "blue"
PHP Code:

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_forward(FM_SetClientKeyValue"SetClientKeyValue"1);
    
    
// Add your code here...
}
public 
SetClientKeyValue(player, const szInfoBuffer[], const szKey[], const szValue[])
{
    new 
sCurModel[32], PlayerChoice[32];
        
    
//hl_get_user_model(player, sCurModel, charsmax(sCurModel));
    
get_user_info(player"model"sCurModel31);
        

    if(
equal(szKey"model") && is_user_connected(player) && !equal(g_asModels[player], ""))
    {
        if(
changes[player] >= )
        {
            
//hl_set_user_model(player, PlayerChoice[player]);
            
client_print(playerprint_chat" ====== Stop  change model ======= ")
            
set_user_info(player"model"PlayerChoice[player]) 
            
//return FMRES_IGNORED
            
return FMRES_HANDLED
        
}
        
client_print(playerprint_chat" ====== Auto  change model ======= ")
        
changes[player]++
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED


btw my function what i want use for change model without killing in team ( in HL Game dll restricts models for teams)

PRoSToTeM@ 04-07-2017 16:41

Re: block key 'model' & used it for other case ?
 
You can't change client-side model value. You should check your real model with some third person view plugin.

edon1337 04-07-2017 17:46

Re: block key 'model' & used it for other case ?
 
Try this
Code:
public plugin_init( ) {     register_plugin( PLUGIN, VERSION, AUTHOR ) ;     register_forward( FM_SetClientKeyValue, "SetClientKeyValue", 1 ) ; } public SetClientKeyValue( player, const szInfoBuffer[ ], const szKey ], const szValue[ ] ) {     new sCurModel[ 32 ], PlayerChoice[ 32 ];         get_user_info( player, "model", sCurModel, charsmax( sCurModel ) );         if( equal( szKey, "model" ) && is_user_connected( player ) && !g_asModels[ 0 ] )     {         if( changes[ player ] >= 1 )         {             client_print( player, print_chat, " ====== Stop  change model ======= " ) ;             set_user_info( player, "model", PlayerChoice[ player ] ) ;                         return FMRES_SUPERCEDE ;         }                 client_print( player, print_chat, " ====== Auto  change model ======= " ) ;         changes[ player ] ++                 return FMRES_SUPERCEDE ;     }         return FMRES_IGNORED ; }

What are
Code:
sCurModel[ 32 ], PlayerChoice[ 32 ];
For ?

abdobiskra 04-08-2017 04:14

Re: block key 'model' & used it for other case ?
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2510181)
You can't change client-side model value. You should check your real model with some third person view plugin.

i want block it can i do that ? .. yes im yes 3D view to chack model

edon1337
you code is wrong i mean here
&& !g_asModels[ 0 ] )
this arry should be index

and this full code :

PHP Code:

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

#define PLUGIN   "Test"
#define AUTHOR   "LetiLetiLepestok"
#define VERSION   "1.0"

#define RANDOMSKINS 3

new const Set_ClassesRANDOMSKINS][] =
{
    
"blue",
    
"red",
    
"helmet"
}
new 
g_asModels[33][32]

public 
plugin_init()
{
   
register_plugin(PLUGINVERSIONAUTHOR)
   
register_forward(FM_SetClientKeyValue"SetClientKeyValue"0);
   
register_clcmd("set_model""set_player_mdl")
   
register_clcmd("say ss""set_views")
   
register_clcmd("say gg""set_test")
}


public 
set_views(id)
   
set_view(idCAMERA_3RDPERSON)  // i use this to see if my skin is changed :)

   
   
public set_test(id)
   
client_cmd(id"set_model %s"Set_Classes[random(RANDOMSKINS)])
   
   
public 
set_player_mdl(player)
{
    new 
sModel[32]
    
read_argv(1sModelcharsmax(sModel))
    
    
trim(sModel)
    
remove_quotes(sModel)
    if(
equal(sModel""))
    
g_asModels[player] = ""
    
g_asModels[player] = sModel
    
    set_user_info
(player"model"g_asModels[player])   
    return 
PLUGIN_HANDLED
}

public 
SetClientKeyValue(player, const szInfoBuffer[], const szKey[], const szValue[])
{
    new 
sCurModel[32], PlayerChoice[32];
        
    
//hl_get_user_model(player, sCurModel, charsmax(sCurModel));
    
get_user_info(player"model"sCurModel31);
        

    if(
equal(szKey"model") && is_user_connected(player) && !equal(g_asModels[player], ""))
    {
        
        new 
name[32]//, model[32];
        
        
get_user_name(playername31);
        
//get_user_info(id, "model", model, 31);
        
log_amx("check model %s %s"namesCurModel);

        if(
changes[player] > || equali(sCurModel[player], PlayerChoice) && equali(sCurModel[player], name) )
        {
            
//hl_set_user_model(player, PlayerChoice[player]);
            
client_print(playerprint_chat" ====== Stop  change model ======= ")
            
set_user_info(player"model"PlayerChoice[player]) 
            
//return FMRES_IGNORED
            
return FMRES_HANDLED
        
}
        
client_print(playerprint_chat" ====== Auto  change model ======= ")
        
changes[player]++
        return 
FMRES_SUPERCEDE
        
    
}
    return 
FMRES_IGNORED




All times are GMT -4. The time now is 17:48.

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