1 registered members (AndrewAMD),
1,534
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
[ANET] Send playername into struct
#406785
08/29/12 18:10
08/29/12 18:10
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
OP
Serious User
|
OP
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
Hey guys! Im trying to set and send my playername to / from a struct:
typedef struct
{
...
STRING *name; //Playername
...
} CPlayer;
pPlayerArray[enet_get_clientid()].name = "player1";
enet_sendto(pPlayerArray[enet_get_clientid()].name, BROADCAST);
What doesnt work! I already tried:
enet_sendto(&(pPlayerArray[enet_get_clientid()].name), sizeof(STRING), BROADCAST);
Doesnt work either... Please help me
Last edited by Ch40zzC0d3r; 08/29/12 18:11.
|
|
|
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
Ch40zzC0d3r
OP
Serious User
|
OP
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
What about str_cpy(pPlayerArray[enet_get_clientid()].name,"player1"); ?? This gives me crash 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
Expert
|
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.
|
|
|
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
Ch40zzC0d3r
OP
Serious User
|
OP
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
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
Serious User
|
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
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
Ch40zzC0d3r
OP
Serious User
|
OP
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
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
Serious User
|
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
Ch40zzC0d3r
OP
Serious User
|
OP
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
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 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
panmin
Guest
|
Guest
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.
|
|
|
|