Help-me PhotonMessageInfo State = Null
Options
TyHover
✭
Hello everyone, I want to update the active (PUN) for a current version and some errors appear for someone to take a look at my script below:
error CS1502: The best overloaded method match for `ChatDemo.AddChatMessage(string, PhotonMessageInfo)' has some invalid arguments
error CS1503: Argument `#2' cannot convert `null' expression to type `PhotonMessageInfo'
protected virtual void Send() { if (!string.IsNullOrEmpty(m_InputLine)) { if (MessageOK(-1, m_InputLine)) AddMessage(m_InputLine); else { switch(FilterMode) { case MessageFilterBehavior.Alert: PlaySound(m_Chat.ChatErrorSound); break; case MessageFilterBehavior.Silent: AddChatMessage(GetFormattedPlayerName(PhotonNetwork.player.ID) + m_InputLine, null); PlaySound(m_Chat.ChatSound); break; } } SnapToBottom(); } m_InputLine = ""; GUI.FocusControl(""); ShowTextInput(false); }
LINE ERROR:
AddChatMessage(GetFormattedPlayerName(PhotonNetwork.player.ID) + m_InputLine, null);
For Script:
[PunRPC] void AddChatMessage(string message, PhotonMessageInfo info) { if (info.sender != null) { ............. } }
0
Comments
-
help0
-
I don't have a lot of experience with the chat system yet, but if this is just a typical PunRPC call, I don't think you would pass 'null' into the function. PhotonMessageInfo is automatically passed.
Here's an example of my AutoAttack RPC:_photonView.RPC("AutoAttack", PhotonTargets.AllViaServer, _target.GetComponent<PhotonView>().viewID);
Here, I'm basically saying, tell everyone in the room, to call their AutoAttack function on this view and I'm giving it 'my' target photon view ID as the parameter. In my AutoAttack function, I'm using the PhotonMessageInfo to figure out who sent it, and what to do.
So just guessing, you would probably callphotonView.RPC("AddChatMessage", [target], GetFormattedPlayerName(PhotonNetwork.player.ID) + m_InputLine);
[target] is either a specific PhotonPlayer, or else a PhotonsTarget (enum).
Hope that helps.0