Strange RPC not behaving propaley.

Options
Ok so im making a fps game in unity using photon.
Is been running fine and every thing but I have recently run in to a issue that i cant seem to resolve.

I wanted to make some one get kicked from the server if they are idle for too long. this is because some of the people that I have given my game to to test have a tendincey to leave it running in the background. (most of them are just kids who want to try it)

I created my own kick function and it works perfictley (i have run several tests with it and it defentley works)
		[RPC]
		public void KickPlayer (string playerName, string kickReasion)
		{

				AddChatMsg ("Kicking player: " + playerName + kickReasion);
				if (playerName == PhotonNetwork.player.name) {
						inGame = false;
						PhotonNetwork.Disconnect ();
				}
		}


the problem is with kicking some one who is idle.
when the client runs the rpc to be kicked from the server Onley that client runs the rpc
the client still gets kicked from the photon network hence they disapear on evey ones screen BUT the chat message "AddChatMsg ("Kicking player: " + playerName + kickReasion);"
onley comes up on the the client that got kicked.

Here is the code that checks if some one is idle and then kicks them
		void IdleCheck ()
		{
				if (!Input.anyKeyDown) {
						idleTime -= Time.deltaTime;
				} else {
						idleTime = idleTimeReset;
				}

				if (idleTime < 0) {
						idleTime = idleTimeReset;
						GetComponent<PhotonView> ().RPC ("KickPlayer", PhotonTargets.All, PhotonNetwork.player.name, " Kicked for being idle");
				}
		}

any kind of rpc call that is run inside

if (idleTime < 0) {
}

does not work across the network. Ive tried calling lots of different rpc functions from in side there and none of them are being run across the network. they only get run on the client that called it.

if I run one out side that if statement it works fine. But of course that will not help because I need it to kick some one for being idle. and I would like to know why it dose not work too.

now i want to make it clear that the kick function WORKS I have tested it in Manny ways from using a button to having some one be kicked (hard coded) to things like being kicked because they shot something they should not have ect and the chat message comes up fine across every ones clients. its only this idle code that wont run across the network and I can not work out why.

anyway any help on finding out why rpcs are not being called across the network when run in that kind of if statement will be greatly appreciated.

Comments

  • vadim
    Options
    Try PhotonTargets.AllViaServer
    This should ensure that RPC goes before disconnection event.