Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
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
1 registered members (AndrewAMD), 1,534 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[ANET] Send playername into struct #406785
08/29/12 18:10
08/29/12 18:10
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline OP
Serious User
Ch40zzC0d3r  Offline OP
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Hey guys!
Im trying to set and send my playername to / from a struct:
Code:
typedef struct
{
...
	STRING *name; 		//Playername
...
} CPlayer;



Code:
pPlayerArray[enet_get_clientid()].name = "player1";
enet_sendto(pPlayerArray[enet_get_clientid()].name, BROADCAST);



What doesnt work!

I already tried:
Code:
enet_sendto(&(pPlayerArray[enet_get_clientid()].name), sizeof(STRING), BROADCAST);



Doesnt work either...
Please help me frown

Last edited by Ch40zzC0d3r; 08/29/12 18:11.
Re: [ANET] Send playername into struct [Re: Ch40zzC0d3r] #406787
08/29/12 18:19
08/29/12 18:19
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
What about str_cpy(pPlayerArray[enet_get_clientid()].name,"player1"); ??


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: [ANET] Send playername into struct [Re: alibaba] #406788
08/29/12 18:21
08/29/12 18:21
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline OP
Serious User
Ch40zzC0d3r  Offline OP
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Originally Posted By: alibaba
What about str_cpy(pPlayerArray[enet_get_clientid()].name,"player1"); ??


This gives me crash smirk
Also, the problem is sending, not writing.

Re: [ANET] Send playername into struct [Re: Ch40zzC0d3r] #406789
08/29/12 18:55
08/29/12 18:55
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Have you created a String? with str_create.
btw if your string is invalid, sending wont be possible.

Last edited by alibaba; 08/29/12 18:56.

Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: [ANET] Send playername into struct [Re: alibaba] #406800
08/30/12 04:41
08/30/12 04:41
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline OP
Serious User
Ch40zzC0d3r  Offline OP
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Originally Posted By: alibaba
Have you created a String? with str_create.
btw if your string is invalid, sending wont be possible.


I tried the str_create method and its working fine on client.
But on server when I send the string, its empty...

EDIT: Fixed it, just used a char array!

Last edited by Ch40zzC0d3r; 08/30/12 04:54.
Re: [ANET] Send playername into struct [Re: Ch40zzC0d3r] #406825
08/30/12 14:30
08/30/12 14:30
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:
EDIT: Fixed it, just used a char array!


That's exactly the point! Using a STRING* won't work because a STRING* is nothing more than a pointer to a local memory address. If you send this pointer, you only sand the memory address (which is not valid on other computers!) and not the content of the string!


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 playername into struct [Re: Dark_samurai] #406828
08/30/12 16:30
08/30/12 16:30
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline OP
Serious User
Ch40zzC0d3r  Offline OP
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Originally Posted By: Dark_samurai
Quote:
EDIT: Fixed it, just used a char array!


That's exactly the point! Using a STRING* won't work because a STRING* is nothing more than a pointer to a local memory address. If you send this pointer, you only sand the memory address (which is not valid on other computers!) and not the content of the string!


So when I have ENTITY* I cant send it too?
I mean I need to make ENTITY[1] then?

EDIT: Also, can I save the name of my player into a skill and send it?

Last edited by Ch40zzC0d3r; 08/30/12 17:04.
Re: [ANET] Send playername into struct [Re: Ch40zzC0d3r] #406893
09/01/12 00:43
09/01/12 00:43
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
For entities you can use enet_clent_create()/enet_svent_create(). It generates a global pointer that can be used on all participants. For more details, read the manual section regarding entity functions.

Why don't you use enet_set_playername() for managing the player name?

To say it in general: All pointers that are generated by Lite-C are invalid on a different participant!


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 playername into struct [Re: Dark_samurai] #406895
09/01/12 07:24
09/01/12 07:24
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline OP
Serious User
Ch40zzC0d3r  Offline OP
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Originally Posted By: Dark_samurai
For entities you can use enet_clent_create()/enet_svent_create(). It generates a global pointer that can be used on all participants. For more details, read the manual section regarding entity functions.

Why don't you use enet_set_playername() for managing the player name?

To say it in general: All pointers that are generated by Lite-C are invalid on a different participant!


Thank you! Got all to work now laugh
And to your question why I dont use the anet func for playernames:

Because in the playerdisconnect event (which I use as timed out event) the client isnt valid anymore, but I need to say who timed out.

Re: [ANET] Send playername into struct [Re: Ch40zzC0d3r] #413390
12/13/12 06:22
12/13/12 06:22
Joined: Dec 2012
Posts: 3
P
panmin Offline
Guest
panmin  Offline
Guest
P

Joined: Dec 2012
Posts: 3
The article brings us Buy MapleStory Mesos is heart shock! Your article is its; Your article is propaganda team; Your article is drill; The article brings MapleStory Gold the reader's joy and prosperity of the BBS.


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