sorry one more multiply player question

Posted By: PrenceOfDarkness

sorry one more multiply player question - 12/11/10 10:19

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=349605#Post349605

hey jcl sorry for annoying you with yet another multiplayer related question.

i cant get sendskillto/id to work. thought might have had a problem else where in my code so i made a stand alone simple app but just can find the problem plz help.
Posted By: jcl

Re: sorry one more multiply player question - 12/13/10 09:18

Your idea is basically correct: When your script does not work as it should, strip it down to simplicity and then try to find the problem. However the script you posted is not simple, it has many waits, complicated skill conditions or lines that apparently make no sense. Lite-C is robust and runs also bad scripts, but too many bug possibilities make such a script useless for testing.

send_skill_to works when I try it, although of course it's possible that it has a bug that appears only under certain conditions. But for the next steps I suggest the following:

- First work through some lessons of the lite-C tutorial for learning better scripting - especially the debugging lessons and the two last lessons. You're an old timer on the forum, but I see from your code that you're not yet 100% settled in script writing. Multiplayer requires the ability to write clean code, and to know what to do when something does not work.

- Next, use the multiplayer tutorial for your test script. Run it with 2 clients. First just send a skill from the server to one of the clients, but not to the other. Use send_skill_to for this, giving the entity pointer. Check if this works.

- Then, send back a skill from one of the clients to the server, and use a receive event on the server to send it to the other client. Check also if this works.

If you encounter a problem, please post again and we'll help.


Posted By: PrenceOfDarkness

Re: sorry one more multiply player question - 12/13/10 15:00

Hey JCL! I followed your advice, and I must agree the sloppy code I posted made me look like an ammature. So I followed all of your advice to a T. I used the multiplayer tutorial as a guide and you were 100% correct send_skill_to DID work. I expected this because in my game I have used send_skill_to before and it has worked. However what I'm trying to do now needs to be done with send_skill_id. I've updated my post and made everything crystal clear. I am suspecting that send_skill_id is bugged. The code I included this time is very clear and commented very well. Please let me know if anything is unclear.

(btw I did some further testing. send_skill_id is returning 1 which means it is sending the information out. However the entity's receive flag is never triggered on the client, and yes I did set the flag.)

Also I did learn a bit in the debug tutorial. But I still can't get debug to work with multiplayer games. I run the current script with -sv -cl set and the I debug run only with -cl and the client hangs forever. I'm less concerned with this because I've been getting by pretty well debugging it with panels so I'd rather focus more on the send_skill_id. Maybe you could try it yourself but I can't imagine how you would write the code any different the what I did in my new post.

I've honestly searched every where for a working example of send_skill_id but I couldn't find a single one. I've searched over the last two years in the search and just some annoying prenceofdarkness guy keeps showing up wink with the same stupid problem.
Posted By: jcl

Re: sorry one more multiply player question - 12/13/10 15:10

Yes, debugging the server can cause the client to hang because the server does not send anymore. The client will hang as long as you single step. But that should normally not matter when you want to catch a certain event on the server.

We've meanwhile also looked into the send_skill_id functions and found indeed a potential problem. Under some circumstances, the id could be wrong. That can cause exactly the problem that you had.

This should not happen with the upcoming 8.10 version that's to be released in the next days for public beta test. I suggest that you wait for that version, and until then, use send_skill_to instead of send_skill_id. If the problem still happens in 8.10, please post again.

Posted By: PrenceOfDarkness

Re: sorry one more multiply player question - 12/13/10 15:19

This bug is in A7 as well and I believe it has been for months or years. Can you please release just this one change to the A7 user community? Originally I bought A7 pro just for these functions.
Posted By: jcl

Re: sorry one more multiply player question - 12/13/10 15:28

Can't you use send_skill_to in that case? You only need an ent_next loop for finding the entity pointer, like this:

Code:
function send_skill_id2(var id, var* skill, var mode)
{
  for (you = ent_next(NULL); you; you = ent_next(you)) {
    if(you.client_id == id) {
      send_skill_to(you,skill,mode);
      break;
    }
  }
}



Posted By: PrenceOfDarkness

Re: sorry one more multiply player question - 12/13/10 15:38

Thank you for the alternative (you just saved me hours trying to come up with a work around). However I will be honest, send_skill_id was a feature in A7 and not really a new feature (I wish the bug would have been found sooner so it would of been fixed) I just want what I payed for nothing more or less. An A7 user indeed found the bug (an old bug that should of been fixed). I'm just asking if it's not to much trouble that when you guys do fix it if it can be released to everyone. In the end your the boss and I don't have any real say of course.

Regardless of your final decision JCL, I do want to thank you for your time and I hope you continue to accept questions via "Ask the Developers"... no matter how annoying we might get wink.

On a bit off topic note.. If A8 ever has any advantages over A7 multiplayer you can be sure I'll be the first to upgrade to pro A8.
Posted By: PrenceOfDarkness

Re: sorry one more multiply player question - 12/13/10 15:52

btw I change my code to include the function you wrote and it didn't work.

Code:
ENTITY* item;	//a pointer not called player to eliminate confusion
var itemSkill1;//a global variable for the item's skill1 so that the engine doesnt return a "IDK what item.skill1 is" error
var itemClient_id;//this is the items's client_id of the item's maker. This should be zero because the SERVER made this entity
var vClientid;	//a variable to indicate the client_id of a client that has just joined

PANEL* testPNL = {
	flags = SHOW;
	digits(0,0,"item.skill1: %.3f",*,1,itemSkill1);
	digits(0,10,"dplay_id: %.3f",*,1,dplay_id);
	digits(0,20,"item.client_id: %.3f",*,1,itemClient_id);
	digits(0,30,"vClientid: %.3f",*,1,vClientid);
}

function send_skill_id2(var id, var* skill, var mode)
{
	for (you = ent_next(NULL); you; you = ent_next(you)) {
		if(you.client_id == id) {
			send_skill_to(you,skill,mode);
			break;
		}
	}
}

function on_server_event(void* str,var id) // automatically assigned to on_server
{
	if(event_type == EVENT_JOIN)	//if a client joined
	{
		vClientid = id;	//store the ID of the client that just joined into a global variable
	}
}

void fItem()
{
	while(my.client_id < 0) wait(1);	//this item is created on the server there for client_id will be zero but I'll include it anyway
	item = my;	//this is an item
	
	if(connection & CONNECT_SERVER)	//in my game the server would assign the item an ID number so i'll do the same here for skill1
	{
		my.skill1 = 1000;
	}
	else										//if we're not a server we're a client
	{
		while(my.skill1 != 1000)		//wait until our skill1 because the value we know it should be. In this case 1000
		{
			itemSkill1 = my.skill1;		//since we're locked in this loop forever because send_skill_id isn't working I want
			itemClient_id = my.client_id;//to update our client_id and skill1 values.
			wait(1);
		}
	}
	
	while(1)
	{
		wait(1);
		
		itemSkill1 = my.skill1;				//this only works on the server because the client never makes it to this point
		itemClient_id = my.client_id;		//because it's skill1 never changes from zero
		
		if(connection & CONNECT_SERVER)
		{
			send_skill_id2(vClientid,my.skill1,0);	//the server sends the vClientid FOREVER but the client never seems to receive it
		}														//regardless of the fact that the client's dplay_id is equal to vClient_id which 
		else													//is the where the server is sending information to.
		{
			if(my.skill1 != 0)	//if the client would ever make it to this point the problem is solved and we break out of the while loop
			{
				break;
			}
		}
	}
	
	beep();	//two beeps indicate success!!
	beep();
}

on_server = on_server_event;	//if a client joins two parameters are passed: the player's name and the client identification number
//this is all in the manual if you look up on_server.
void main()
{
	if (!connection) { // not started with -cl / -sv -cl?
		if (!session_connect(app_name,"")) // no client found on the localhost?
		session_open(app_name); // start as server
	}
	
	do{wait(1);}
	while(dplay_status < 2); // wait until the session is opened or joined
	
	dplay_localfunction = 2;		//run actions on both server and client
	
	level_load("valiance.wmb");	// load the level
	
	if(connection & CONNECT_SERVER)	//are we a server?
	{
		ent_create("testing.mdl",vector(100,0,0),fItem); //OMG a monster was killed!!! Drop an item ont he server!
	}
}


Posted By: 3run

Re: sorry one more multiply player question - 12/13/10 15:56

I've tried to get it to work a long time ago but I couldn't... I think that's a bug!! Same as bug with c_ignore!! Why don't you fix them??? I understand that you are currently working on SELLING A8, but how can you start working on new version of Game Studio without even finishing older one?? Belive me, a lot users that uses A7 version of GS don't want to change to A8 yet and one of the main reasons is that they aren't sure that you'll support it well in future!! To my mind, I think that you'll leave A8 unfinished same as A7, and will start working on A9, which will be unfinished too...and so on... How can you push people to buy it (I mean A8)?! Why don't you support users that bought A7? You do really spit at them and they projects... That is really not serious... Shame upon you guys... Prince sorry for off-topic... But I can't keep it inside any more... And I know (cause I'm pretty sure) that all of my words will make no sense... Cause you don't care about A7 users...
Posted By: PrenceOfDarkness

Re: sorry one more multiply player question - 12/13/10 15:59

I think JCL will fix this. I mean how hard could it be. The work is already going to be done. And we're not asking for new features. I think A6 was pretty complete. Now that they're aware of the issues I can't imagine why not fix them.
Posted By: jcl

Re: sorry one more multiply player question - 12/13/10 16:04

As far as I understand your script, you're sending to the ID of the last joined client, but this client has not created any entity. So send_skill_id2 can not work in this case because no client created entity is found.
Posted By: 3run

Re: sorry one more multiply player question - 12/13/10 16:10

Where is JCL's message? It was right before your last post Prince.
Posted By: PrenceOfDarkness

Re: sorry one more multiply player question - 12/13/10 16:12

okay JCL you were right. Here is my main function for anyone actually following this:

Code:
void main()
{
	if (!connection) { // not started with -cl / -sv -cl?
		if (!session_connect(app_name,"")) // no client found on the localhost?
		session_open(app_name); // start as server
	}
	
	do{wait(1);}
	while(dplay_status < 2); // wait until the session is opened or joined
	
	dplay_localfunction = 2;		//run actions on both server and client
	
	level_load("valiance.wmb");	// load the level
	
	if(connection & CONNECT_SERVER)	//are we a server?
	{
		ent_create("testing.mdl",vector(100,0,0),fItem); //OMG a monster was killed!!! Drop an item ont he server!
	}
	else
	{
		ent_create("testing.mdl",vector(0,0,0),NULL);
	}
}


Posted By: jcl

Re: sorry one more multiply player question - 12/13/10 16:16

Here's a function that should work also for clients without created entities:

Code:
function send_skill_id2(var id, var* skill, var mode)
{
   ENTITY e;
   e.client_id = id;
   e.eflags = 1<<4;
   return send_skill_to(&e,skill,mode);
}



As to the question of an A7 patch - A7 is not in production anymore. We release patches in case of serious bugs, but so far nothing serious is known for A7. The known A7 bugs have simple workarounds.

As you found this bug, we can certainly do something for you when you want to upgrade to A8 - please contact the support in that case. A8 has not much multiplayer advantages over A7 though, the major difference is that it uses ENET instead of DirectPlay.
Posted By: PrenceOfDarkness

Re: sorry one more multiply player question - 12/13/10 16:28

WOW thank you very much!!!
© 2024 lite-C Forums