lfnetwork.com mark read register faq members calendar

Thread: Writing a file based on IP address
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 08-18-2009, 12:00 PM   #1
eezstreet
Lurker
 
Join Date: Aug 2009
Posts: 3
Writing a file based on IP address

I'm making a code modification, but I need some assisstance with something.

My code mod is going to have a 'challenge' system similar to Movie Battles 2, as well as an experience, levelling, and class system. Challenges unlock certain things, and certain challenges are limited to class and weapon.

I want the game to write a file serverside based on the IP address to achieve this, as well as a /wipe command in order to erase all data.

I'm thinking I can reference two new functions, oz_Write and oz_Read in ClientDisconnect and ClientConnect, respectively. I haven't the foggiest idea how to write oz_Write/Read though, and I tried using a register type system that Robo posted a while back, but it requires me to include Windows include files and that will crop up even more issues (But it will work with JK3...sigh).

I'm using the .vm compiler to compile in JK2 first, that way I know how to implement the features without worrying about JK3 exploits. Then I can fix the bugs, or use OJP's source.

I'm thinking something like a write file, but use ent->client->sess.IPString as a filename.

Could someone help me please?
eezstreet is offline   you may: quote & reply,
Old 08-22-2009, 01:30 PM   #2
dumbledore
Rookie
 
Join Date: Nov 2005
Posts: 85
wouldn't a login system be better? peoples ip addresses change all the time.
dumbledore is offline   you may: quote & reply,
Old 08-24-2009, 01:55 AM   #3
-=*Raz0r*=-
Rookie
 
-=*Raz0r*=-'s Avatar
 
Join Date: Oct 2006
Location: Australia
Posts: 243
Create a new string in client->sess called IP

Upon ClientConnect it does a userinfo grab for the IP.
Create a local variable (char TmpIP[32] = {0})

Adjust the code to look like:
Code:
	// check to see if they are on the banned IP list
	value = Info_ValueForKey (userinfo, "ip");
	//Store the IP
	if (!isBot)
		Q_strncpyz(TmpIP, value, sizeof(TmpIP)); // Used later
	if ( G_FilterPacket( value ) ) {
		return "Banned";
	}
Then, just before this block of code:
Code:
//if this is the first time then auto-assign a desired siege team and show briefing for that team
Chuck in...
Code:
if (firstTime && !isBot)
{
	if(!TmpIP[0])
	{// No IP sent when connecting, probably an unban hack attempt
		client->pers.connected = CON_DISCONNECTED;
		return "Invalid userinfo detected";
	}
	Q_strncpyz(client->sess.IP, TmpIP, sizeof(client->sess.IP));
}
So when someone connects for the first time, their IP is stored in client->sess.IP, which can then be accessed from anywhere in the gameside code.
That code there (As explained in comments) will also deny connection from someone attempting to overflow their userinfo string, in which case ban checks can't be performed

Then, create your file writing/reading funcs using that.
For file reading, I recommend poking around JA's token parsing system (You know, the way it reads .sab files)


Sorry I can't post much more, kind-of rushed =P


Last edited by -=*Raz0r*=-; 10-02-2009 at 08:48 PM. Reason: Forgot to add '!isBot' where we deny the connection
-=*Raz0r*=- is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > Writing a file based on IP address

Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:28 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.