An addon script for parties between players, used to handle the data and events between members.
Party Data
Party data is stored in a GlobalState which can be accessed from any script server or client. Each party is identified via a unique partyId.
A player's current party id can be accessed via their state. If done locally, this can be done via LocalPlayer.state.party. This then can be used to access the party data via the following:
localpartyId=LocalPlayer.state.partylocalpartyData=GlobalState["Party:" ..partyId]print(partyData)-- Output:--{-- members = { 1 = true, 2 = true }, --A list of sources that are apart of the party.-- playerCount = 2, -- The amount of members in the party-- maxPlayers = 4, -- Max allowed players in the party-- type = "example", -- Type of the activity set in the creation-- data = {} -- Data stored by the party--}
If you'd like to access the same data via the server, you an use the state bags again.
localpartyId=Player(source).state.party
createActivityParty
This can be used to create a shareable activity and subsequent party data. Storing information like the host, activity type, members, invites and shared data. Once the activity has been created, the creator or "Host" is given a party radial menu option to invite leave the party.
Below is an example from the sanitation job
inviteToParty
While this won't be used often due to the radial menu option, it can be handy to forcibly invite members
removePlayerFromParty
Forcibly remove a player from a party.
endActivityParty
End the party activity
setPartyData
Update data connected to the party's global state.
resetPartyData
This can only be called via exports
Reset a parties data back to data provided.
triggerPartyEvent
Triggers a client event for all players within the party and with supplied arguments
triggerPartyNotif
Sends a notification to all the party members
Reffer to TMC.Functions.SimpleNotify for argument options
This event does not support the duration argument.
Dev Commands
/fakeinvite
If you wish to test the invitation system, you can use this to force the invited status.
/testparty
If you'd like to force yourself into a test party - default activity name "A test activity".
-- source: player to remove (not required if called via event)
-- activityName: Name of the activity (shows on invite notifications)
-- activityType: Type of activity, used for script reference if required
-- maxPlayers: Max members allowed within the party (defaults to 4 if not set)
-- initialData: Inital data to be stored wihtin the party, used for script syncing (defaults to {} if not set)
TMC.Functions.TriggerServerEvent("parties:server:createActivityParty", activityName, activityType, maxPlayers, initialData)
-- source: player to remove (not required if called via event)
-- targetId: Target to add into the party.
TMC.Functions.TriggerServerEvent("parties:server:inviteToParty", targetId)
-- source: player to remove (not required if called via event)
-- partyId: Id of party to remove from
TMC.Functions.TriggerServerEvent("parties:server:removePlayerFromParty", partyId)
-- source: player linked to the party (not required if called via event)
-- partyId: Id of party to remove from
TMC.Functions.TriggerServerEvent("parties:server:endActivityParty", partyId)
-- partyId: party id to apply the data to (not required if called via event)
-- dataKey: key within the party's data strucutre to set the data
-- dataValue: value which will be placed at the dataKey within the party data
TMC.Functions.TriggerServerEvent("parties:server:setPartyData", dataKey, dataValue)
-- partyId: party to target
-- initalData: data that should be forceibly updated to
exports.parties:resetPartyData(partyId, initalData)
-- partyId: party to target (not required in server event)
-- event: event name to be triggered
-- arguments...: arguments
TMC.Functions.TriggerServerEvent("parties:server:triggerPartyEvent", event, argumnets...)
-- partyId: party to target (not required in server event)
-- text: content for the notification
-- type: type of notification
TMC.Functions.TriggerServerEvent("parties:server:triggerPartyNotif", text, type)