Raised This Month: $ Target: $400
 0% 

HLTV record/stop plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 05-05-2007 , 19:41   HLTV record/stop plugin
Reply With Quote #1

Hey Guys and Gals, I have not tested this plugin yet seeing that I just wrote it. It took ~40 minutes because I have never used sockets in my life before so I gave it a shot.

My Goal: When an admin calls either of the two functions, it will start/stop recording a demo on the connected HLTV server

Possible problems: Code (it compiles without any issues). Password - it may need some sort of password to check if it's allowed to connect...???

I noticed this type of plugin was never written as a standalone (as far as my searching abilities go) so I felt I could use it because I don't want my members to have full control of my HLTV server in case they stop the HLTV server :-).

Please let me know what I can do to fix it or do it and reply explaining it if necessary! Thank you!

PHP Code:
/* Plugin generated by AMXX-Studio 
Many thanks to DeviceNull's HLDS<->IRC to illustrate how to connect using sockets :-)
*/

#include <amxmodx>
#include <amxmisc>
#include <sockets>

#define PLUGIN "HLTV Remote Control (HLTVRC)"
#define VERSION "1.0"
#define AUTHOR "slmclarengt"

new hltv_hosthltv_porterrorhltv_sockethltv_record_start[64], hltv_record_stop[64]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("amx_hltv_record""cmdHltv_Record_Start"ADMIN_KICK"<name of demo> - Start Record Demo via HLTV")
    
register_clcmd("amx_hltv_stoprecord""cmdHltv_Record_Stop"ADMIN_KICK"Stops Recorded Demo via HLTV")
    
    
hltv_host register_cvar("hltv_host""127.0.0.1"// 127.0.0.1 = localhost
    
hltv_port register_cvar("hltv_port""27020"// 27020 = default HLTV port
}
public 
cmdHltv_Record_Start(idlevelcid)
{    
    new 
name_demo[32], server[32], port
    
if (!cmd_access(idlevelcid2)) // nuh uh uh - no touchy!
        
return PLUGIN_HANDLED;
    
read_argv(idname_demo31// read name inputted by user
    
    
if(equal(name_demo,"")) // No name specified
    
{
        
client_print(idprint_chat"[HLTV RECORD] You have not entered a valid name for the demo! Please try again.")
        
client_print(idprint_chat"[HLTV RECORD] Hint: Use the player's name and/or reason for recording")
        
client_print(idprint_chat"[HLTV RECORD] You need not include the map name or time as those are appended as is.")
        return 
PLUGIN_CONTINUE
    
}
    
    
get_pcvar_string(hltv_hostserver31// transfer to variables
    
port get_pcvar_num(hltv_port// transfer to variables
    
    
for(new 1<= get_playersnum(1); i++) // start including players/HLTV connecting
    
{
        static 
hltv_players
        
if (is_user_hltv(i))
        {
            
hltv_players++
        }
        if (
hltv_players == 0)
        {
            
client_print(idprint_chat"There are NO HLTVs connected or connecting to this server!")
            return 
PLUGIN_HANDLED
        
}            
    }
    
    
hltv_socket socket_open(server,port,SOCKET_TCP,error// from HLDS<->IRC (thanks devnull)
    
switch (error
    { 
        case 
1:    
        {
            
log_amx("[HLTV RECORD] Error creating socket to %s:%i",server,port)
            return -
1
        
}
        case 
2:    
        {
            
log_amx("[HLTV RECORD] Error resolving hostname %s",server)
            return -
2
        
}
        case 
3:    
        {
            
log_amx("[HLTV RECORD] Couldn't connect to %s:%i",server,port)
            return -
3
        
}
    }
    
format(hltv_record_start63"rcon record %s"name_demo// format start record command
    
socket_send(hltv_socket,hltv_record_start,0// send start command
    
    
client_print(idprint_chat"[HLTV RECORD] HLTV Recording successfully started - Check your HLTV folder for demo")
    
    return 
PLUGIN_CONTINUE
}
public 
cmdHltv_Record_Stop(idlevelcid)
{    
    new 
server[32], port
    
if (!cmd_access(idlevelcid2)) // nuh uh uh - no touchy!
        
return PLUGIN_HANDLED;
    
    
get_pcvar_string(hltv_hostserver31// transfer to variables
    
port get_pcvar_num(hltv_port// transfer to variables
    
    
for(new 1<= get_playersnum(1); i++) // start including players/HLTV connecting
    
{
        static 
hltv_players
        
if (is_user_hltv(i))
        {
            
hltv_players++
        }
        if (
hltv_players == 0)
        {
            
client_print(idprint_chat"There are NO HLTVs connected or connecting to this server!")
            return 
PLUGIN_HANDLED
        
}            
    }
    
    
hltv_socket socket_open(server,port,SOCKET_TCP,error// from HLDS<->IRC (thanks devnull)
    
switch (error
    { 
        case 
1:    
        {
            
log_amx("[HLTV RECORD] Error creating socket to %s:%i",server,port)
            return -
1
        
}
        case 
2:    
        {
            
log_amx("[HLTV RECORD] Error resolving hostname %s",server)
            return -
2
        
}
        case 
3:    
        {
            
log_amx("[HLTV RECORD] Couldn't connect to %s:%i",server,port)
            return -
3
        
}
    }
    
format(hltv_record_stop63"rcon stoprecording"// format stop record command
    
socket_send(hltv_socket,hltv_record_stop,0// send stop command
    
    
client_print(idprint_chat"[HLTV RECORD] HLTV Recording successfully ended - Check your HLTV folder for demo")
    
    return 
PLUGIN_CONTINUE

Slmclarengt (BnD | Sleeper)
Attached Files
File Type: sma Get Plugin or Get Source (record_hltv.sma - 1121 views - 4.0 KB)
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 05-06-2007 , 19:05   Re: HLTV record/stop plugin
Reply With Quote #2

you canīt send a command to a server (hltv) without the challenge number.
you need this first to send commands.

You should take a look to the hl1 engine rcon protocol.

(Tip: HLTV use the old protocol )

second: hltv servers have an rcon password too, itīs the "adminpassword". this one you need to send commands.

this is the way to get it work:
- send initialize to hltv server
- hltv server responding challenge number
- send challenge number & adminpassword & command

iīm working on a plugin to remote hltv too.
What my plugin does:

- command for all players, like "/cheater"
- an hltv connecting and records 3 min demo
- hltv disconnecting



its now beta, but all works fine, only cosmetics, release soon
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 05-06-2007 at 22:06.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 05-07-2007 , 00:04   Re: HLTV record/stop plugin
Reply With Quote #3

Quote:
Originally Posted by |PJ| Shorty View Post
you canīt send a command to a server (hltv) without the challenge number.
you need this first to send commands.

You should take a look to the hl1 engine rcon protocol.

(Tip: HLTV use the old protocol )

second: hltv servers have an rcon password too, itīs the "adminpassword". this one you need to send commands.

this is the way to get it work:
- send initialize to hltv server
- hltv server responding challenge number
- send challenge number & adminpassword & command

iīm working on a plugin to remote hltv too.
What my plugin does:

- command for all players, like "/cheater"
- an hltv connecting and records 3 min demo
- hltv disconnecting



its now beta, but all works fine, only cosmetics, release soon
Could you possibly give me an example, please? Because I do not understand exactly how to do that - Do I use sockets or another querying type?

Thanks,

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-07-2007 , 04:29   Re: HLTV record/stop plugin
Reply With Quote #4

Quote:
Originally Posted by VEN View Post
VEN is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 05-07-2007 , 07:04   Re: HLTV record/stop plugin
Reply With Quote #5

sure, added simplified example from my plugin.

- edit hltvpw[], hltvip[] and hltvport in the source (your "adminpassword" from hltv)
- connect a hltv server to your game server
- type "hltv_start" in your server console, hltv should start recording

take also a look to the links from VEN for more examples. the plugin in the 3rd link doesnīt work, but shows you basicly how to
Attached Files
File Type: sma Get Plugin or Get Source (hltv_example.sma - 1299 views - 2.8 KB)
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 05-07-2007 at 07:21.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 05-07-2007 , 17:46   Re: HLTV record/stop plugin
Reply With Quote #6

Thank you both very much - VEN for tutorials and Shorty of course for the example. Shorty, I'm wondering if
Code:
public send_command() {
	
	if (hltv_recording)
	{
		hltv_recording = false
		new packetstr[128]
		formatex (packetstr, 127, "%c%c%c%crcon %s ^"%s^" %s^n", -1,-1,-1,-1,hltvrcon,hltvpw,command_stop) //formating the command
		socket_send2(s_handle, packetstr, 127) //sending command
	}
	
	else
	{
		new packetstr[128]
		formatex (packetstr, 127, "%c%c%c%crcon %s ^"%s^" %s^n", -1,-1,-1,-1,hltvrcon,hltvpw,command) //formating the command
		socket_send2(s_handle, packetstr, 127) //sending command
		hltv_recording = true
	}
	abort_query() //close socket
	
	return PLUGIN_CONTINUE
}
would be ok as a substitute function for send_command() so that if the demo is already being recorded, stopping it through the command hltv_stop in console. I'll attach the whole source for simplicity. Thanks!

Slmclarengt
Attached Files
File Type: sma Get Plugin or Get Source (hltv_example.sma - 988 views - 3.3 KB)
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 05-07-2007 , 18:00   Re: HLTV record/stop plugin
Reply With Quote #7

Yes, sure. it was only a simply example from me.
you can send all possible rcon commands with it.
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 05-07-2007 , 22:33   Re: HLTV record/stop plugin
Reply With Quote #8

Quote:
Originally Posted by |PJ| Shorty View Post
Yes, sure. it was only a simply example from me.
you can send all possible rcon commands with it.
Well, it actually did not work - maybe it was because my modifications were inaccurate but would you mind making it start the demo and if it's already started, when hltv_stop is called, it stops the demo. I still cannot figure out how to use this stuff.

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 05-07-2007 , 22:58   Re: HLTV record/stop plugin
Reply With Quote #9

is my basic plugin from my 2nd post working?
is hltv start recording?
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 05-07-2007 at 23:56. Reason: wrong command before
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 05-08-2007 , 00:25   Re: HLTV record/stop plugin
Reply With Quote #10

Quote:
Originally Posted by |PJ| Shorty View Post
is my basic plugin from my 2nd post working?
is hltv start recording?
No, hltv_start from your second post is not working.

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt 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 06:33.


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