# getAssignedTeam(self) only gives me 0

**URL:** <https://cod4x.ovh/t/getassignedteam-self-only-gives-me-0/3102>\
**Category:** CoD4x | Mods & Script Support\
**Created:** [December 5, 2023, 2:30am UTC](https://cod4x.ovh/t/getassignedteam-self-only-gives-me-0/3102 "2023-12-05T02:30:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RabaukenBobby](https://cod4x.ovh/user_avatar/cod4x.ovh/rabaukenbobby/32/1329_2.png) [@RabaukenBobby](https://cod4x.ovh/u/RabaukenBobby)\
**Post date:** [December 5, 2023, 2:30am UTC](https://cod4x.ovh/t/getassignedteam-self-only-gives-me-0/3102/1 "2023-12-05T02:30:41Z")

</div>

```auto
init()
{
    level endon("game_ended");
    level thread PrintAssignedTeam();
}

PrintAssignedTeam()
{
    for (;;)
    {
        wait 1;

		team = getAssignedTeam(self);

        iprintln("You are team: " + team);
		
    }
}

```

On this script i only get the number 0. Wich means i am in not a team. But i choosed a team and it still said 0. What did i do wrong? And if it isnt working what can i do to find out wich team a player is?

---

<div class="post-metadata">

**Author:** ![MAD\_DAD](https://cod4x.ovh/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@MAD\_DAD](https://cod4x.ovh/u/MAD_DAD)\
**Post date:** [December 5, 2023, 11:51am UTC](https://cod4x.ovh/t/getassignedteam-self-only-gives-me-0/3102/2 "2023-12-05T11:51:45Z")

</div>

This will get it to say axis or allies

```auto
init()
{
	level thread onPlayerConnect();
}
onPlayerConnect()
{
	for( ;; )
	{
	level waittill( "connecting", player );
	player thread onSpawnPlayer();
		
	}
}
	
onSpawnPlayer()
{
	self endon ( "disconnect" );
	while( 1 )
	{
	self waittill( "spawned_player" );
	wait 1;

	team = self.team;

    iprintln("You are team: "+team);
	}
}

```

---

<div class="post-metadata">

**Author:** ![MAD\_DAD](https://cod4x.ovh/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@MAD\_DAD](https://cod4x.ovh/u/MAD_DAD)\
**Post date:** [December 5, 2023, 12:00pm UTC](https://cod4x.ovh/t/getassignedteam-self-only-gives-me-0/3102/3 "2023-12-05T12:00:59Z")

</div>

If you actually want the team name then:

```auto
init()
{
	level thread onPlayerConnect();
}
onPlayerConnect()
{
	for( ;; )
	{
	level waittill( "connecting", player );
	player thread onSpawnPlayer();
		
	}
}
	
onSpawnPlayer()
{
	self endon ( "disconnect" );
	while( 1 )
	{
	self waittill( "spawned_player" );
	wait 1;

	if (self.team == "allies")
	{
	team = getDvar( "g_TeamName_Allies" );
    iprintln("You are team: "+team);
	}
	else
	{
	team = getDvar( "g_TeamName_Axis" );
    iprintln("You are team: "+team);
	}
}
}

```
