Posted August 21, 201510 yr Basically what I am doing is that, I has some waypoints in which you can share with other people, the only thing is, is that if the person who shared the waypoint updates that waypoint, it will not change for anyone else who they have shared the waypoint with. So what I am wondering is what would be the best way to send an updated waypoint packet to everyone else who the waypoint is shared with.
August 21, 201510 yr have a list of all players that are receiving the waypoint and for(string pName : list) if(!pName.equals(editingplayer.name) sendmessage(msg, world.getplayer(pname); can't be copy pasted but you can use that structure to updated everyone you need to. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
August 22, 201510 yr Author Since I send the update message from the actual packet what would be the best thing to go with to send to players, a String array or a List of Strings since I am storing the name of players the waypoint has been shared with, also how would I send their data through the packet since I know you can send strings, but not string arrays or lists.
August 22, 201510 yr to write a string array do the following: write the size of the array to the buf. after that write each string to the buf. to read it. read the size of the array from the buff for(i=0; i<size;i++) read the string
August 22, 201510 yr Author the thing is is that I cannot use a string array since every time someone shares the waypoint with someone else it must add a player name to the list.
August 22, 201510 yr the thing is is that I cannot use a string array since every time someone shares the waypoint with someone else it must add a player name to the list. So assign a new array of the appropriate size or use a Collection such as Set or List. http://i.imgur.com/NdrFdld.png[/img]
August 22, 201510 yr Store your array of players that share a waypoint serverside and when any of them change the waypoint it sends the update to everyone on the list that isn't that player. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
August 23, 201510 yr Author the way my waypoints work is that there is two types of waypoints, just a normal "Waypoint", and then there is the "Shared Waypoint", the waypoint is what is created when a user creates a new waypoint, a shared waypoint is what a user receives from other users. The waypoint is editable, but the shared waypoint is not editable, meaning that only the user that shared the waypoint can edit it, and the users who have received that waypoint should get the edited version once the creator of the waypoint clicks the confirm edit button. I have up to the point so that it can send the update to a specified player, but I cannot figure out how to send it to all the players that are stored in a List of Strings (it is strings because it stores their usernames). I have the usernames stored in the list instead of an array since to add a new name to an array I would have to create a new array, but instead I can just add it to a list.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.