Exemple #1
0
    public void ConfirmBanUser()
    {
        var request = new BanRequest();

        try {
            if (!string.IsNullOrEmpty(banTimeInHours.text))
            {
                request.DurationInHours = uint.Parse(banTimeInHours.text);
            }
        } catch (System.Exception e) {
            request.DurationInHours = 0;
        }
        request.Reason    = banReason.text;
        request.PlayFabId = lastPlayerIdentifier.playerID;
        var banList = new List <BanRequest>();

        banList.Add(request);
        PlayFabAdminAPI.BanUsers(new BanUsersRequest {
            Bans = banList
        },
                                 result => {
            banModal.SetActive(false);
            Debug.Log("BAN USER OK: " + result.ToJson().ToString());
            Inform(string.Format("{0} was successfully banned for {1} hours for \"{2}\"",
                                 lastPlayerIdentifier.displayName, banTimeInHours.text, banReason.text));
        },
                                 error => {
            Debug.LogError("BAN PLAYER FAILED: " + error.ToString());
            Inform("Unable to ban user! " + error.ErrorMessage);
            banModal.SetActive(false);
        });
    }