Sign In Register

How can we help you today?

Start a new topic
Answered

sparkTeam.create()?

 there is a cloud code function to drop a spark team:

var success = Spark.getTeams().getTeam(myTeamId).drop();

https://docs.gamesparks.net/documentation/cloud-code-api/spark-cloud-code-api/sparkteam#drop


is there a corresponding create() function? or should one send the request like so?

Spark.sendRequest({
"@class": ".CreateTeamRequest",
"teamId": myTeamId, "teamType": myTeamType, "teamName": myTeamName
});

 


Best Answer

What I did for the team Create is just using the TeamCreateRequest.

In Unity C# 

I did 


var teamReq = new CreateTeamRequest();

            //set the name, type and the teamId (same as the name)

            teamReq.SetTeamName(teamName).SetTeamType("teamType").SetTeamId(teamName);

            teamReq.Send((response) =>

            {

                if (response.HasErrors)

                {

                    Debug.LogError("CreateTeamRequest has an error: " + response.Errors.JSON);

                }

                else

                {

                    Debug.Log("CreateTeamRequest has worked with no errors" + response.ScriptData);

                }

            });


If you specify the TeamId you can specify what it is instead of leaving it up to being "hashed" (or whatever it is).  I didn't realize it for a while but now I can make the teamId in GS the same as the team name, which makes things easier to find later if you save teamName/TeamId to your player data .

1 Comment

Answer

What I did for the team Create is just using the TeamCreateRequest.

In Unity C# 

I did 


var teamReq = new CreateTeamRequest();

            //set the name, type and the teamId (same as the name)

            teamReq.SetTeamName(teamName).SetTeamType("teamType").SetTeamId(teamName);

            teamReq.Send((response) =>

            {

                if (response.HasErrors)

                {

                    Debug.LogError("CreateTeamRequest has an error: " + response.Errors.JSON);

                }

                else

                {

                    Debug.Log("CreateTeamRequest has worked with no errors" + response.ScriptData);

                }

            });


If you specify the TeamId you can specify what it is instead of leaving it up to being "hashed" (or whatever it is).  I didn't realize it for a while but now I can make the teamId in GS the same as the team name, which makes things easier to find later if you save teamName/TeamId to your player data .

Login to post a comment