That's all I need
,That's all I need
,Do you want to ban the player on the client side and then load the scene? You can call BanUsers on the client side via Azure Function Cloud Script and then load the scene in the callback. Referring to the example below, I am testing on Unity. If my understanding is wrong, please explain your needs in detail.
public void BanPlayer() { PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest { FunctionName = "Test", GeneratePlayStreamEvent = true }, (result) => { SceneManager.LoadScene("Test"); }, (error) => { Debug.LogError(error.GenerateErrorReport()); }); }
using System; using System.IO; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.WebJobs; using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using PlayFab; using PlayFab.Samples; using System.Collections; using System.Collections.Generic; using PlayFab.ServerModels; namespace Company.Function { public static class Test { [FunctionName("Test")] public static async Task<dynamic> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log) { FunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync()); var request =new BanUsersRequest{ Bans=new List<BanRequest>(){ new BanRequest{ PlayFabId=context.CallerEntityProfile.Lineage.MasterPlayerAccountId, DurationInHours=24, Reason="test" } } }; var setting=new PlayFabApiSettings{ TitleId=context.TitleAuthenticationContext.Id, DeveloperSecretKey=" " }; var serverApi=new PlayFabServerInstanceAPI(setting); return await serverApi.BanUsersAsync(request); } } }
Do you have a script that's a bit like this?
Sorry for being a bit annoying. I just started trying to code with PlayFab.
void OnTriggerEnter(Collider other) { //ban player in trigger }
You just need to call BanPlayer() above in OnTriggerEnter().
If you are new to Azure Function Cloud Script, you can refer to PlayFab CloudScript using Azure Functions Quickstart Guide - PlayFab | Microsoft Docs to get started.
13 People are following this question.