Raised This Month: $ Target: $400
 0% 

block key 'model' & used it for other case ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 04-06-2017 , 15:34   block key 'model' & used it for other case ?
Reply With Quote #1

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 !
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 04-06-2017 , 17:17   Re: block key 'model' & used it for other case ?
Reply With Quote #2

In if(changes[player] >= 1 ) check you should return FMRES_SUPERCEDE and where have FMRES_SUPERCEDE you should change toFMRES_IGNORED
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 04-06-2017 at 17:19.
EFFx is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 04-06-2017 , 17:51   Re: block key 'model' & used it for other case ?
Reply With Quote #3

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() ) .
__________________
edon1337 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 04-06-2017 , 18:13   Re: block key 'model' & used it for other case ?
Reply With Quote #4

If is pre or post I do not know, but it can be blocked.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-07-2017 , 08:00   Re: block key 'model' & used it for other case ?
Reply With Quote #5

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.
__________________
gabuch2 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 04-07-2017 , 13:05   Re: block key 'model' & used it for other case ?
Reply With Quote #6

I'm using as I said on my furien and it works.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 04-07-2017 , 14:51   Re: block key 'model' & used it for other case ?
Reply With Quote #7

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)
__________________

Last edited by abdobiskra; 04-07-2017 at 15:08.
abdobiskra is offline
Send a message via Skype™ to abdobiskra
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 04-07-2017 , 16:41   Re: block key 'model' & used it for other case ?
Reply With Quote #8

You can't change client-side model value. You should check your real model with some third person view plugin.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 04-08-2017 , 04:14   Re: block key 'model' & used it for other case ?
Reply With Quote #9

Quote:
Originally Posted by PRoSToTeM@ View Post
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

__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 04-08-2017 , 06:18   Re: block key 'model' & used it for other case ?
Reply With Quote #10

Quote:
Originally Posted by abdobiskra View Post
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

I don't see how this makes sense.
Code:
!equal(g_asModels[player], "")

It's checking if string is empty, right?
__________________
edon1337 is offline
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 17:48.


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