Sign In Register

How can we help you today?

Start a new topic

Team Create

I am having a hard time understanding how team creation work.What i want is if a player click a button i want to create a team. Since i am in ios platform here is my code

GSCreateTeamRequest* request = [[GSCreateTeamRequest alloc] init];
    [request setTeamId:@"1123123"];
    [request setTeamName:@"tese"];
    [request setTeamType:@"tese"];
    [self.gs send:request];
       [request setCallback:^ (GSCreateTeamResponse* response) {
          NSArray* members = [response getMembers];
          GSPlayer* owner = [response getOwner];
          NSDictionary* scriptData = [response getScriptData];
          NSString* teamId = [response getTeamId];
          NSString* teamName = [response getTeamName];
          NSString* teamType = [response getTeamType];
           NSLog(@"GSCreateTeamResponse Fayed %@",teamType);
           
      }];

 if i don this i get an error of setTeamType:"INVALID". Then i create a Team in gamesparks webportal where i named  the short code to "tese" after that i can successfully create a team. but i want is to create a team from client side where other user can join. How can i do that. do i need to use cloud code?if so what will be the code?any snippets of example are appreciated.. 


1 person has this question

Hi Fayed,


The team you define in the portal behaves like a class - it defines things like the maximum members a team can have and how many teams a player can own, but it doesn't actually create a joinable team (or instance). Your CreateTeamRequest creates a team based on this team type. Your CreateTeamResponse will include the id of your newly created team. Players can then join your team via the JoinTeamRequest using either this teamId; or a combination of teamType + the playerId of the team owner.


I hope this helps clear things up a bit. If you have any more questions please let us know.


Regards,

Vinnie

Thank you,
I have another question. is it possible to see the created teams in my portal?

Hi Fayed,


Yes, you can view your teams via the NoSQL Explorer. The System->teams collection contains all of your created teams.


image


Regards,

Vinnie

Thanks Vinni, 

So i have created a guild.  

-(void)GuildCreate
{
    GSCreateTeamRequest* request = [[GSCreateTeamRequest alloc] init];
    [request setTeamId:@"4200"];
    [request setTeamName:@"Warriors"];
    [request setTeamType:@"tese"];
    [self.gs send:request];
       [request setCallback:^ (GSCreateTeamResponse* response) {
          NSArray* members = [response getMembers];
          GSPlayer* owner = [response getOwner];
          NSDictionary* scriptData = [response getScriptData];
          NSString* teamId = [response getTeamId];
          NSString* teamName = [response getTeamName];
          NSString* teamType = [response getTeamType];
           NSLog(@"GSCreateTeamResponse teamType %@ teamId %d",teamType,teamId);
           
      }];

}

 In log i get the teamid 50537284 which is fine. Now from another device i am trying to join the team using the team id 50537284. Here is the code snippet   

GSJoinTeamRequest* request = [[GSJoinTeamRequest alloc] init];
    [request setTeamId:@"50537284"];
    [self.gs send:request];

    [request setCallback:^ (GSJoinTeamResponse* response) {
          NSArray* members = [response getMembers];
          GSPlayer* owner = [response getOwner];
          NSDictionary* scriptData = [response getScriptData];
          NSString* teamId = [response getTeamId];
          NSString* teamName = [response getTeamName];
          NSString* teamType = [response getTeamType];
        NSLog(@"teamId %d teamName %d teamType %@",teamId,teamName,teamType);
      }]; 

  it should work right..but i got team:"INVALID" response on the log...

What i understand is when authentication same userid is generated for all user that's why i cant join a team by team id.Now how to generate different userid for different user during authentication?

Login to post a comment