Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Player Chat + Kicking Players From Room

Discussion in 'Multiplayer' started by OmarDajani, Nov 18, 2016.

Thread Status:
Not open for further replies.
  1. OmarDajani

    OmarDajani

    Joined:
    Aug 17, 2016
    Posts:
    49
    Hey, so I took a look at the chat example from Photon's demo scene, however, it does not help me understand how to make a chat.

    I need a chat for each room that is created. So for example, if someone creates the room "Test" a chat will instantiate in the lobby (where players wait for the game to start) so that they can start chatting together.

    ---

    Also, I need to kick players from room.

    I tried doing this:

    Code (CSharp):
    1.     public void CloseConnection () {
    2.         PhotonPlayer playerToKick;
    3.         playerToKick = playerToKickInput.text;
    4.         PhotonNetwork.CloseConnection (PhotonPlayer playerToKick.name);
    5.     }
    However, this did not work.

    Thanks for your help, I really appreciate it :).
     
  2. Kamil-Says

    Kamil-Says

    Joined:
    Jun 30, 2014
    Posts:
    154
    I'm lazy to explain you the chat but I will help you with kicking players.

    1. Add PunRPC method "PlayerKick()" in any script that is attached to player.

    2. Add the following line to it: PhotonNetwork.LeaveRoom();

    3. Send Kick RPC command to any player by player ID!

    InCode:

    Code (CSharp):
    1. [PunRPC]
    2. private void KickPlayer()
    3. {
    4.     PhotonNetwork.LeaveRoom(); // load lobby scene, returns to master server
    5. }
    6.  
    7. public void SendKickPlayer(int playerID)
    8. {
    9.      PhotonPlayer player = PhotonPlayer.Find(playerID);
    10.  
    11.      photonView.RPC("KickPlayer",player);
    12. }
    13.  
     
    Katsshura and OmarDajani like this.
  3. OmarDajani

    OmarDajani

    Joined:
    Aug 17, 2016
    Posts:
    49
    Thanks for this! I'm going to give it a try and let you know how it goes :).
     
  4. MerhatPandzharov

    MerhatPandzharov

    Joined:
    Aug 29, 2015
    Posts:
    82
    Isn't photon too expensive ?
     
  5. OmarDajani

    OmarDajani

    Joined:
    Aug 17, 2016
    Posts:
    49
    Too expensive in terms of money? Correct me if I'm wrong, but there are different products of Photon on the Asset Store. I'm using the free one.
     
  6. Deleted User

    Deleted User

    Guest

    I think RPC not the best choose, because RPC cant guarantee delivering of Function, you need to kick on Server side, not allow Client to decide what to do on RPC Command, anyway you will face with some problems, like the Client cut RPC method code, and when you call Kick command on server, Client will not be kicked cause of anti-kick hack.
     
  7. Kamil-Says

    Kamil-Says

    Joined:
    Jun 30, 2014
    Posts:
    154
    Dude, this is PUN means this framework has no server side access to costumize it. To prevent kick, you have to inject an dll hack to mono runtime. And if you have a system that checks the mono thread attach (would be external C++ dll) which sends heartbeats to server, you can't even hack the game anymore, not even with cheat engine.
     
  8. Deleted User

    Deleted User

    Guest

    lmao, il2cpp compile your code in Assembly-Csharp.dll, you cannot make your game hackproof 100% If you dont have launcher and authoritative server, also, your kick system RPC can be easily avoid, just accept it as Rule. Thank you.

    On UNET, you have something like NetworkConnection.Disconnect(); Which is running on Server not called on Client, so that make you sure that server will kick client for 100% without any questions to Client like your RPC call method...

    P.S, server not must to Ask "-John, please Leave from this room" - like in your RPC call method, server must to throw John out the door without any questions.
     
    Last edited by a moderator: Nov 22, 2016
    LastChaos and Deleted User like this.
  9. Kamil-Says

    Kamil-Says

    Joined:
    Jun 30, 2014
    Posts:
    154
    1. Dude, LeaveRoom disconnects the player first from game server and returns the client to master server. Ok?.
    2. Again it's PUN = no authoritative server. Photon Server Loadbalancing API = authoritative server. Ok?
    3. il2cpp compiles on WebGL & mobile and and, not standalone build.
    4. Now read again: I know RPC can be avoid but you seem not to understand (like a baby) that this is not
    authoritative server framework so you have only this option in PUN.


     
    Katsshura likes this.
  10. Deleted User

    Deleted User

    Guest

    What a toxic man here, wrote a S***y code and trying to defend himself. S***coders everywhere..
     
    Deleted User likes this.
  11. Deleted User

    Deleted User

    Guest

    What about this?
    PhotonNetwork.CloseConnection( PhotonPlayer kickPlayer ) is this for blinded or what?

    After this make a hook which will connect client again to Master Server on client side, nothing hard here huh?
     
  12. Kamil-Says

    Kamil-Says

    Joined:
    Jun 30, 2014
    Posts:
    154
    Dude, you are failing all the time, so funny. Ok here is some lecture for S***coders that don't understand networking apis.
    "PhotonNetwork.CloseConnection( PhotonPlayer kickPlayer )" this can be called ONLY by master client, Ok?
    Only the creator of the room and the next random xyz client after current master disconnects will be next master client. We are talking about admin tools here which means RPC is the only one option left again. OK?

    Stop your tryhard man. Thanks!
     
  13. Deleted User

    Deleted User

    Guest

    Lmao.. 10 S***coders / 10

    Just like, just mark a host of Room as admin, then call Command to MasterClient for kick. It is so hard for you)
     
Thread Status:
Not open for further replies.