Watching a server from external program

Forum concernant ce jeu et les serveurs que j'héberge. (ce sous-forum remplace conseiljedi.com)
User avatar
evan1715
Posts: 95
Joined: Fri Nov 09, 2007 11:51 pm
Location: Florida
Contact:

Watching a server from external program

Post by evan1715 »

HEY :ouin

ok i hope u can answer this without
A. getting angry telling me to read a book again :P
B. telling me to make a topic, if not ill just copy and paste it :green

:D
OK, if you want to create a program (preferable without any .dll's) that u can launch and it will watch your jk2Ded for something like if some one changes their model to ******, the program will kick them... basically what im asking is: How do you get it to watch the jk2Ded for something?
******* is a client crash, if some1 does /model ****** people will start crashing once they press tab or die.
Last edited by Gamall on Sat Jan 05, 2008 10:38 am, edited 1 time in total.
Reason: topic created from MP. Sensitive info replaced by *****
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Watching a server from external program

Post by Gamall »

Some off-topic precisions (in the spoiler):
Spoiler: Reveal
evan1715 wrote:A. getting angry telling me to read a book again :P
I only do that when you ask indecently trivial questions you should have googled on. But this is a very interesting question, so I have no call to get angry. :langue
evan1715 wrote:B. telling me to make a topic
Yep, as any and all tech questions, it deserves a topic. PMs and mail are only for "non reusable or extremely sensitive" stuff.
evan1715 wrote:OK, if you want to create a program (preferable without any .dll's) that u can launch and it will watch your jk2Ded for something like if some one changes their model to ******, the program will kick them... basically what im asking is: How do you get it to watch the jk2Ded for something?******* is a client crash, if some1 does /model ****** people will start crashing once they press tab or die.
-> In a mod

Well, the simplest and most efficient way to do that would be to write a mod: 4 or 5 lines in ClientUserInfoChanged() ought to do the trick. This is not your question, however, so I'll assume that writing or modifying a mod for that purpose is completely impossible.

-> In an external program

Well, there are things you can easily watch from an external program, by checking them regularly: every server tracker program does that, and that's what QCmd v0.2's monitor mod does for the number of clients. Basically, you can watch everything getInfo and getStatus give you. But they don't give you the player's models. I wouldn't count on any non-admin query to do that.

The program would need RCon to kick anyway, so if there is a RCon command which returns the model (or full userinfo) of all players, writing said program will be very easy (when you know some socket programming).

But, if there is no such RCon command, I can't think of anyway to do it except... using a fully-functionnal fake player. This has never been done so far as I know. The only two programs I know of which create fake players are Luigi Auriemma's q3fill and my QCmd v0.2's messenger mode. And none of these go further than the "handshake".

The idea would be to fully simulate a player through the program. As any player, this one would be kept updated on everybody else's actions and... model changes. It would then be possible to detect the change as soon as it happens, and take immediate action. That's a far-fetched way to do things, but that's the only one I see.

But I wouldn't know how to write that, there doesn't seem to be any documentation about that on the net.


-> So, to sum it up...
  1. If you can compile a mod (which you can on any up-to-date versions of the game ;) ), do that without hesitation, it is clearly the best solution. If you really really cannot, move to point 2.
  2. If you can find a rcon command returning the model, no problem, I'll write the app when I get time and release the code. Some good code speaks more clearly than a 100 vague forum posts. If there is no such RCon command, see point 3.
  3. If you can find extensive documentation on JK(A/2)'s client protocol after the getchallenge/connect bit, well, I'll see what I can do with it, and with some luck and a lot of time, it might work. If you can't find documentation, see point 4.
  4. See point 1 :gamall
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
evan1715
Posts: 95
Joined: Fri Nov 09, 2007 11:51 pm
Location: Florida
Contact:

Re: Watching a server from external program

Post by evan1715 »

-_-

it's been done before, people have kickbots, but for linux, theres some1 i know who wrote it in Linux Shell script or whatever, then some1 who wrote it in C but won't share it :P, and some1 who wrote it in VB and also wont share... I know you can watch it for a particular model change because thats what a kill tracker does (like mau dae's kill tracker 2.0 for JK2 here written in VB)... the kill tracker watches for "%s was sabered by %s" then does in console, "/say I have killed this many people %s in total." so why can't another program watch the jk2Ded for maybe not model\****** but for ANYTHING that has ******* and see which client number it is, then well in a mod do
if (galak_mech)
trap_SendServerCommand(-1, va("clientkick \"%s"", clientNum));
i mean it should be some-what like that >_< (idk if u do print\ clientkick or what, if u do i think it just does server: clientkick #)

meh, what i ment is for a home-dedicated server, 1 that you host on ur computer and not some paid for 1, watch that jk2Ded for any "*****" and if so find the clientNum that changed to it, then print "clientkick %s" and after that say "svsay Client was kicked for using ******"... maybe u misunderstood and now going to think it's a dumb question :( (ive googled it and it's not seeming to help me)

yes a mod would be a great idea, but it's JK2 1.02 and we have no source code :P
no theres no such rcon command :S
lol and theres no way i can ever find out how to make an official fake player bot that does stuff for you :P
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Watching a server from external program

Post by Gamall »

First: Please make an effort on the presentation: your post is nearly undreadable :?

Second:
evan1715 wrote:meh, what i ment is for a home-dedicated server, 1 that you host on ur computer and not some paid for 1
Ah! How was I supposed to guess this ? I thought you were talking about a remote server.

You do realize these are two totally different problems ? :banghead
evan1715 wrote: know you can watch it for a particular model change because thats what a kill tracker does (like mau dae's kill tracker 2.0 for JK2 here written in VB)
A kill tracker works in a very different way a program communicating with a remote server does. The first uses system calls to communicate directly with the app, while the latter uses a communication protocol built on TCP or UDP (in the case of q3: udp).

So, basically, what you want is a KT-like app. I have never written one of those, so I can't help you much. The code you linked to will be extremely useful, though:

The meat of the matter is in jedithing.bas:

Code: Select all

Public Declare Function GetTickCount Lib "kernel32.dll" () As Long
Public Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As etc... 
This is the part of the Win32 API you'll need, regardless of the programming language you use.
Note: if you do that in C or another portable language, please don't do it the same way it's done in this code: wrap the API calls in a somewhat more abstract wrapper, so as not to screw portability completely... thanks :)

And the core program in jedithing.frm:

Code: Select all

jkmpwinconsole = FindWindow("jk2mp winconsole", vbNullString)
editx = FindWindowEx(jkmpwinconsole, 0&, "edit", vbNullString)

Call SendMessageBystring(editx, WM_SETTEXT, 0&, "say " + sbrmsg)
 
(of course, you'll need to adapt: it won't be "jk2mp winconsole" in your case... etc...).


Again, I have personally never written any KT-like app, and I don't know the Win32 API. So I won't be of much use if that's what you want to do. You best bet is to find someone who has and get help there.

Although with a good book (when I programmed in VB6... long ago... I had "Win32 API Programming with Visual Basic", by Steven Roman, O'REILLY. A very good book.), the VB code, and lots of time and efforts, you should be good to go...
evan1715 wrote:yes a mod would be a great idea, but it's JK2 1.02 and we have no source code
This is the part when I really bang my head against the walls. :banghead But you already know that, I don't think I've told you more than 7827737353525353838363531342 times already. :provo
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
evan1715
Posts: 95
Joined: Fri Nov 09, 2007 11:51 pm
Location: Florida
Contact:

Re: Watching a server from external program

Post by evan1715 »

Gamall wrote:You do realize these are two totally different problems ? :banghead
yeah i realize that, but i wasnt thingking of a "remote server" i was just thinking of a 2 apps together on 1 computer, the kicker and the jk2ded
Gamall wrote:The meat of the matter is in jedithing.bas:

Code: Select all

Public Declare Function GetTickCount Lib "kernel32.dll" () As Long
Public Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As etc...   
This is the part of the Win32 API you'll need, regardless of the programming language you use.
Note: if you do that in C or another portable language, please don't do it the same way it's done in this code: wrap the API calls in a somewhat more abstract wrapper, so as not to screw portability completely... thanks :)

And the core program in jedithing.frm:

Code: Select all

jkmpwinconsole = FindWindow("jk2mp winconsole", vbNullString)
editx = FindWindowEx(jkmpwinconsole, 0&, "edit", vbNullString)

Call SendMessageBystring(editx, WM_SETTEXT, 0&, "say " + sbrmsg)
   
(of course, you'll need to adapt: it won't be "jk2mp winconsole" in your case... etc...).
so ur saying i to basically rewrite those 2 files just to have a box with an exit button the top right, no options, and for it to just watch the jk2Ded then clientkick >_< ?! (eh this is preferably going to be written in C, i can't write VB but it seems easy to read)

"You best bet is to find someone who has and get help there."
oh i'm trying to >_<, luigi seems to have given up on me :P and my friend thats was helping me on the mod, went to go do a Q4 mod and then theres 1 other person that wrote the Linux kicker to get flooders and the model user, written in C, but he is never online...
User avatar
evan1715
Posts: 95
Joined: Fri Nov 09, 2007 11:51 pm
Location: Florida
Contact:

Re: Watching a server from external program

Post by evan1715 »

ok what about this...
how do u get it to watch the games.logs file for the model change?
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Watching a server from external program

Post by Gamall »

evan1715 wrote:s just to have a box with an exit button the top right, no options,
Don't you think it's quite premature to think about the GUI right now ? :?
evan1715 wrote:k what about this...how do u get it to watch the games.logs file for the model change?
Could be an idea,if the userinfo changes are logged. I think they are if the server is in developer mode (seta developer 1).

But the logs are buffered, so everything is written with a delay which depends on the amount of data the servers produces. This delay might be too long to make the kicker really efficient.
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
evan1715
Posts: 95
Joined: Fri Nov 09, 2007 11:51 pm
Location: Florida
Contact:

Re: Watching a server from external program

Post by evan1715 »

userinfochanged is always logged if logs are on. seta g_log "games.log"

Yeah, i always look at logs, there is indeed a delay, i just need to know how to watch the log because it could be easier to find a way how... so its either the logs or the jk2ded and i dont know how >_< after that im set i can do the rest (i think)
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Watching a server from external program

Post by Gamall »

evan1715 wrote:userinfochanged is always logged if logs are on. seta g_log "games.log"
...but I don't think the full userinfo is written down each time by default. If it isn't, how are you going to parse it to find the model ? ;)
evan1715 wrote: i just need to know how to watch the log
:quoi It amounts to reading a file. You know how to read a file ? Then you know how to watch the logs :huhu
(plus you need to keep track of where you are in the logs exactly, using something like fsetpos etc, and parse them somehow to extract the model... nothing exciting there, but nothing difficult either)
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
evan1715
Posts: 95
Joined: Fri Nov 09, 2007 11:51 pm
Location: Florida
Contact:

Re: Watching a server from external program

Post by evan1715 »

Gamall wrote:...but I don't think the full userinfo is written down each time by default. If it isn't, how are you going to parse it to find the model ? ;)
actually CHANGEuserinfo is logged by default each time, play jk2 and you'll see.
Gamall wrote:It amounts to reading a file. You know how to read a file ? Then you know how to watch the logs :huhu
(plus you need to keep track of where you are in the logs exactly, using something like fsetpos etc, and parse them somehow to extract the model... nothing exciting there, but nothing difficult either)
-_- :rhaaaa ........ k wtf? i guess i didn't word myself correctly or i am misunderstanding your post, "I just need to know how to watch the jk2Ded or the games.log file for a model change to galak_mech if so print it on the jk2Ded and kick it, by not doing this manually coding it in C as a program and letting it do it automatically."

The link u gave me tells it where in the file, first i have to make it FIND the file or process(jk2ded) >_< which i do not know how to do
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Watching a server from external program

Post by Gamall »

evan1715 wrote: first i have to make it FIND the file [...] >_< which i do not know how to do
Ok.This is the long-awaited read a book part. ;(

-> http://www.cppreference.com/stdio/index.html
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
evan1715
Posts: 95
Joined: Fri Nov 09, 2007 11:51 pm
Location: Florida
Contact:

Re: Watching a server from external program

Post by evan1715 »

don't be so ignorant

i looked at the whole site, i went http://www.cppreference.com/all_c_functions.html to when you gave me http://www.cppreference.com/stdio/fsetpos.html/
of course i looked at all of that crap
theres nothing there but horse shit

"fopen open a file" i assume that just opens the fucking file i just want it to monitor it

u know i just dont want to explain it to u, ur not understanding, just close the topic and put it in ur cave thing or whatever the hell it is, u haven't helped me very much at all since i've started talking to u, just close the topic
User avatar
evan1715
Posts: 95
Joined: Fri Nov 09, 2007 11:51 pm
Location: Florida
Contact:

Re: Watching a server from external program

Post by evan1715 »

sry, just close the topic :ouin :grrrr

also do u mind if i take some of ur cool smileys and add it to my forum? :paladin
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Watching a server from external program

Post by Gamall »

evan1715 wrote:"fopen open a file" i assume that just opens the fucking file i just want it to monitor it
You know... you have to write some code to make a program... I'm sorry to break it to you like that... there is no magic formula out there that does exactly what you want, you have to write the magic formula using the little you have. In this case, you have to write a function which monitors a file, using fopen and fsetpos and and and... and it's not difficult, but it takes time and nobody will do it for you unless you pay them.

That kind of activity even has a name: it's called programming... are you sure that's really what you are interested in ? :8|
evan1715 wrote:also do u mind if i take some of ur cool smileys and add it to my forum?
Help yourself, they are not "mine" anyway, I took them here and there.
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
evan1715
Posts: 95
Joined: Fri Nov 09, 2007 11:51 pm
Location: Florida
Contact:

Re: Watching a server from external program

Post by evan1715 »

Gamall wrote:...unless you pay them.
well i just don't want to do it that's all, but some body has to to help the dying game that i've been playing for 6 years... how much? :oO
Gamall wrote:
evan1715 wrote:also do u mind if i take some of ur cool smileys and add it to my forum?
Help yourself, they are not "mine" anyway, I took them here and there.
Cool.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 190 guests