When both players entered the game scene, they send message to server, confirming to start the game. Server begin to create data as soon as it gets messages from both players.
3. Data generated in real time script. As soon as data
generated, real time script create request .createLogEventRequest().setEventKey("SET_MD") and
send generated data to SET_MD
//Real Time script
function getMatchDetails(){
generateBattleStatistics(matchData);
if(!isUseSkill)
{
RTSession.setTimeout(getMatchDetails, 20000);
}
}
function generateBattleStatistics(matchData){
var rtData = RTSession.newData().setString(1, "asfasf");
RTSession.newPacket().setOpCode(7).setData(rtData).send();
var participantData = [];
for(var i = 0; i < RTSession.getPlayers().length; i++)
{
participantData.push({
heals: Math.round(matchData.participants[i].endurance * 200),
damage: matchData.participants[i].strength * 10,
mana: matchData.participants[i].intellect * 20,
blockPoint: getRandomPoint(0,3),
attackPoint: getRandomPoint(0,3)
});
}
var request = RTSession.newRequest()
.createLogEventRequest()
.setEventKey("SET_MD");
request.setmid(matchID);
request.setpdata(participantData);
request.setPlayerId(playerID)
.send(function(response){
if (!response.error) {
RTSession.getLogger().debug(response);
sendStatistics();
} else {
RTSession.getLogger().debug(response.error);
}
});
}
4. Script SET_MD get data from createLogEventRequest()
// Event script "SET_MD"
var matchID = Spark.getData().mid;
var scriptMatchData = null;
var participantsData = Spark.getData().pdata;
var matchParticipants = null;
Spark.getLog().debug(matchID);
var request = new SparkRequests.MatchDetailsRequest();
request.matchId = matchID;
request.realtimeEnabled = true;
var response = request.Send();
Spark.getLog().debug(participantsData);
scriptMatchData = response.matchData;
5. After that I'm trying to find a match and rewrite match’s data.
6. After rewriting, server send message to
players that they can take new data and use it in game.
//Real Time script
function sendStatistics() {
var rtDataToSend = RTSession.newData().setString(1, "true");
RTSession.newPacket().setOpCode(5).setData(rtDataToSend).send();
}
However, in reality data is notoverwriten properly. I have three possible
outcomes.
1. Data is not overwriten for both players.
2. Data is overwriten for one player.
3. Data successfully overwriten for both
players.
I tried to check code in Test Harness and it
is working correctly.
Could you please help me to solve this
problem. I need it to be overwriten for
both players.
Thanksinadvance
1 Comment
Customer Support
said
over 5 years ago
Hi Vitaly,
I can see that an agent is looking into this issue for you in the ticketing system. We are awaiting your response there.
Vitaly Evtukh
Good day.
I have an issue with overwriting data. It is not overwriting correclty and I cannot understand why it happens.
I will try to explain in steps:
1. At first I do create match between 2 players. As soon as match created, method OnMatchFoundMessage create data for that match.
2. After that, players get connected to the session. As soon as both payers connected, server send them message to allow to enter game scene.
When both players entered the game scene, they send message to server, confirming to start the game. Server begin to create data as soon as it gets messages from both players.
3. Data generated in real time script. As soon as data generated, real time script create request .createLogEventRequest().setEventKey("SET_MD") and send generated data to SET_MD
4. Script SET_MD get data from createLogEventRequest()
5. After that I'm trying to find a match and rewrite match’s data.
6. After rewriting, server send message to players that they can take new data and use it in game.
However, in reality data is not overwriten properly. I have three possible outcomes.
1. Data is not overwriten for both players.
2. Data is overwriten for one player.
3. Data successfully overwriten for both players.
I tried to check code in Test Harness and it is working correctly.
Could you please help me to solve this problem. I need it to be overwriten for both players.
Thanks in advance