I'm developing a game.app that shows the state of some objects by color (e.g state 1 = green, 2 = yellow etc...). The users are asked to make some choices on some objects and when they are finished they have to check a field. As soon as the last user finish the round a global method is fired to update the objects in the game. After that I try to fire another method to update the colors for every user and sends a message that they can begin with the second round.
I tried to do the last with the UserManager plugin, but when we tested the game the interface was updated only in the last user (the one who fires the method) and he got also 4 times the message instead of one.
- Code: Select all
//if all players are finished
if (datasetarrayU.getMaxRowIndex() == 4)
{
var serverName = databaseManager.getDataSourceServerName(forms.game_objects1.controller.getDataSource());
var noyears = forms.game_settings.set_no_years;
//updates the objects
globals.markovCode(serverName,noyears);
//updates the game and send a message to every user
// Returns all clients an execute the script
var vClients = plugins.UserManager.getClients()
var len = vClients.length
for (var i = 1; i<=len; i++)
{
var clientID = vClients[0].clientId
application.output(clientID);
var client = plugins.UserManager.getClientByUID(clientID)
client.executeMethod(globals.updateClients);
client.sendMessage('please start a new round.')
}
}
else
{
var title = "";
var message = i18n.getI18NMessage('i18n:ssg.not.all.players.finished');
var btn1 = i18n.getI18NMessage('i18n:ssg.ok');
plugins.dialogs.showInfoDialog(title, message, btn1);
}
Do I miss something in my code or is this not the right way?