- Home /
Trying to send command for non-local player.
im trying to make it so that when a user clicks an inventory button on his client it opens sends a request to the server to get what items he has in his inventory (so server authoritative) however when i do it i get this message "Trying to send command for non-local player.".
Here is a sample code with the exact same logic:
//the players temp id...
int playerId = 1;
//this method is fired when a user presses a button on his UI.
public void RequestInventory() {
CmdRequestInventory (playerId);
}
//the server request to get the inventory
[Command]
void CmdRequestInventory(int _playerId) {
Debug.Log ("cmd");
RpcReceivedInventory ("1, 2, 3, 4");
}
//the client callback once the items are received.
[ClientRpc]
void RpcReceivedInventory(string items) {
Debug.Log ("we have the inventory..");
Debug.Log ("items: " + items.ToString());
}
Comment
Your answer
Follow this Question
Related Questions
Close UI using Canvas Group 1 Answer
On collision nearby objects ui view (scroll view) 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Help with GUILayout and tooltip(C#) 1 Answer