© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
8 replies
ChoppySloppy542

The Given key was not present in the dictionary

ive revived a nostalgic old mobile game and ive converted the offline dead servers from smart fox to photon and everything seems to work but one mode in the game doesnt work at all here is a code snippet public void BirthPlayer(PhotonPlayer player)
{
if (!SFS_Player_Arr.ContainsKey(player))
{
Multiplayer multiplayer = new Multiplayer(player.ID);
multiplayer.InitAvatar((AvatarType)player.customProperties["avatarType"], (uint)(int)player.customProperties["birthPoint"]);
multiplayer.InitWeaponList((int)player.customProperties["weapon1"], (int)player.customProperties["weapon2"], (int)player.customProperties["weapon3"]);
SFS_Player_Arr.Add(player, multiplayer);
multiplayer.nick_name = (string)player.customProperties["nickname"];
multiplayer.Init();
multiplayer.ChangeWeaponWithindex((int)player.customProperties["weaponNum"]);
}
}
public void InitializePlayer(PhotonPlayer player)
{
// Check if the player is already added, if not, add them
BirthPlayer(player);
}

public void OnPlayerJoin(PhotonPlayer newPlayer)
{
InitializePlayer(newPlayer);
}

public override void DoLogic(float deltaTime)
{
if (!is_game_excute)
{
return;
}
player.DoLogic(deltaTime);
if (!is_game_over && PhotonNetwork.isMasterClient)
{
object[] array = new object[enemyList.Count];
enemyList.Keys.CopyTo(array, 0);
for (int i = 0; i < array.Length; i++)
{
Enemy enemy = enemyList[array[i]] as Enemy;
enemy.DoLogic(deltaTime);
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

KeyNotFoundException: The given key was not present in the dictionary.
C#CC# / help
3y ago
the given key "server id" was not present in the dictionary
C#CC# / help
2y ago
❔ System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary
C#CC# / help
3y ago
Blazor Server App. Error KeyNotFoundException: The given key was not present in the dictionary.
C#CC# / help
3y ago