Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 838 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Server > Unique Client - [Help] #222317
08/18/08 20:41
08/18/08 20:41
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline OP
Serious User
indiGLOW  Offline OP
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
I am having some difficulty using 'SEND_STRING_TO', mostly it appears to be establishing correct pointers/handles when entities are created. i.e player1 = client1, player2 = client2, etc...

I am trying to create a server side array of all currently connected players, pointers to each players master entity, and use this to send strings to individual clients.

Setting up this part of MP is really busting my brain, and after 2 weeks of trying to crack it, I am out of ideas...

Please could someone demonstrate how I create an entity on a client & server using ent_create, and then send messages to that client specifically from the server; Without the message going to all clients.

I believe SEND_STRING_TO(entpointer, stringtosend) should do the trick, but I just can't seem to get entpointer correct.

Any help, even examples of code would be really helpful. TIA

note: Running A6 Pro.


The Art of Conversation is dead : Discuss
Re: Server > Unique Client - [Help] [Re: indiGLOW] #222325
08/18/08 21:15
08/18/08 21:15
Joined: Nov 2002
Posts: 913
Berlin, Germany
S
SchokoKeks Offline
User
SchokoKeks  Offline
User
S

Joined: Nov 2002
Posts: 913
Berlin, Germany
here is the code I used. note that I'm not using an array, as there are 4 players max. and I'm not actually using send_xx_to, all clients get the same data in my system. too complicated otherwise..

Code:

define plid, skill1;

// on client:

	local_pl = ent_create ("dummy.mdl", vector (0,0,-5000), plent_act);
	sleep (2); // sleep time can be shorter, but in my game updates are only send every 2 seconds.
	while (local_pl.plid == 0) {wait (1);}
	local_faction = local_pl.plid;

[...]

// on server
function plent_event()
{
	if (EVENT_TYPE == EVENT_DISCONNECT)
	{
		ent_remove (me);
	}
}

function plent_act()
{
	my.enable_disconnect = 1;
	my.event = plent_event;

	if (pl1 == null) {my.plid = 1; pl1 = me; goto plent_slotsdone;}
	if (pl2 == null) {my.plid = 2; pl2 = me; goto plent_slotsdone;}
	if (pl3 == null) {my.plid = 3; pl3 = me; goto plent_slotsdone;}
	if (pl4 == null) {my.plid = 4; pl4 = me; goto plent_slotsdone;}
	diag ("\n all slots full?!");

	plent_slotsdone:

	sleep (2);
	send_skill (my.plid, null);
}




Re: Server > Unique Client - [Help] [Re: SchokoKeks] #222329
08/18/08 21:28
08/18/08 21:28
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline OP
Serious User
indiGLOW  Offline OP
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
Thanks for the incredibly fast response smile

I am still not clear how you identify ClientA over ClientB.

when the client runs an ent_create(etc, etc, etc); how do I establish pointers on both the server and all clients?

I presume pl1, pl2 etc, are entity* definitions. How do you ensure that the pointers are correct for server and clients?

Thanks for the help, it's much appreciated. If it helps I can post my code?


The Art of Conversation is dead : Discuss
Re: Server > Unique Client - [Help] [Re: indiGLOW] #222371
08/19/08 02:16
08/19/08 02:16
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
the only way i managed to achieve this was by sending a string to all clients and then from that string working out if it was intended for them and responding as needed else just ignoring it

there're new commands added in A7 (no use to you i know) but i think that they highlight some of the required events and commands in a6 don't exist
send_string (STRING*)
send_string_to (ENTITY*, STRING*)
send_string_id (var client_id, STRING*)

hope this helps somewhat...

Re: Server > Unique Client - [Help] [Re: MrGuest] #222390
08/19/08 03:41
08/19/08 03:41
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Assign ID to all clients on server...
Example : number_of_cl += 1; my.id = number_of_cl
Use str_ functions and execute to assign a pointer with that ID to that entity and wait 1 second. Send the ID.
Client side , start a function that loops endlessly. In this function , go thru the list of entities , and if the current entity ID pointer is assigned , do nothing. Otherwise , assign it to that entity , again with str_ functions and execute.

If you dont understand it smile read it again...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Server > Unique Client - [Help] [Re: EpsiloN] #222403
08/19/08 07:35
08/19/08 07:35
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Quote:

I am still not clear how you identify ClientA over ClientB.


Epsilon gave a great answer! I would add that A7 has a client_id that may accomplish the same thing. cool

Re: Server > Unique Client - [Help] [Re: fastlane69] #222510
08/19/08 18:14
08/19/08 18:14
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline OP
Serious User
indiGLOW  Offline OP
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
Thanks Epsolon, this may well make a great deal more sense, and allow me to get closer. The honest truth is a feel that I have created pointers as you describe, the trick is how I should reference them from the server to SEND_STRING_TO.

I've noticed several functions including things such as:

SEND_SKILL(EntityPointer.Skillx, "String to send"); where .Skillx is maybe a handle pointer to the entity?

Where as my use:
SEND_STRING_TO(EntityPointer, "String to send");

Doesn't seem to work. Now either my 'EntityPointer' is incorrect, or indeed my use of the function is incorrect. I've used ent_next to search through all entities, ensuring that a client entity with some unique identifier, such as ._client flag and playerID == n, but when I send string to this ent, I get nothing on the client.

IS it a case that I use SEND_STRING("String to Send") where "String to Send" includes text references that the Client then sorts through to see if the message was intended for it? i.e on recieving string from server, check if the message was for me? Compare my ID to the reference in the string?

I will refine my test code and post here, maybe you will be able to help me get my thick head around it. This should not be this hard smile

Thanks for the assistance both, your patience is exemplary grin

@MrGuest: Yes it always seems the function you need is better delivered in the next version smile There's always a next version...

Last edited by indiGLOW; 08/19/08 21:46. Reason: MrGuest Comment

The Art of Conversation is dead : Discuss
Re: Server > Unique Client - [Help] [Re: indiGLOW] #222600
08/20/08 03:57
08/20/08 03:57
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
fastlane69 , thats from my attempt at MMO wink

I think , for sending strings , you need to actualy put a string pointer there...I mean , player_name_str for example...to be predefined in your script. Otherwise the client wont know in wich string to save that text :P
Btw , I used and needed IDs only for the updating. When a client receives an array with updates , it updates the entity with the ID stored in the first variable...
Another 'ent type' skill identifies players and dummy entities or other objects...Thats how I know wich one is a player.


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Server > Unique Client - [Help] [Re: EpsiloN] #222713
08/20/08 16:37
08/20/08 16:37
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Quote:
fastlane69 , thats from my attempt at MMO


Dude, I do the exact same thing in my MMO since it pre-dates client_ID. cool

Re: Server > Unique Client - [Help] [Re: fastlane69] #222732
08/20/08 19:04
08/20/08 19:04
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline OP
Serious User
indiGLOW  Offline OP
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
Ok so I am still not getting this...so


1.Server starts up (all is calm)
2.Client Joins Server (Server Event! new Client)
3.Server sends everyone available player ID number
4.Client without ID assigns this as its identification number

some time later...

5.Server wants to send message to the client who got the ID
6.Server checks all entities until entity with correct ID is selected
7.Server sends message to that entity
8.Client that created the entity, gets a message???

I'm trying to understand the 'hand-shake' that goes on in order for the server to identify this client.

I will ensure my code follows this process (unless corrected) and see what happens. I'm still expecting the SEND_STRING_TO to not work. I hope I am wrong smile


The Art of Conversation is dead : Discuss
Page 1 of 3 1 2 3

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1