Skip to main content
Version: 5.9.6

create

BACKND Guidelines > 9. Implementing Guild Functions > Step 2. Creating Guilds

Creating Guilds

1. Write a method for creating guilds

Add content to the CreateGuild method in BackendGuild.cs written in Pre-arrangements.

BackendGuild.cs

Before editing

    public void CreateGuild(string guildName) {
// Step 2. Creating Guilds
}

After editing

    public void CreateGuild(string guildName) {
// goodsCount entering as 10 is the number of goods types that can be used and cannot be modified later.
var bro = Backend.Guild.CreateGuildV3(guildName, 10);

if(bro.IsSuccess() == false) {
Debug.LogError("An error occurred while creating the guild. : " + bro);
return;
}

Debug.Log("Guild created. : " + bro);
}

2. Add method call to BackendManager.cs

BackendManager, which is automatically called when the game is executed, must be used to call this method.
Add it so that the method may be called after BACKND initialization and BACKND login.

Enter the name of the guild to create in the parameter value for BackendGuild.Instance.CreateGuild.

BackendManager.cs

Before editing

    async void Test() {
await Task.Run(() => {
BackendLogin.Instance.CustomLogin("user1", "1234"); // Logs in as user1

// Adds guild logic

Debug.Log("Test complete.");
});
}

After editing

    async void Test() {
await Task.Run(() => {
BackendLogin.Instance.CustomLogin("user1", "1234"); // Logs in as user1
// When 412 error occurs while creating a guild, the creation of the guild is unavailable because the user already belongs to a guild.
// Create a new user with CustomSignUp("user3", "1234") to generate a guild.

BackendGuild.Instance.CreateGuild("Desired_guild_name"); // Method for creating guilds

Debug.Log("Test complete.");
});
}

3. Test in Unity

After editing the script, execute Unity debugging and check the console log of Unity.

The method has been successfully called when the log displays 'Guild created. : statusCode : 204'.
When errors, such as statusCode : 400, 404, and 409, occur instead of the above log, you can check which errors caused the failure in CreateGuildV3 error case.

4. Check in the console

Go to the BACKND Console, and inBACKND Base > Guild Management, check that the created guild exists.