click other client and show some informations

Posted By: anfuncy

click other client and show some informations - 07/23/06 15:13

Hi, all.
I want my client click other client and show some informations.
Suppose that clientA clicks clientB, and clientA's screen will
show clientB's health.
I tried some ways but it doesn't work.
Can someone help me?
Thanks very much!!

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 fun_show_health(ent)
{
ent_you = ent;
pan_show.visible = on;
}



function player_events()
{
if(event_type == event_click)
{
proc_client(you,fun_show_health(me));
}


// client disconnected
if (EVENT_TYPE == EVENT_DISCONNECT)
{
ent_remove(me); // remove ent of player that quit
}
}


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

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: Dutchie666

Re: click other client and show some informations - 07/23/06 16:14

maybe you can use on a client:

function mouse_check(){
while(1){
wait(1);
if(mouse_left && mouse_ent){
ent_you = mouse_ent;
}
}
}

it just checks if you press left mouse button and if a mouse entity is active and than sets the ent_you to mouse_ent
Posted By: anfuncy

Re: click other client and show some informations - 07/24/06 16:21

Thanks for your reply
But the skill(health) what it get is always zero,
my entities' health are all above zero.
Posted By: Dutchie666

Re: click other client and show some informations - 07/24/06 19:41

maybe you could test if the model you press is really changed to the ent_you model... ty change the function to:
function mouse_check(){
while(1){
wait(1);
if(mouse_left && mouse_ent){
ent_you = mouse_ent;
ent_you.transparent = on;
}
}
}
Posted By: anfuncy

Re: click other client and show some informations - 07/27/06 06:11

Thanks for your tip.
Unfortunately, the pointer doesn't send to server.
Yesterday I tried another way, it worked but still have some problems.

I tested the code by a host and two clients.
In the first time, three players enter the game in sequence,
and all players can click each other and get correct health.
But when a client leaves the game and enter again, he can't click anyone anymore.
In other words, his click can't trigger the enable_click event.

I thinks it's because the new client can't get others' pointer,
so I have to resend all the entity pointers.
The problem is : How to resend pointer so that the new client can receive?
Can someone help me? Thanks very much.

My new code is as following :
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()
{
ent_you = me;
pan_show.visible = on;
}

function fun_ClickLocal()
{
if(connection == 2)
{
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
}
}



© 2024 lite-C Forums