Gamestudio Links
Zorro Links
Newest Posts
hello all
by jcl. 09/24/19 09:04
Right AssetsFix for trading Forex on IG?
by Andy60. 09/23/19 21:11
Converting fbx file to mdl7
by Dark_Light. 09/23/19 15:50
New system for Zorro S subscriptions
by jcl. 09/23/19 08:34
IG plugin initial release
by Andy60. 09/23/19 07:40
Any chance of PBR materials with A8?
by Dooley. 09/22/19 21:43
Levels, textures, etc for A8
by Dooley. 09/22/19 03:57
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
8 registered members (svenbob, Tamas, MatPed, Superku, kvm, jenGs, 3run, 1 invisible), 642 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Zylo, Hjuutgckk, Dark_Light, oxygenjoe, web20tpo
18292 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Quick Super Noob Question about Connecting [Re: EpsiloN] #450049
04/05/15 16:43
04/05/15 16:43
Joined: Apr 2005
Posts: 1,985
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,985
Canadian, Eh
Quote:

About the Servers listing, I've also never done this, but I'm planning it for my next project.

The theory is this:
Every play that clicks "Start server" sends URL GET parameters to my webpage, a certain .php file that records his IP, PORT, Server name, Players in server, map name in a MySQL table.
Then, every client that clicks on "Servers list" will send GET method parameters to my webpage, again a certain .php file, that will spit out all servers recorded in the MySQL table as text.
The client's game will parse this text to separate the servers and show them on screen. Once the player clicks "Join", he'll use the IP that was given by my website for that particular server to connect a session.
When a server is closed, it will again send data to my website to get it off the list. Also, each time a client disconnects, the server will send data to modify the information in the table to show accurate players count for that server.

All this is done with a MySQL table and basic PHP.

If you don't know what GET parameters are, search on google. GET is the vars sent with the website address in the URL input box on your Internet Explorer.

The only hard part is parsing the returned text. Not that its hard, but there are countless ways to implement that...


Thanks dude, This is awesome! This makes good sense, I just need to put the theory to work for myself now. I've been building websites so php and mysql is like riding a bike grin Edit: (if you know how to ride a bike I suppose)

Last edited by DLively; 04/05/15 16:44.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: Quick Super Noob Question about Connecting [Re: DLively] #450075
04/06/15 10:19
04/06/15 10:19
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
No problem laugh I will be doing the same thing soon, so if you have any problems contact me and I'll try to help.

Also, here's a long forgotten MMO project I was working on, as an example of a character creation with a PHP and MySQL system:
Code:
STRING* character_creation_str="";
STRING* client_username_str="";
STRING* client_password_str="";
function create_character()
{
	character_creation = 1;
	str_cpy(character_creation_str,"op=7&user=");
	str_cat(character_creation_str,client_username_str);
	str_cat(character_creation_str,"&pass=");
	str_cat(character_creation_str,client_password_str);
	str_cat(character_creation_str,"&app=0000000000&pos=0000000x0000000x0000000");
	var createchar_http_id = http_sendpost("http://www.mesetts.com/game_req.php",character_creation_str);
	while (!http_status(createchar_http_id)) { wait(1); }	//wait for the server to reply
	if (http_status(createchar_http_id) == 1)					//transfer successful?
	{
		http_result(createchar_http_id,character_creation_str);	//get the replied IP
		if(str_cmp(character_creation_str,"41") == 1)
		{
			info_num = 13;
			str_cpy((info_txt.pstring)[0],"Character created!\nEntering game...");
			pan_controller(info_ok , SHOW_PAN);
		}
		else
		{
			info_num = 12;
			str_cpy((info_txt.pstring)[0],"Could not create. Please,\ncontact the administrator immediately!\nError code: ");
			str_cat((info_txt.pstring)[0],character_creation_str);
			pan_controller(info_ok , SHOW_PAN);
		}
	}
	else
	{
		info_num = 12;
		str_cpy((info_txt.pstring)[0],"Could not connect to database server.");
		pan_controller(info_ok , SHOW_PAN);
	}
	http_free(createchar_http_id);									//always cleanup the httpid!
}



And the PHP part:
Code:
if($operation == 7) {				// If register request
	if(isset($_GET['user'])) {		// If user received
		$user = $_GET['user'];		// Get it
	}
	else {
		echo '43';			// Else return 5 - no user posted
		return;
	}
	if(isset($_GET['pass'])) {		// If pass received
		$pass = $_GET['pass'];		// Get it
	}
	else {
		echo '44';			// Else return 6 - no pass posted
		return;
	}
	if(isset($_GET['app'])) {
		$app = $_GET['app'];
	}
	else {
		echo '48';
		return;
	}
	if(isset($_GET['pos'])) {
		$pos = $_GET['pos'];
	}
	else {
		echo '49';
		return;
	}

	$user = stripslashes($user);		// Strip slashes
	$pass = stripslashes($pass);
	$user = mysql_real_escape_string($user);	// Remove bad characters
	$pass = mysql_real_escape_string($pass);
	$app = stripslashes($app);
	$app = mysql_real_escape_string($app);
	$pos = stripslashes($pos);
	$pos = mysql_real_escape_string($pos);

	$mysqli_query_str="SELECT * FROM users WHERE nick='$user' and parola='$pass'";	// Prepare query
	$result=$mysqli->query($mysqli_query_str);					// Look for user

	// Mysql_num_row is counting table row
	$count=$result->num_rows;
	// If result matched $myusername and $mypassword, table row must be 1 row

	if($count==1){				// If match found
		$row = $result->fetch_assoc();
		if($row['character'] != null)
		{
			echo "46";		// Already present
			return;
		}
		else {
			$mysqli_query_str="INSERT INTO characters (appearance, position) VALUES('$app','$pos')";	// Prepare query
			$result=$mysqli->query($mysqli_query_str);							// Register user in database
			if($result) {
				$charid = $mysqli->insert_id;
				$mysqli_query_str='UPDATE users SET `character`="'.$charid.'" WHERE `nick`="'.$user.'" AND `parola`="'.$pass.'"';	// Prepare query
				$result=$mysqli->query($mysqli_query_str);							// Register user in database
				if($result) {
					echo "41";		// Success creating char and inserting
					//echo "<br />" . $charid . " | " . $result . "<br />" . $mysqli_query_str;
				}
				else {
					echo "40";		// Success creating/failed linking
					//echo "<br />" . $mysqli->error;
					return;
				}
			}
			else {
				echo "47";			// Failed creating
				return;
			}
		}
	}
	else {
		echo '45';			// Else - no user found / bad pass
		return;
	}
}



pan_controller is a function that shows/hides my panels in this case...

Don't laugh at my PHP laugh it was a long time ago...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Quick Super Noob Question about Connecting [Re: EpsiloN] #450082
04/06/15 13:59
04/06/15 13:59
Joined: Apr 2005
Posts: 1,985
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,985
Canadian, Eh
Thank you! This will be great to learn from. Better a little late, than never grin

Your php is not bad enough to laugh at tongue You may already know this but you can place functions in functions.
Code:
$user = stripslashes(mysql_real_escape_string($user));// Strip slashes & Remove bad characters
$pass = stripslashes(mysql_real_escape_string($pass));

....

$result=$mysqli->query("SELECT * FROM users WHERE nick='$user' and parola='$pass'");


I like php because of how 'dynamic' the usability of the syntax is.

Cheers laugh


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: Quick Super Noob Question about Connecting [Re: DLively] #450141
04/07/15 10:32
04/07/15 10:32
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Now I know, years ago I didn't laugh I also like the flexibility PHP has that is missing in Lite-C, but at least Conitec added multidimensional arrays, unlimited local arrays and passing any number of arguments... grin That was my biggest pain back in the days...it was extremely limited...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Page 2 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1