I have a custom class with 2 [team_settings_and_inventory_device] editables & then in the main device code I call GetPlayspace().GetTeamCollection() … How do I determine which item in the collection relates to my device?
Sample Code ( assign 1 player to first team & then ALL other players to second team)
AssignTeams():void={
#randomly select 1 player at the beginning
AllPlayers := GetPlayspace().GetPlayers()
PlayerIndex := GetRandomInt(0,AllPlayers.Length-1)
if(SelectedPlayer := AllPlayers[PlayerIndex]){
#(move player to first team & apply the class)
}
var curIndex : int = 0
Teams := GetPlayspace().GetTeamCollection()
for(CustomPlayer : AllPlayers){
if(curIndex <> PlayerIndex){
#Move ALL other player to other Team
}
set curIndex += 1
}
}
So the GetTeamCollection() does not return a team_settings_and_inventory_device device, it’s a pure Verse class that allows you to access team related functions.
If you want a specific team (let’s say team 1), you’ll do :
if(TeamOne := GetPlayspace().GetTeamCollection().GetTeams()[0]):
# TeamOne is a instance of the class 'team'
TeamOne can then be used in other functions that require any team type variable. I’m not sure what you’re trying to do exactly so I might need more intel on the best solution to provide here
As denoted in my sample code, I want to assign 1 random player to a specific team on game start… as said player eliminates others, they are then also moved to that team (an infection style game).
If the team_settings_and_inventory_device is not the route I should take then I am lost. I need to be able to know the team a player is on and then move said player to another team. I don’t think assuming team 1 (team index 0) is a good idea, but maybe that is how I should approach this.
Well, I really do need to read up on existing device functionality
Even so, if those weren’t settings I had available, within Verse, how would I associate a Team object to a device? … or maybe that isn’t even a reasonable idea… I really don’t know yet. Regardless, thanks for the continued support. I’ll keep digging & learning.
Ok, I figured out how to force a team to use the indexes… but in verse, when a player respawns, I need to check their team and call specific code…
#Check Team... use Infected Or Human
AllTeams := GetPlayspace().GetTeamCollection()
if(AssignedTeam := AllTeams.GetTeam[Agent]){
#Infected Team is index 2 (or 1 if it is zero based ???)
*if player is on Infected team then custom code here.*
}
Ok, I am certainly progressing and I am trying to move forward… I have my code in a fresh project ( I was in a test project where I have a bunch of other test code ).
When my map starts, it is only finding 1 team when I call GetPlayspace().GetTeamCollection().GetTeams().Length even though I have 2 team designers created.
So, my previous code is no longer working as index 1 does not exist…
Even though you can define any team settings with the team settings and inventory device, the count of existing team is defined by your IslandSettings, by both those parameters :
In my exemple it’s FFA so I guess there’s like 100 available teams, but if you choose Team Index, you can choose the number of teams with the number on the right.