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

CSGO console command to chat command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dariush
Junior Member
Join Date: Jan 2017
Old 01-19-2017 , 01:10   CSGO console command to chat command
Reply With Quote #1

hi,
i want code for making console commands into chat command

for example:

Console command: exec warmup.cfg
Chat command: !warmup

or

Console command: exec live.cfg
Chat command: !live


just admins can use that commands,

how can i add that in my server?

thanks
Dariush is offline
stay.pista
Senior Member
Join Date: Apr 2013
Location: Hungary
Old 01-19-2017 , 01:33   Re: CSGO console command to chat command
Reply With Quote #2

Very simple
E.g.
PHP Code:
public OnPluginStart(){

RegConsoleCmd("sm_live"Command_live);


PHP Code:
public Action:Command_live(client,args){

ServerCommand("exec live.cfg")



if do you want this only for admins, make a array in postadmincheck and write the condition before servercommand.
__________________


•suяƒ• Since 2008
stay.pista is offline
Dariush
Junior Member
Join Date: Jan 2017
Old 01-19-2017 , 02:04   Re: CSGO console command to chat command
Reply With Quote #3

thanks,

but i don't know how to use that, if that a plugin, can you make it for me?
Dariush is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 01-20-2017 , 09:26   Re: CSGO console command to chat command
Reply With Quote #4

here you go
PHP Code:
#include <sourcemod>
#define CFGLive "live.cfg"
#define CFGWarm "warmup.cfg"
public OnPluginStart()
{
    
RegAdminCmd("sm_live"Command_liveADMFLAG_ROOT);
    
RegAdminCmd("sm_warmup"Command_warmupADMFLAG_ROOT);
}
public 
Action Command_live(int clientint args)
{
    
ServerCommand("exec %s"CFGLive);
}
public 
Action Command_warmup(int clientint args)
{
    
ServerCommand("exec %s"CFGWarm);

Attached Files
File Type: sp Get Plugin or Get Source (warm.sp - 564 views - 410 Bytes)

Last edited by ambn; 01-20-2017 at 09:59.
ambn is offline
stay.pista
Senior Member
Join Date: Apr 2013
Location: Hungary
Old 01-20-2017 , 12:45   Re: CSGO console command to chat command
Reply With Quote #5

sexy
__________________


•suяƒ• Since 2008
stay.pista is offline
Dariush
Junior Member
Join Date: Jan 2017
Old 01-21-2017 , 00:19   Re: CSGO console command to chat command
Reply With Quote #6

thanks, work fine,

if i want add more command, for example
!r1 for restart game --> sm_cvar mp_restartgame 1

PHP Code:
#include <sourcemod>
#define CFGLive "live.cfg"
#define CFGWarm "warmup.cfg"
#define Restart "sm_cvar mp_restartgame 1"
public OnPluginStart()
{
    
RegAdminCmd("sm_live"Command_liveADMFLAG_ROOT);
    
RegAdminCmd("sm_warmup"Command_warmupADMFLAG_ROOT);
    
RegAdminCmd("sm_r1"Command_r1ADMFLAG_ROOT);
}
public 
Action Command_live(int clientint args)
{
    
ServerCommand("exec %s"CFGLive);
}
public 
Action Command_warmup(int clientint args)
{
    
ServerCommand("exec %s"CFGWarm);
}  
public 
Action Command_r1(int client,int args)
{
   
ServerCommand("r1 %s"Restart);

Its correct for r1? ? or i'm wrong?

Last edited by Dariush; 01-21-2017 at 00:19.
Dariush is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 01-21-2017 , 02:47   Re: CSGO console command to chat command
Reply With Quote #7

Quote:
Originally Posted by Dariush View Post
-snip-
I made a more dynamic way of doing the executed configuration files, that way all you have to do is add a cfg file name into the array at the top and increment the define value.

Also added
Code:
sm_r <delay>
so you can type !r 1

Plugin



EDIT: Moved to plugin requests since this post belongs here

Last edited by headline; 01-21-2017 at 03:22.
headline 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 00:52.


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