- Home /
Make priority for players
Hi; I'm developing an online board game. In the game there is a dice button that when a player clicks it the s/he throws dice. Now I want to implement a function so it gives priority to the players so each player each time can clicks this button once. And s/he should wait until her turn comes again. Any ideas how to do this?
Any ideas will be appreciated. thanks
Answer by Posly · Jan 15, 2012 at 04:45 PM
I'd use something like a counter, you add one to the counter everytime the player clicks the button, and when the counter reaches it's max number, lets say 5, it subtracts 5 and starts the cycle all over again. Here's an example:
var counter : int = 0;
function Update (){
if(counter = 0)
{
"now it's player one's turn"
}
if(counter = 1)
{
"now it's players two's turn"
}
if(counter = 2)
{
"now it's player three's turn"
}
if("the dice is rolled")
{
counter += 1;
}
if(counter == 2)
{
counter -= 2;
}
}
alright I hope this helps!
There is another problem now. This works fine with the server, but it looks like that the client doesn't get the updates counter, so the never could throw dice, and server can throw dice just once. Do you have any ideas how to fix it?