MirrorNetworking / MirrorNetworking/Mirror

Allow [Command] functions to be called in server-only mode

Open
#3,450 2 comments 0 reactions 1 assignee View on GitHub

@miwarnec is already working on this.

Since Apr 8, 2023.

enhancement
Dominant language
C#
Stars
6.3k
Forks
870
PR merge metrics
No merged PRs in 30d

Description

This has been requested a lot, ever since UNET.

For example:

class Inventory : NetworkBehaviour
{
    // drop item at slot
    [Command]
    void DropItem(int slot) { ... }

   // local client may request to drop
   void Update()
   {
        if (isLocalPlayer && clicked) DropItem(4);
   }


   // server may want to call the code too
   [Server]
   void PunishPlayer()
   {
        // THIS ERRORS because commands can't be called on server-only
        for (i = 0 to count)
            DropItem(i);
   }
   ...

}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.