Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,388 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: [ANET] Send coordinates? [Re: Dark_samurai] #351848
12/28/10 21:29
12/28/10 21:29
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
@Dark_Samurai

I already thought about that, and i think i will do it like that. Would that cost less traffic?

---

Ok i got a new problem. Everything is working fine. I´m receiving the pointer "id" and can give the you pointer to the entity. enet_ent_remove works fine. But if i try to change the health (skill20) of the entity i get an error msg.

Code:
you = entity_pointer;
you.health -= 120;



"Crash in svevent_dmg: SYS"

I´m not really sure but shouldnt that work? Cause this function only runs on the server who creates the entitys. The server should be able to change the health value, or not?

Re: [ANET] Send coordinates? [Re: Rasch] #351850
12/28/10 21:50
12/28/10 21:50
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Quote:
I already thought about that, and i think i will do it like that. Would that cost less traffic?


You can count the required traffic by looking into the manual. Every function has informations about the produced traffic. It should be easy to calculate.
But sometimes it's better to use a technic that requires a bit more traffic and have a cleaner code instead.

Code:
you = entity_pointer;
you.health -= 120;



Ok you misunderstood how the global pointers work. All global entities are listed in an array. So if enet_ent_create() is called, every host performs a normal ent_create() and stores the local pointer in this array. All hosts store it at the same position in the array (so the index to access the local pointer is the same on every host).

And this array index is the global pointer. It's nothing more than a number.

=> you = entity_pointer; would make no sence. You need to get the local pointer according to the global pointer. => use enet_get_locpointer(entity_pointer); This function returns the content of the array on the position entity_pointer. The result is different on every host but on every host the same entity is ment.

enet_get_globpointer() searches for an entry in the array with the passed local pointer and returns the index/position where the local pointer is stored in the array.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [ANET] Send coordinates? [Re: Dark_samurai] #351852
12/28/10 22:19
12/28/10 22:19
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Ok i think i got it. Now it works very well.

Great just great. Thanks to you both for your help. Very kind grin

BTW: ANet is great. wink

Re: [ANET] Send coordinates? [Re: Rasch] #351862
12/28/10 23:42
12/28/10 23:42
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline
Serious User
Rackscha  Offline
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
No problem laugh

And yes its great, just updated to Professional^^

Greetings
Rackscha


MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: [ANET] Send coordinates? [Re: Rackscha] #351913
12/29/10 15:06
12/29/10 15:06
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Hello again. I´m back very soon with another problem. But the same thing ^^

Thanks to you i know how to send variable arrays and entity pointers. Now i´m trying to send an String Array and what happens? Right! ..nothing grin

What i want is to send my TEXT* object... or better the strings from it.

The definiton:

Code:
TEXT* playerlist =	
{
	pos_x = 560;
	pos_y = 25;
	font = "Arial#16b"; 
	strings = 6;
	flags = SHOW;
}



That works really great so far. But now i need to know how to send this. Whenever a new client joins, i´m doing a namecheck to avoid double names. If everything is correct i´m copying the name into the text string with his id.

Code:
str_cpy((playerlist.pstring)[id], namelog);



Now the server is fine. Next i want to send the whole playerlist to all clients to refresh the names. I tried it with send_array but nothing happens.

Code:
enet_send_array("playerlist",0,5,BROADCAST);



Then i tried it with an event.

Code:
enet_svsend_event(16, playerlist, sizeof(playerlist)+4, BROADCAST);



After trying with different "get" methods in the receive function i everytime get wrong characters. Even if i´m creating String Array or char array, copying the playerlist into those.

numbers are no problems anymore i think. But Strings... please help grin

THank you very much

Re: [ANET] Send coordinates? [Re: Rasch] #351918
12/29/10 15:24
12/29/10 15:24
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
You could use the built in Player strings for that. Then you can avoid your problem. Look into the manual under player functions.

To your problem: your enet_send_array() and enet_svsend_event() calls don't work because a TEXT element is not natively supported. You have to send the content of the String array:

var size = 2*sizeof(string) + str_len((playerlist.pstring)[0]) + str_len((playerlist.pstring)[1]);
enet_send_data(&((playerlist.pstring)[0]), size, BROADCAST);

This is only a guess, I'm not sure if this would work!


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [ANET] Send coordinates? [Re: Dark_samurai] #351921
12/29/10 15:48
12/29/10 15:48
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Ok i did it with the playerstrings. That works very well. Thanks laugh

Page 2 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | 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