Lan Chess

Posted By: Bossy

Lan Chess - 05/11/11 10:05

Hi guys

i have this 2 action which highlight the chess piece and move it accordingly, i want to allow both player to be able to see the movement. for example player 1 move, player 2 should be able to see on the client side. player 2 move, player 1 should see the movement on his side.

i tried to
Code:
send_skill(my.skill1,SEND_UNRELIABLE|SEND_RATE);
send_skill(my.skill2,SEND_UNRELIABLE|SEND_RATE);


in highlighting function, but when player 1 highlights, player 2 can see on his side, but when player 2 highlight, player 1 can't see, so as the movement.

i post the movement and highlight part of my code, anyone can help?

skill1 stores the type of chess pieces
skill2 stores the position of the chess pieces.

Code:
function highlight_event()
{
	var skill1_old = 0, skill2_old = 0;
	
	if (event_type == EVENT_CLICK)
	{
		if (my.client_id == dplay_id)
		{ 	
			send_skill(my.skill1,SEND_UNRELIABLE|SEND_RATE);
			
      	send_skill(my.skill2,SEND_UNRELIABLE|SEND_RATE); 
		}

                if(selected == NULL)
		{
			resetValues();
	  		my.ambient = 100; // the make it look bright
	  		my.lightrange = 200; // and generate light on a radius of 200 quants!
	  		selected = my;
	  		selectedpiece = my.skill1;
	  		location = my.skill2;
		}
	  		
	  	else if(selected != NULL && my.skill1 == selectedpiece)
	  	{
	  		resetValues();
	  		my.ambient = 0; // the make it look bright
		  	my.lightrange = 0; // and generate light on a radius of 200 quants!
		 	selected = NULL;
		 	resetValues();
		}
			
		else if(selected != NULL && my.skill1 != selectedpiece)
		{
			resetValues();
			selected.ambient = 0; // the make it look bright
		  	selected.lightrange = 0; // and generate light on a radius of 200 quants!
		  	selected.skill2 = 0;
		  	my.ambient = 100; // the make it look bright
		  	my.lightrange = 200; // and generate light on a radius of 200 quants!
		  	selected = my;
		 	selectedpiece = my.skill1;
		  	location = my.skill2;
		}

		
		
	
	}	
}

function tiles_event()
{
	sides = 0.0;
	valid = 0.0;
	var id = 0.0;
	
	if(event_type == EVENT_CLICK)
	{
		if(selected != NULL)
		{
			if(mouse_ent)
			{
				tile = mouse_ent.skill2;
				sides = selectedpiece/10;
				id = selectedpiece%10;
				switch(id){
					case 1:	checkKing(tile);
					break;
					case 4: 	checkRook(tile,location);
					break;
					case 5:	checkKnight(tile);
					break;
					case 9:	checkPawn(tile,sides);
					break;
				}
				if(valid == 1)
				{
						selected.x = mouse_ent.x;
						selected.y = mouse_ent.y;
						selected.ambient = 0; // the make it look bright
						selected.lightrange = 0; // and generate light on a radius of 200 quants!
						selected.skill2 = mouse_ent.skill2;	
						selected = NULL; 		
				}	
			}
		}	
	}
}

action tiles()
{
	my.emask = ENABLE_CLICK;
  	my.event = tiles_event; 
}

action lights() // this action is attached to chess pieces
{
  	// make the wizard models sensitive to mouse touching and releasing
  	my.emask = ENABLE_CLICK | ENABLE_FRAME;
  	// run function highlight_event the wizards are touched or released
  	my.event = highlight_event;
}



thanks in advance~
*sorry for my poor english*
Posted By: Bossy

Re: Lan Chess - 05/12/11 10:23

anyone can help me, i have been stuck here for days~
Posted By: Redeemer

Re: Lan Chess - 05/12/11 13:31

Try setting the NOSEND flag to prevent the server from blocking the client's updates to the server.
© 2023 lite-C Forums