Calling Log Event Requests in RT Scripts

A LogEventRequest has attributes that don't work exactly like scriptData. You need a way to include the attribute data in the request. This tutorial provides an example that demonstrates how to include attribute data in a LogEventRequest.

LogChallengeEventRequests? The following applies equally to calling LogChallengeEventRequests from RT scripts.

For the example, we'll create an Event with two Attributes:


Realtime Availability? The Realtime feature is no longer available to games created on or after February 19th, 2019, or for games created before February 19th, 2019 that had not yet used the feature. If you require Realtime for your game and do not have access under your current plan, please contact us to discuss the Enterprise Pricing Tier.

Setting Event Attributes

Here's how we can set these Attributes for our log event:

var request = RTSession.newRequest()
        .createLogEventRequest()
        .setEventKey("event");
    request.settestvar("Hey this is a string");
    request.settestvar2({"key":"value"});
    request.setPlayerId(packet.getSender().getPlayerId())
        .send(function(response){
            RTSession.getLogger().debug(response);
        });

Understanding the JSON Constructor

Here are the main points for understanding the JSON constructor:

So, our above code block for setting the Event Attributes will be unpacked into the following JSON:

{"eventKey:"event",testvar:"Hey this is a string",{"testvar2":{"key":"value"}},"playerId":"playerId"};

Formatting Constraints

When using set in these sorts of case, the first character after an instance of set will always be rendered as lower case:

Did this page help you? Please enter your feedback below.