Segments API
Integration of segments through SDK. Methods of operation.
List of methods
Properties:
ss.segments.list
- list of segments. FREE
Checks:
ss.segments.has()
- check if the player is in the segment. FREE
Events:
ss.segments.on('enter')
- subscribe to the moment of entering a segment.ss.segments.on('leave')
- subscribe to the moment of leaving a segment.
Properties
List of segments
FREEYou have access to the entire list of segments at once when the game starts and the player loads, in the format of a string array.
- JavaScript
- Unity
ss.segments.list;
SS_Segments.List()
Example content:
['HAS_PAYMENTS', 'VIP', 'NEWBLE', 'VERY_ACTIVE'];
Checks
Segment check
ss.segments.has(tag)
FREE
- JavaScript
- Unity
// By Tag
const hasPayments = ss.segments.has('HAS_PAYMENTS');
// Check
if (hasPayments) {
// Player is in the HAS_PAYMENTS segment
}
// By Tag
bool hasPayments = SS_Segments.Has('HAS_PAYMENTS');
// Check
if (hasPayments) {
// Player is in the HAS_PAYMENTS segment
}
Events
Enter segment
The callback returns the segment tag as a string:
- JavaScript
- Unity
ss.segments.on('enter', (segmentTag) => {
// player entered the segment
});
// Subscribe to event
private void OnEnable()
{
SS_Segments.OnSegmentEnter += OnEnter;
}
// Unsubscribe from event
private void OnDisable()
{
SS_Segments.OnSegmentEnter -= OnEnter;
}
// Player enter segment
public void OnEnter(string tag)
{
ConsoleUI.Instance.Log("Enter segment: " + tag);
}
Leave segment
The callback returns the segment tag as a string:
- JavaScript
- Unity
ss.segments.on('leave', (segmentTag) => {
// player left the segment
});
// Subscribe to event
private void OnEnable()
{
SS_Segments.OnSegmentLeave += OnLeave;
}
// Unsubscribe from event
private void OnDisable()
{
SS_Segments.OnSegmentLeave -= OnLeave;
}
// Player leave segment
public void OnLeave(string tag)
{
ConsoleUI.Instance.Log("Leave segment: " + tag);
}
Stay in Touch
Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.
SpellSync Community Telegram
: @spellsync.
For your suggestions e-mail
: [email protected]
We Wish you Success!