The rejoin problem

Posted By: anfuncy

The rejoin problem - 08/05/06 09:51

Hi, all.
I have a strange problem. I finished a "clientA click clientB and show clientB's health on clientA's screen" code.
I tested the code with a host and a client, When they join the game first time, they can click each other and show correct health.
But when the client leave and rejoin the game, he can't click the host anymore.
In other words, it can't trigger the enable_click event while clicking.
At the same time, I let a third player join the game(the second client), and the first client can click the second client, but the second client can't click anyone.

The problem let me so confused and has taken me so much time.
I hope someone can help me, thanks very much

my code :
Code:

entity* ent_you;

panel pan_show
{
pos_x = 500;
pos_y = 0;
digits = 20, 10, 5, _a4font,1,ent_you.health;
layer = 20;
flags = refresh, d3d;
}


action move_player1 //three player actions, I just paste one
{
actor = 1;
wait(1);
proc_client(my,move_player_local);

if(connection == 3)
{
move_player_local();
}
}


function move_player_local()
{
player_move();
}

function player_events()
{
if(event_type == event_click)
{
ent_you = me;
pan_show.visible = on;
}
// client disconnected
if (EVENT_TYPE == EVENT_DISCONNECT)
{
ent_remove(me); // remove ent of player that quit
}
}

function fun_LocalEvent()
{
// this area isn't executed when the client rejoin
ent_you = me;
pan_show.visible = on;
}

function fun_ClickLocal()
{
// this area is executed
if(connection == 2)
{
// this area is executed
my.enable_click = on;
my.event = fun_LocalEvent;
}
}
function player_move()
{
my.enable_disconnect = ON;
my.enable_click = ON;
my.event = player_events;

my.nosend_frame = on; // don't send animation

sleep(.3); // this can be left at .3 no matter what
ent_sendnow(my);
sleep(.3); // sleep(3); // high latency solution for now

proc_local(my,fun_ClickLocal);

if(actor == 1)
{
my.health = 50;
}
if(actor == 2)
{
my.health = 40;
}
if(actor == 3)
{
my.health = 30;
}
send_skill(my.health,send_all);

while(1)
{
......//movement code
}
}



Posted By: anfuncy

Re: The rejoin problem - 08/06/06 13:58

Today I finally know why the client can't trigger the enable_click event
after rejoining.
The answer is I use two local procedure in the same entity.
How fool I am!
But three is still problem, the health after clicking is always zero after the player rejoin the game. Just as before.
Hope someone can help me.
I will keep trying.
Posted By: anfuncy

Re: The rejoin problem - 08/08/06 13:38

No suggestion?
Sometimes I doubt that the problem shoudn't occur.
I searched the forum, it seems that no one faced the strange problem.
Recently, I found a new thing. When clientA clicks clientB, the clientB's entity pointer indeed pass to the clientA.
Code:

function fun_LocalEvent()
{
my.transparent = on;
ent_you = me;
pan_show.visible = on;
}

function fun_ClickLocal()
{
if(connection == 2)
{
my.enable_click = on;
my.event = fun_LocalEvent;
}
}


After testing, the clientB become transparent after the clientA click it.
But just as before, the health is always zero only when the client rejoin the game.
Why on earth the clientB's health can't pass to clientA correctly?
It's always zero, zero, zero......:(
I'm tired although, I will keep trying.
© 2024 lite-C Forums