isMasterClient where is ?

On Unity you have a very useful property:


there is something like that on Lua SDK ?



  • Not exactly isMasterClient but similar method exist:

    You can compare the return value against actor Nr of the player in question.
  • rrerre
    edited May 13
    Thank you Vadim, now I have to found whats is my Nr ! Doesn't exists a function that return your number. ; )
    There is a GetUserID() but the ID is not the nuber.

    However, I found a solution, also reported on the Solar2D website ( , which I repeat here:

    Starts from example found in photon SDK (photon_corona_plugin_sample) where you create the class:

    local client =, appInfo.AppId, appInfo.AppVersion)
    function client:checkInit()
        --return "S" slave or "M" master
        local nrMaster = 0
        local result = "S"
        if self:isJoinedToRoom() then
          nrMaster = self:myRoomMasterActorNr()
          for actorNr, actor in pairs(client:myRoomActors()) do
            if actor.actorNr == nrMaster and actor.isLocal == true then
              --I'm master
              result = "M"
              --I'm slave
        return result

    I think is better call also other 2 instances to have updated the state
    function client:onActorJoin(actor)
    function client:onActorLeave(actor)

    I think the code should be better: avoid the ‘for’ loop.
    But I’m not able to write a better one. ; (

    If someone can help is appreciate.

  • rrerre
    edited May 15
    Thank you,
    you probably think at something like this:
    self:myRoomActors()[self:myRoomMasterActorNr()].isLocal == true

    I don't think will will work!

    be careful that the number of players in the room does not match the number of each player.

    For example:
    -> enter 2 players
    [1] actor.actorNr 1 name Player 1
    [2] actor.actorNr 2 name Player 2

    in that case the code above will works

    <-- exit player1
    --> enter player3

    you will have 2 actors on rom
    [1] actor.actorNr 2 name Player 2
    [2] actor.actorNr 3 name Player 3

    so the myRoomMasterActorNr() will give you value 3 but on table you will find on row 2


  • vadimvadim mod
    edited May 15
    I was sure that Actor object has a property returning actor nr. Unfortunately, it does not. Sorry.
    But seems like your approach should work at least while the client is joint to the room.
    self:myRoomActors() is a table with joined actor numbers as keys. Master actor nr should be among them.
  • rrerre
    edited May 15
    Yes, I confirm, MasterActor it is among these and it works.

    And if there are few actors in a room, a 'for' cycle does not give problems, you don't notice delay. You could probably have problems were many.

    Thanks for your help!


Sign In or Register to comment.