Справочник функций
Godot 4 · GDScript · Groups & clans
transfer_group_leadership
Transfers leadership from the caller to another member (leader only).
Asynchronous (result via signal)
Signature
transfer_group_leadership(player_key: String) -> voidWhat it does
POSTs /groups/members/transfer-leadership. The current leader hands the leader role to the target member and is typically demoted to admin. error_code may be insufficient_rank / target_not_member / forbidden / not_found.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| player_key | String | required | Key of the member who becomes the new leader. |
How to call it
Connect group_leadership_transferred first, then call transfer_group_leadership(). Only the current leader may do this; use it instead of assign_group_role() to grant the "leader" role.
Result signal: group_leadership_transferred(success: bool, player_key: String, error_code: String)
Example
Gamdato.group_leadership_transferred.connect(_on_transfer)
Gamdato.transfer_group_leadership(player_key)
func _on_transfer(ok: bool, player_key: String, error_code: String) -> void:
if ok: print("New leader: %s" % player_key)
else: print("Failed: %s" % error_code)Use cases
- Hand off a clan before the leader leaves.
- Pass leadership to a co-founder or veteran member.