Exception on Event.Create() .. "You are not the server of, you can not raise this event"

Laurence_B
edited March 2020 in Photon Bolt
Hello Forum!

I am trying to create a log system, where the player can see messages like "xx has joined the game" or "xx was shot down". Stuff like that.
I have created an Event in the Bolt Assets window, I've created an OnEvent(event xx) and the Event.Create()/Send(). (see pictures below).

Every time the client connects he gets this error: A picture of the error.

Here the event in the Bolt Assets window: A picture of the event

The following code inherits from another script (which inherits from Bolt.EntityBehaviour<ICarState>):
public class LB_Car_Network : LB_BaseCarRigidBody_Controller
    {
        public override void Attached()
        {
            state.SetTransforms(state.CarTransform, transform);
            
            var evnt = PlayerJoinedEvent.Create();           //here I get the error
            evnt.Message = "Name joined the game";
            evnt.Send();
        }

        protected override void HandleNetwork()
        { }
    }

The following code is attached to a canvas of a child object of the car-entity:
public class LB_Car_NetworkUI : Bolt.GlobalEventListener
    {
        public TextMeshProUGUI logsTMP;

        public override void OnEvent(PlayerJoinedEvent evnt)
        {
            logsTMP.text.Insert(0, evnt.Message);
        }
    }


I have also tried moving stuff around. For example sending the event from the base script. Or putting the OnEvent on a gameobject in the scene..
Help and explanation is much appreciated.

Cheers,
Laurence.

Best Answers

  • stanchion
    stanchion mod
    Answer ✓
    You set the event so that it can only be sent from the server, but attached is called everywhere. Therefore your clients are trying to send the event.
  • Laurence_B
    Answer ✓
    @stanchion I have tried setting the global sender to "only client" and "only server" and I have also tried setting global sender to "none" and setting entity sender to "only owner".

    None of them work..

Answers