I have added some code to George's Multiplayer10's function main, the if (client_fired) code near the end.

This shows that the my pointer sent from the client and directed to you on the server is seen as the my of server,
so client's bullet fires from the server's gun?

George had this code working, so has a bug crept into later releases of Gamestudio?

Code:
function main() 
{
	fps_max = 60; // limit the number of data packets that are sent over the network each second to 60
	level_load ("multiplayer10.wmb");
	camera.ambient = 120;
	on_mouse_left = fire_bullets; // the player use the left mouse buttons to fire
	if (!connection) // no server could be found?
		sys_exit(NULL); // then shut down the engine
	if (connection == 2)  // this instance of the game runs as a client?
	{
		my = ent_create("redsoldier.mdl", vector (100, 50, 40), move_players); // then create the red soldier!		
		wait (-0.5); // wait until the handle is ready and valid for all the clients (this line is very important!)
		client_ent = handle(my); // now we can get a valid handle to the client entity (the player that runs on the client)
		send_var(client_ent); // and let's send the handle over the network to the server (no need to do that more than once)
		while (1) 
		{			
			my.skill1 = 5 * (key_w - key_s) * time_step;
			my.skill2 = 4 * (key_a - key_d) * time_step;
			send_skill(my.skill1, SEND_VEC); // send skill1...3 to the server (skill3 is used to store player's health
			send_var(client_fired); // send client_fired to the server; even client's bullets are created on the server
			simple_camera(); // call the simple camera function
			// new code
			players_health = my.health; // display the proper player health value on the client
			wait (1);
		}
	}
	if (connection == 3) // this instance of the game runs as a server and client at the same time? (connection = 3)
	{
		my = ent_create("bluesoldier.mdl", vector (-100, -50, 40), move_players); // create the blue soldier
		VECTOR bullet_pos[3];
		while (1) 
		{
			my.skill1 = 5 * (key_w - key_s) * time_step;
			my.skill2 = 4 * (key_a - key_d) * time_step;
			simple_camera(); // call the simple camera function
			// new code
			players_health = my.health; // display the proper player health value on the server
			
			if (server_fired) // the server has fired? Then we've got everything that we need here ("my" is the player on the server)
			{
				vec_set(bullet_pos.x, vector (30, -5, 15)); // create the bullet at an offset of x = 30, y = -5, z = 15
				vec_rotate(bullet_pos.x, my.pan); // in relation to the origin of the model
				vec_add(bullet_pos.x, my.x);
				bullet_pan = my.pan; // the bullet will have the same pan angle with player's pan
				if (my.health > 0) // the server player is still alive?
					ent_create("bullet.mdl", bullet_pos.x, move_bullets); // then create the server player bullets
			}
			if (client_fired) // the client has fired? Then we need to get access to the client player
			{
				beep(); // See if client mouse left button is seen! IT IS !!!!
				
				you = ptr_for_handle(client_ent); // let's restore its handle; the client player is now "you"
				
				// We are not 'seeing' you as the client soldier's data but as the server soldier's data!!!!!!!!
				// =============================================================================================
				
				vec_set(bullet_pos.x, vector (30, -5, 15)); // we set bullet_pos to the same offset
				vec_rotate(bullet_pos.x, you.pan); // in relation to the "you" model (client's player)
				vec_add(bullet_pos.x, you.x);
				bullet_pan = you.pan; // and we use client's player pan angle for the bullet
				if (you.health > 0) // the client player is still alive?
					ent_create("bullet.mdl", bullet_pos.x, move_bullets);	// then create client's bullets (on the server as well)

				vec_set(bullet_pos.x, vector (30, -5, 15)); // we set bullet_pos to the same offset
				if (you.health  > 0) // Test Code! This adds 15 to Server, NOT Client????????????
					you.health += you.health ;
			}
			wait (1);
		}
	}
}



Last edited by cjm; 06/28/09 15:06.