Raised This Month: $ Target: $400
 0% 

Execute cfg via chat


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fjlep
Junior Member
Join Date: Apr 2024
Old 04-12-2024 , 20:41   Execute cfg via chat
Reply With Quote #1

Some time ago I found a plugin that the function was to execute cfg using the say, for example to execute lo3.cfg I wrote in the chat lo3 and the configuration was loaded, but I don't remember where I saw it, I hope you can help me.
fjlep is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-17-2024 , 09:47   Re: Execute cfg via chat
Reply With Quote #2

you can do amx_rcon exec lo3.cfg
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
tedaimlocks
Senior Member
Join Date: Jan 2024
Old 04-17-2024 , 10:08   Re: Execute cfg via chat
Reply With Quote #3

Quote:
Originally Posted by fjlep View Post
Some time ago I found a plugin that the function was to execute cfg using the say, for example to execute lo3.cfg I wrote in the chat lo3 and the configuration was loaded, but I don't remember where I saw it, I hope you can help me.
this should work, i guess


HTML Code:
#include <amxmodx>

#define PLUGIN "CFG Via Chat"
#define VERSION "1.0"
#define AUTHOR "tedaimlocks"

#define FLAG ADMIN_CFG

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_clcmd("say /lo3", "cfg")
	register_clcmd("say_team /lo3", "cfg")
}

public cfg() {
        if(!get_user_flags(id) & FLAG) {
            return PLUGIN_HANDLED;
        }
	server_cmd("exec lo3.cfg");
}

Last edited by tedaimlocks; 04-21-2024 at 05:08.
tedaimlocks is offline
fjlep
Junior Member
Join Date: Apr 2024
Old 04-20-2024 , 23:02   Re: Execute cfg via chat
Reply With Quote #4

Quote:
Originally Posted by tedaimlocks View Post
this should work, i guess


HTML Code:
#include <amxmodx>

#define PLUGIN "CFG Via Chat"
#define VERSION "1.0"
#define AUTHOR "tedaimlocks"


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_clcmd("say /lo3", "cfg")
	register_clcmd("say_team /lo3", "cfg")
}

public cfg() {
	server_cmd("exec lo3.cfg");
}
It works! How do I add more cfg's to the same plugin?
fjlep is offline
fjlep
Junior Member
Join Date: Apr 2024
Old 04-20-2024 , 23:07   Re: Execute cfg via chat
Reply With Quote #5

Quote:
Originally Posted by georgik57 View Post
you can do amx_rcon exec lo3.cfg
I want to avoid using the console, I like to use the "say .lo3" =D
fjlep is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-20-2024 , 23:25   Re: Execute cfg via chat
Reply With Quote #6

Quote:
Originally Posted by fjlep View Post
I want to avoid using the console, I like to use the "say .lo3" =D
Add your config files to the array, excluding the ".cfg" extension. Do you want to limit who can execute config files to admins only?

This will support saying /lo3 or .lo3
PHP Code:
#include <amxmodx>

new const Version[] = "0.1";

new const 
configs[][] = 
{
    
"lo3",
    
"lo4",
    
"lo5"
};

public 
plugin_init() 
{
    
register_plugin"Say Exec Config" Version "bugsy" );
    
    
register_clcmd"say" "SayHook" );
    
register_clcmd"say_team" "SayHook" ); 
}

public 
SayHook() 
{
    new 
szArg];
    
    
read_argvszArg charsmaxszArg ) );
    
    for ( new 
sizeofconfigs ) ; i++ )
    {
        if ( 
equalszArg] , configs] ) )
        {
            
server_cmd"exec %s.cfg" szArg] );
            break;
        }
    }

__________________

Last edited by Bugsy; 04-21-2024 at 19:50.
Bugsy is offline
fjlep
Junior Member
Join Date: Apr 2024
Old 04-21-2024 , 18:12   Re: Execute cfg via chat
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
Add your config files to the array, excluding the ".cfg" extension. Do you want to limit who can execute config files to admins only?

This will support saying /lo3 or .lo3
PHP Code:
#include <amxmodx>

new const Version[] = "0.1";

new const 
configs[][] = 
{
    
"lo3",
    
"lo4",
    
"lo5"
};

public 
plugin_init() 
{
    
register_plugin"Say Exec Config" Version "bugsy" );
    
    
register_clcmd"say" "SayHook" );
    
register_clcmd"say_team" "SayHook" ); 
}

public 
SayHook() 
{
    new 
szArg];
    
    
read_argvszArg charsmaxszArg ) );
    
    for ( new 
sizeofconfigs ) ; i++ )
    {
        if ( 
equalszArg] , configs] ) )
        {
            
server_cmd"exec %s.cfg" szArg );
            break;
        }
    }

When I type .lo3 in chat in console I get this "couldn't exec .lo3.cfg" I have the files in /cstrike/, if I type /lo3 I get this exec /lo3.cfg: invalid path and I would like admin's only to be able to use this option.

Last edited by fjlep; 04-21-2024 at 18:35.
fjlep is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-21-2024 , 19:46   Re: Execute cfg via chat
Reply With Quote #8

That's because it's currently passing the whole chat argument through to the command line. You need to remove the first character in the same way that it was done for the comparison. I.e. add the indexing of the szArg array in the server_cmd() function like this:

Code:
server_cmd( "exec %s.cfg" , szArg[1] );
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-21-2024 , 19:51   Re: Execute cfg via chat
Reply With Quote #9

Ah, my bad.

As fysiks said, you can do:
server_cmd( "exec %s.cfg" , szArg[ 1 ] );
or
server_cmd( "exec %s.cfg" , configs[ i ] );
both will do the exact same thing.
__________________
Bugsy is offline
fjlep
Junior Member
Join Date: Apr 2024
Old 04-23-2024 , 21:02   Re: Execute cfg via chat
Reply With Quote #10

Bugsy and fysiks Thanks for your help!
fjlep is offline
Reply


Thread Tools
Display Modes

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 08:34.


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