Raised This Month: $32 Target: $400
 8% 

Plugin to execute HLTV recording?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blood2k
Senior Member
Join Date: Mar 2014
Old 11-17-2019 , 14:21   Plugin to execute HLTV recording?
Reply With Quote #1

Hey all,

Can some1 help create this? I can pay you if you want.

Just need a plugin with 2 commands. amx_hltvrecord and amx_hltvstoprecord

This will be something admins can call on to get the HLTV that's connected to start recording and stop recording.


& then also just a cvar to specify where the demos are being saved within the cstrike folder.



P.S I can't execute HLTV recording via RCON because I don't run the HLTV off the same box or the same IP. So the rcon record <demoname> command will not work here by our admins (Plus I don't want to give everyone rcon)


Last edited by blood2k; 11-17-2019 at 15:19.
blood2k is offline
blood2k
Senior Member
Join Date: Mar 2014
Old 11-17-2019 , 15:19   Re: Plugin to execute HLTV recording?
Reply With Quote #2

Didn't mean to double post, thought I hit "EDIT" on the previous comment not quote.

Last edited by blood2k; 11-17-2019 at 15:20.
blood2k is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 11-18-2019 , 03:13   Re: Plugin to execute HLTV recording?
Reply With Quote #3

Why dont you use auto demo recorder? You wont need any command, or admin online
https://forums.alliedmods.net/showthread.php?p=770786
ZaX is offline
blood2k
Senior Member
Join Date: Mar 2014
Old 11-18-2019 , 13:35   Re: Plugin to execute HLTV recording?
Reply With Quote #4

Hi,

Yes I've checked that one out when searching for my plugin. But I specifically would like it to record only when we execute it and stop when we want it too. Auto recording based on player count won't be needed.
blood2k is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 11-18-2019 , 14:57   Re: Plugin to execute HLTV recording?
Reply With Quote #5

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <sockets>

new g_Socket;
new 
g_Forward;
new 
g_Args[192];
new 
g_Password[32];

new 
g_This;
new 
g_Host;
new 
g_Pass;
new 
g_Folder;
new 
g_Name;

public 
plugin_init()
{
    
register_plugin("Amx Mod (HLTV)","0.0.1","SmileY");
    
    
g_This get_cvar_pointer("net_address");
    
    
g_Host create_cvar("amx_hltv_host","192.168.237.1:27020",FCVAR_NONE,"Remote HLTV address");    
    
g_Pass create_cvar("amx_hltv_pass","2133",FCVAR_PROTECTED,"Remote HLTV rcon password");
    
    
g_Folder create_cvar("amx_hltv_demo_folder","demos",FCVAR_NONE,"Demo folder inside HLTV");
    
g_Name create_cvar("amx_hltv_demo_name","record",FCVAR_NONE,"Default demo name");
    
    
register_concmd("amx_hltv","RunCommand",ADMIN_RCON,"amx_hltv <record|stop> - Start or Stop a demo recording from remote HLTV");
}

public 
RunCommand(id,level,cid)
{
    if(!
cmd_access(id,level,cid,2))
    {
        return 
PLUGIN_HANDLED;
    }
    
    new 
Command[8];
    
read_args(Command,charsmax(Command));
    
remove_quotes(Command);
    
    if(
Command[0] == 'r')
    {
        new 
This[MAX_IP_WITH_PORT_LENGTH];
        
get_pcvar_string(g_This,This,charsmax(This));
        
        new 
Folder[MAX_NAME_LENGTH];
        
get_pcvar_string(g_Folder,Folder,charsmax(Folder));
        
        new 
Name[MAX_NAME_LENGTH];
        
get_pcvar_string(g_Name,Name,charsmax(Name));
        
        
RconCommand("connect %s;record %s/%s",This,Folder,Name);
    }
    else
    {
        
RconCommand("stop");
    }
    
    return 
PLUGIN_HANDLED;
}

stock RconCommand(const Command[],any:...)
{
    if(
g_Socket == 0)
    {
        new 
Host[MAX_IP_WITH_PORT_LENGTH];
        
get_pcvar_string(g_Host,Host,charsmax(Host));
        
        
get_pcvar_string(g_Pass,g_Password,charsmax(g_Password));
        
        new 
IP[MAX_IP_LENGTH],Port[6];
        
strtok(Host,IP,charsmax(IP),Port,charsmax(Port),':');  
        
        if(
IP[0] && Port[0] && g_Password[0])
        {
            new 
Error;
            
g_Socket socket_open(IP,str_to_num(Port),SOCKET_UDP,Error,SOCK_NON_BLOCKING);
            
            if(
Error == SOCK_ERROR_OK)
            {
                
vformat(g_Args,charsmax(g_Args),Command,2);
                
                new 
Data[32];
                
formatex(Data,sizeof(Data),"%c%c%c%cchallenge rcon",0xFF,0xFF,0xFF,0xFF);
                
                if(
socket_send2(g_Socket,Data,charsmax(Data)) != -1)
                {
                    
g_Forward register_forward(FM_StartFrame,"OnSocketRecv");
                }
            }
            else
            {
                
socket_close(g_Socket);
                
g_Socket 0;
            }
        }
    }
}  

public 
OnSocketRecv()
{
    if(
socket_is_readable(g_Socket,0))
    {
        new 
Data[128];
        
        if(
socket_recv(g_Socket,Data,charsmax(Data)) > 0)
        {
            new 
Rcon[32],None[64];
            
parse(Data,None,charsmax(None),None,charsmax(None),Rcon,charsmax(Rcon));    
            
            
formatex(Data,charsmax(Data),"%c%c%c%crcon %s ^"%s^" %s",0xFF,0xFF,0xFF,0xFF,Rcon,g_Password,g_Args);            
            
            
socket_send2(g_Socket,Data,charsmax(Data));            
            
            if(
socket_close(g_Socket))
            {
                
g_Socket 0;
                
unregister_forward(FM_StartFrame,g_Forward);
            }
        }
    }

I did not coded command part itself, but i think you got the main idea.

Ps. Using sockets, wait more some minutes to get command working!

Edit: Done.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 11-18-2019 at 15:11.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
blood2k
Senior Member
Join Date: Mar 2014
Old 11-19-2019 , 23:55   Re: Plugin to execute HLTV recording?
Reply With Quote #6

Smiley that's perfect. Do you know if it can save demos with appended random numbers at the end? So it doesn't overwrite previously recorded demos?
blood2k is offline
Mankled
Senior Member
Join Date: Oct 2019
Old 11-20-2019 , 02:58   Re: Plugin to execute HLTV recording?
Reply With Quote #7

talking about demos, can someone put this one to save by date, like this, the file name will be the date when recorded. EX: MYDEMO_11-20-19.dem

PHP Code:
#include <amxmodx>

public plugin_init() 
{
    
register_plugin("Demo Recorder","1.0","")
}

public 
client_putinserver(id)
{
    
set_task(7.0"cmdRec"id)
}

public 
client_disconnected(id)
{
    
client_cmd(id,"stop")
}

public 
cmdRec(id)
{
    if(
is_user_connected(id))
    { 
// is user not disconnected in 7secs?
        
client_cmd(id"stop; record MYDEMO")
    }


Last edited by Mankled; 11-20-2019 at 02:58.
Mankled is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 11-20-2019 , 06:42   Re: Plugin to execute HLTV recording?
Reply With Quote #8

Demos are saved with date correctly at HLTV, do not need to edit. Only edit demo name.
It will be saved like in name-1101290037-de_inferno.dem

@Mankled

Check format_time function for manually create date and times string and place in client_cmd with your command. Or just:

PHP Code:
client_cmd(id"stop; record demo-%i",get_systime()); 
It will save a demo using time elapsed in seconds since 1970
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 11-20-2019 at 06:45.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 23:31.


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