I want to create a time interval for a specific function. For example, players can only press the play button and enter the game from 12 AM to 2 PM. Other than that players can't enter.
I want to create a time interval for a specific function. For example, players can only press the play button and enter the game from 12 AM to 2 PM. Other than that players can't enter.
Can you describe the usage scenario?
If only prevent or allow players to call the API provided by PlayFab. You can do this by modifying the API policy. You can implement it using Azure Function Cloud Script and call this Azure Function Cloud Script at fixed time through Scheduled Task.
Do you have the example C# code in Azure Function Cloud Script ? That would be very helpful
You can refer to the code below. I wrote 3 cases in one function, but you don't need to call them all at the same time.
If you're modifying the policy for the first time, I suggest you use Postman and create a new Title to do some testing to understand what they do.
[FunctionName("UpdatePolicy")] public static async Task<IActionResult> UpdatePolicy( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { FunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync()); var settings = new PlayFabApiSettings { TitleId = context.TitleAuthenticationContext.Id, DeveloperSecretKey = Environment.GetEnvironmentVariable("PLAYFAB_DEV_SECRET_KEY", EnvironmentVariableTarget.Process), }; var adminApi=new PlayFabAdminInstanceAPI(settings); //Get var getPolicy=new GetPolicyRequest() { PolicyName="ApiPolicy" }; var getPolicyResult=await adminApi.GetPolicyAsync(getPolicy); //Add var addPolicy=new UpdatePolicyRequest() { PolicyName="ApiPolicy", OverwritePolicy=false, PolicyVersion=getPolicyResult.Result.PolicyVersion, Statements=new List<PermissionStatement>() { new PermissionStatement() { Resource="pfrn:api--/Client/LoginWithCustomID", Action="*", Effect=PlayFab.AdminModels.EffectType.Allow, Principal="*", Comment="Allow client to login with custom id." } } }; await adminApi.UpdatePolicyAsync(addPolicy); //Update var newStatements=getPolicyResult.Result.Statements; foreach(var item in newStatements) { if(item.Resource=="pfrn:api--/Client/LoginWithCustomID") { item.Effect=PlayFab.AdminModels.EffectType.Deny; item.Comment="Deny client to login with custom id."; } } var updatePolicy=new UpdatePolicyRequest() { PolicyName="ApiPolicy", OverwritePolicy=true, PolicyVersion=getPolicyResult.Result.PolicyVersion, Statements=newStatements }; await adminApi.UpdatePolicyAsync(updatePolicy); return null; }
14 People are following this question.
About to hit 100k MAU limit on Indie Tier, will I be auto transferred to Pro?
We need to store data for a turn based game, that data is about like 5kb because are long turns.
Title player limit Enterprise version
Player data value updates limit extension, Player data value updates per 15 seconds limit extension