Raised This Month: $ Target: $400
 0% 

hltv auto recorder


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Egan
BANNED
Join Date: May 2013
Location: GB
Old 05-13-2013 , 10:59   hltv auto recorder
Reply With Quote #1

Code:
#include <amxmodx>
#include  <amxmisc>
#include  <sockets>
 
#pragma  semicolon 1
 
new g_HLTV[] = "[HLTV]";
 
new g_Address;
new p_Host,p_Port,p_Pass;
 
public plugin_init()
{
    register_plugin("Auto Recoder",AMXX_VERSION_STR,"EganZ");
   
    g_Address     = get_cvar_pointer("net_address");
   
    p_Host         = register_cvar("hltv_host","74.91.115.250",FCVAR_PROTECTED);
    p_Port         = register_cvar("hltv_port","27020",FCVAR_PROTECTED);
    p_Pass         = register_cvar("hltv_pass","61p2o",FCVAR_PROTECTED);
   
    register_concmd("hltv_rcon","HLTV_Rcon",ADMIN_RCON,"<Command>");
    register_concmd("hltv_record","HLTV_Record",ADMIN_RCON,"<File>");
    register_concmd("hltv_stop","HLTV_Stop",ADMIN_RCON,"- Removes the HLTV from server");
}
 
public HLTV_Rcon(id,level,cid)
{
    if(!cmd_access(id,level,cid,2)) return PLUGIN_HANDLED;
   
    new szHost[32],szPass[32];
    get_pcvar_string(p_Host,szHost,charsmax(szHost));
    get_pcvar_string(p_Pass,szPass,charsmax(szPass));
   
    new szCommand[128];
    read_args(szCommand,charsmax(szCommand));
    remove_quotes(szCommand);
   
    Rcon_Command(szHost,get_pcvar_num(p_Port),szPass,szCommand);
   
    return PLUGIN_HANDLED;
}
 
public HLTV_Record(id,level,cid)
{
    if(!cmd_access(id,level,cid,2)) return PLUGIN_HANDLED;
   
    new szHost[32],szPass[32];
    get_pcvar_string(p_Host,szHost,charsmax(szHost));
    get_pcvar_string(p_Pass,szPass,charsmax(szPass));
   
    new szFile[32];
    read_args(szFile,charsmax(szFile));
    remove_quotes(szFile);
   
    new szAddress[32];
    get_pcvar_string(g_Address,szAddress,charsmax(szAddress));
 
    new szCommand[128];
    formatex(szCommand,charsmax(szCommand),"connect %s;record %s;autoretry 1",szAddress,szFile);
   
    Rcon_Command(szHost,get_pcvar_num(p_Port),szPass,szCommand);
   
    console_print(id,"%s Trying to connect in ^"%s^" (And recording in the file ^"%s^")",g_HLTV,szAddress,szFile);
   
    return PLUGIN_HANDLED;
}
 
public HLTV_Stop(id,level,cid)
{
    if(!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED;
   
    new szHost[32],szPass[32];
    get_pcvar_string(p_Host,szHost,charsmax(szHost));
    get_pcvar_string(p_Pass,szPass,charsmax(szPass));
   
    Rcon_Command(szHost,get_pcvar_num(p_Port),szPass,"stop;disconnect;autoretry 0");
   
    console_print(id,"%s O HLTV Disconnected!",g_HLTV);
 
    return PLUGIN_HANDLED;
}
 
stock Rcon_Command(const szHost[],iPort,const szPass[],const szCommand[])
{
    new iError;
    new iSocket = socket_open(szHost,iPort,SOCKET_UDP,iError);
   
    switch(iError)
    {
        case 1:
        {
            socket_close(iSocket);
            server_print("* Error on creating the socket.");
           
            return PLUGIN_HANDLED;
        }
        case 2:
        {
            socket_close(iSocket);
            server_print("* Error on resolve the given hostname.");
           
            return PLUGIN_HANDLED;
        }
        case 3:
        {
            socket_close(iSocket);
            server_print("* Error on connecting.");
 
            return PLUGIN_HANDLED;
        }
    }
   
    new iSend[256],szCmd[256],szRcon[32],szNone[64];
   
    formatex(iSend,sizeof(iSend),"%c%c%c%cchallenge rcon",255,255,255,255);
    socket_send2(iSocket,iSend,charsmax(iSend));
   
    if(!socket_change(iSocket,2000000)) // If socket not change in 2 seconds, then stop it
    {
        socket_close(iSocket);
        server_print("* No response from %s:%d",szHost,iPort);
 
        return PLUGIN_HANDLED;
    }
    socket_recv(iSocket,szCmd,charsmax(szCmd));
    parse(szCmd,szNone,charsmax(szNone),szNone,charsmax(szNone),szRcon,charsmax(szRcon));
   
    formatex(szCmd,sizeof(szCmd),"%c%c%c%crcon %s ^"%s^" %s",255,255,255,255,szRcon,szPass,szCommand);
    socket_send2(iSocket,szCmd,charsmax(szCmd));
   
    if(socket_change(iSocket))
    {
        new szBuffer[2048];
        socket_recv(iSocket,szBuffer,charsmax(szBuffer));
 
        server_print(szBuffer);
    }
    socket_close(iSocket);
 
    return PLUGIN_HANDLED;
}
is their any room for improvement ?

Last edited by Egan; 05-14-2013 at 08:39.
Egan is offline
Send a message via ICQ to Egan Send a message via AIM to Egan Send a message via Yahoo to Egan Send a message via Skype™ to Egan
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-14-2013 , 04:02   Re: hello
Reply With Quote #2

Are you having issues with something?

Also, use a descriptive topic title, it's a rule (and common sense).
__________________
fysiks is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 05-14-2013 , 08:45   Re: hltv auto recorder
Reply With Quote #3

Post in original topic

Ps.
PHP Code:
register_plugin("Auto Recoder",AMXX_VERSION_STR,"EganZ"); 
to

PHP Code:
register_plugin("HLTV (Beta)",AMXX_VERSION_STR,"AMXX Dev Team"); 
Or we not just answer your questions
__________________
Projects:

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

Last edited by ^SmileY; 05-14-2013 at 08:52.
^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 16:24.


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