Currently, a game I am reworking is intended to have a party system and I would like to ask about the preservation of parties. I have not really tried anything myself yet, but I need to gain an understanding about the approach I have in mind or any suggestions on how to do so.
A party system is defined as a group of players that can work collaboratively on a game. This includes mutual alliances (unable to damage each other), location markers, distribution of benefits (i.e. dungeon quests) and so-on; co-operative play, to be short and concise. A party is often started with a leader who holds administrative permissions over this party; disbanding, removing, inviting and other configuration factors.
My current party system paradigm shouldn’t require any editing necessarily. I will be having my parties contained within modules which will indicate parties as data. As far as handling in-server parties, I should be fine. I don’t account for any special circumstances (such as disconnections) or any storage of parties. The only thing I haven’t a clue of what I am to do is how to preserve those parties if players are teleported only - any other circumstance should remove parties (or in the leader’s case, disband it). I also need to be able to account for players who did not make it from the teleport.
The current idea I have in mind is to use the JobId of the target server as a key for a DataStore of parties, whether that’s of a scope of an existing DataStore or a separate one altogether. The value of this would be the members of the party and any additional data.
local TeleportService = game:GetService("TeleportService")
local DataStoreService = game:GetService("DataStoreService")
-- ...
local PartyDataStorage = DataStoreService:GetDataStore("Parties")
local PartyMembers = {} -- In here is a table of Player objects representing the party
local success, TargetJobId = pcall(TeleportService.TeleportPartyAsync, TeleportService, 0, PartyMembers, PartyData, nil) -- PartyData exists elsewhere
if success then
DataStoreService:SetAsync(TargetJobId, value) -- Haven't determined what value will be
end
My worries with this approach and similar approaches are as follows:
- DataStores are only meant for communicative reasons. Everything stored here is throwaway. I’m wasting value budgets on throwaway requests.
- I cannot guarantee that MessagingService will quell my worries when it goes live, though it might somewhat be able to handle processing of groups post-teleport. MessagingService is more for cross-server communication over sending data - the data should only work its magic after all players are done or after a certain time has passed.
- I can already foresee this posing problems as I typed it. I’m saving the JobId of the server. Multiple parties can go to a single JobId. This will obviously destroy my code later down the line.
- There does not exist a server-side method for checking when a player arrived from a teleport explicitly, only for when they joined the server at all. This presents me with a race condition of trying to determine who came from a teleport and who did not.
I have thought about using the leader’s UserId and the JobId together as determinants for storage keys or TeleportService settings while using party data and members, but they’re all mostly ugly workarounds that I feel are not appropriate. There’s also the potential edge case of a failed teleport wherein my server wouldn’t know what to do with the data it has or it’d just keep it stored without ever touching it again.
Worst case scenario, I can’t “preserve” parties or I overcomplicate my situation, I throw the system out and instead make a “trusted players” list, A fairly simple system to make in which should not pose me many or any problems at all.
The list of players that a player trusts carries through servers and places but does not save on a whole. Mutual trust establishes an alliance, while one-sided or non-set trust does not create an alliance. This can also allow me to white list groups as automatic trust between members, in case I support factions for the game. Factions aren’t the hugest thing on my mind though: getting the party system down is.
This new system wouldn’t necessarily achieve my original goal, though the importance of a party-esque system to my game is of fairly high priority for game play purposes (and as per the expectations of the person employing me).