Raised This Month: $51 Target: $400
 12% 

blocking console model changes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
brN17
Junior Member
Join Date: Mar 2022
Old 03-19-2022 , 14:41   blocking console model changes
Reply With Quote #1

So I got a code here in this section, which makes player console model back to It's previous when user tries to change It from console, example, If a player tries to use "model any_custom_model" on console and his model originally were, for example, GIGN, so It'll keep GIGN, I couldn't compile It at first but after some "modifications" I got able to

code I found
Code:
#include < amxmodx >
#include < cstrike >
#include < fakemeta >

public plugin_init()
    register_forward(FM_SetClientKeyValue, "cmdSetClientKeyValue");
    
public cmdSetClientKeyValue(id, const infobuffer[], const key[])
{
    if(equal(key, "model"))
    {
        new sCurModel[32];
        cs_get_user_model(id, sCurModel, charsmax(sCurModel));
        
        if(!equal(sCurModel, PlayerChoice[id]))
            cs_set_user_model(id, PlayerChoice[id]);
            
        return FMRES_SUPERCEDE;
    }
        
    return FMRES_IGNORED;
}
how I managed It to be compiled

Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>

public plugin_init()
{
    register_forward(FM_SetClientKeyValue, "cmdSetClientKeyValue");
}
	
public cmdSetClientKeyValue(id, const infobuffer[], const key[])
{
    if(equal(key, "model"))
    {
		new PlayerChoice[32]
		new sCurModel[32];
		cs_get_user_model(id, sCurModel, charsmax(sCurModel));
        
		if(!equal(sCurModel, PlayerChoice[id]))
			cs_set_user_model(id, PlayerChoice[id])
		return FMRES_SUPERCEDE;
    }    
    return FMRES_IGNORED;
}
my player skins menu

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Player Model Menu"
#define VERSION "1.0"
#define AUTHOR "redemptioN-"

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("say /skins", "model_menu")
}

public plugin_precache() 
{
	precache_model("models/player/model1/model1.mdl")
	precache_model("models/player/model2/model2.mdl")
}

public model_menu(id)
{
	new menu = menu_create("[\wPlayer Models]", "menu_action")
    
	menu_additem(menu, "\wRemove Skins", "1", 0)
	menu_additem(menu, "\wModel1", "2", 0)
	menu_additem(menu, "\wModel2", "3", 0)
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
	menu_display(id, menu, 0)
}

public menu_action(id, menu, item)
{
    if (item == MENU_EXIT)
    {
		menu_destroy(menu)
		return PLUGIN_HANDLED
    }
    new data[6], iName[64]
    new acces, callback

    menu_item_getinfo(menu, item, acces, data, 5, iName, 63, callback)
    
    new key = str_to_num(data)
    
    switch(key)
		{ 
			case 1 : cs_set_user_model(id, "")
			case 2 : cs_set_user_model(id, "model1")
			case 3 : cs_set_user_model(id, "model2")
		}
    menu_destroy(menu)
    return PLUGIN_HANDLED
}
The plugin seems to be working, but when I use my player skins model menu to change skins, It stops blocking console model's change and I can use any model on console again, can someone try to fix and post the code please?

OBS: I need to fix It 'cause I only want players to use available players model, making them unable to reach future VIP or Admin menu player models that I'm planning to put in, and even prevent abuse from using other team models.

Last edited by brN17; 03-19-2022 at 14:42.
brN17 is offline
Dyaus
Member
Join Date: Aug 2021
Old 03-19-2022 , 14:57   Re: blocking console model changes
Reply With Quote #2

i'm a newbie so don't take this advice to heart , but in my opinion if they're smart enough to input "model custom_model" then they're smart enough to realise that they shouldn't do it if they get punished for it like kixked/banned for 10 mins ... etc

so instead of trying to stop the command itself , i think detecting whoever input the cmd in console and punishsing them would be more efficient . idk really seems more efficient to me
Dyaus is offline
brN17
Junior Member
Join Date: Mar 2022
Old 03-19-2022 , 15:13   Re: blocking console model changes
Reply With Quote #3

I got you, but If It can be prevented automatically, so why not? It would be two things less to worry about. I want my VIP server buyers to have their exclusivity as VIP, as a VIP I think everyone'd get pissed with someone having VIP things for "free" since they had to pay for It, btw I'm starting a server alone for now, I won't have 24/7 to check If some player's using VIP model. Thank you for the suggestion btw mate
brN17 is offline
Dyaus
Member
Join Date: Aug 2021
Old 03-19-2022 , 16:16   Re: blocking console model changes
Reply With Quote #4

Quote:
Originally Posted by brN17 View Post
I got you, but If It can be prevented automatically, so why not? It would be two things less to worry about. I want my VIP server buyers to have their exclusivity as VIP, as a VIP I think everyone'd get pissed with someone having VIP things for "free" since they had to pay for It, btw I'm starting a server alone for now, I won't have 24/7 to check If some player's using VIP model. Thank you for the suggestion btw mate
you won't have to check manually or survey anything 24/7 , i'm saying it's probably more efficient to write a plugin , that detects if a player inputs "model "sth"" in their console at any given moment whether there is an admin on server or not and punish them accodingly by banning them for a short duration ( which can be specified by a cvar) , instead of forcing another client_cmd() on the model on possibly crashing the server especially since the code is using cs_set_user_model()

for more context , cs_set_user_model() itself should try to shut down any attempt at changing model manually from client side according to amxmodx API
https://www.amxmodx.org/api/cstrike/cs_set_user_model if you try to override a cs_set_user_model() with another one server will crash
so i think you should test whether a player from client side is even capable of changing their model from console in the first place , if you don't have a testing partner this is my discord although i may not be of much help : Dyaus#6674
Dyaus is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 03-19-2022 , 19:58   Re: blocking console model changes
Reply With Quote #5

Use rg_set_user_model

Already fix this
baneado 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:08.


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