dplay_id BUG?

Posted By: fabiomartins

dplay_id BUG? - 10/17/13 06:08

dplay_id
The unique identification number of a client. The number is sent to the client from the server after joining. On a server, it's always 0. A7.7


I tested the dplay_id variable on "Pong Multiplayer"
the value is always "9999" after joining ....

unique identification number of a client?
Posted By: Uhrwerk

Re: dplay_id BUG? - 10/17/13 07:24

And what happens if a second client joins?
Posted By: Superku

Re: dplay_id BUG? - 10/17/13 11:37

dplay_id works fine without any error or bug, I've used it for 10+ multiplayer projects.
I assume you are just displaying it incorrectly, for instance with a %4.0f or integer format. How do you know it's 9999?
Posted By: fabiomartins

Re: dplay_id BUG? - 10/17/13 16:36

I,m using this:

var meuid ;

PANEL* mostra ={layer = 55; digits(20, 60, 4 ,Arial#24bi, 1, meuid); flags = SHOW;}

....................

function on_server_event(var* received,var id)
{ if (EVENT_JOIN == event_type){ meuid = id; }


So Panel displays 9999 smirk
Posted By: Ch40zzC0d3r

Re: dplay_id BUG? - 10/17/13 16:43

what about
error(str_for_num(NULL, id));
Posted By: Superku

Re: dplay_id BUG? - 10/17/13 16:43

digits(20, 60, 4 ,Arial#24bi, 1, meuid);
-> 4 digits, and you complain that you cannot see more than 4 digits. wink
Posted By: fabiomartins

Re: dplay_id BUG? - 10/17/13 17:07

now using 12 digits:

digits(20, 60, 12 ,Arial#24bi, 1, meuid);

always displays 65536 now
Posted By: Superku

Re: dplay_id BUG? - 10/17/13 17:17

dplay_ids oftentimes only show a difference in the fraction. However, this is irrelevant, the feature works.
Posted By: fabiomartins

Re: dplay_id BUG? - 10/17/13 17:23

using double shows correctly a random number in dplay_id:

double meuid ;
var mostrar;
PANEL* mostra ={layer = 55; digits(20, 60, 30 ,Arial#24bi, 1, meuid); flags = SHOW;}
Posted By: Superku

Re: dplay_id BUG? - 10/17/13 17:28

Don't use doubles or the like for multiplayer code with lite-C, all functions and features (such as client_id) only expect or are vars and thus only guaranteed to work with those.

Writing for instance 10.3 in the digits field would give you 3 decimal places while using vars, too.
Posted By: fabiomartins

Re: dplay_id BUG? - 10/17/13 19:33

running two or more instances on same machine...
Ex. 1 server and one o more clients on same machine, the dplay_id will be the same...

corretly?






Posted By: Superku

Re: dplay_id BUG? - 10/17/13 19:40

Check out this article & code: http://opserver.de/nwik5/index.php?title=Multiplayer
Posted By: Ch40zzC0d3r

Re: dplay_id BUG? - 10/17/13 21:58

The Server will manage the ids and send them to the clients...
It will start with 0 as usual for the server and 1+ for the clients.
Server: 0 <- started a new empty server
Client: 1 <- a client connected
Client: 2 <- a second client connected
...

Not very hard, IDK wheres your actual problem.
I would also suggest to use ANet, I simply love it tongue
Posted By: Superku

Re: dplay_id BUG? - 10/17/13 22:13

That's not how dplay_id works, though. (It seems to use the server's system time instead or something like that.)
Posted By: fabiomartins

Re: dplay_id BUG? - 10/18/13 17:53

Iīm understanding
I can show the dplay_id corretly in the screen with:
var test

main loop....
draw_text(str_printf(NULL,"bps: %.0f",(double)dplay_id),20,40,COLOR_WHITE);

But, I canīt get put this inside a variable... ;(
Posted By: Ch40zzC0d3r

Re: dplay_id BUG? - 10/18/13 18:20

What the hell are you doing xD
Its simply a var no double or float <_<
© 2024 lite-C Forums