Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question I need help with errors

Discussion in 'Scripting' started by TwoTeraBytes, Dec 15, 2020.

  1. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    I need help fixing this part of my script. I have been trying to fix this for a while but non of them work.

    private string _role = string.Empty;
    public string RolePrefix
    {
    get
    {
    if (CurrentTeamUser != null && !string.IsNullOrEmpty(CurrentTeamUser.UserName));
    {
    return string.Format("<color=#{1}>[{0}]</color>", CurrentTeamUser.m_Role.ToString(), ColorUtility.ToHtmlStringRGBA(CurrentTeamUser.m_Color))
    }
    else
    {
    return string.Empty;
    }
    if(bl_DataBase.Instance == null || !bl_DataBase.Instance.isLogged || !bl_DataBase.Instance.LocalUser.Clan.haveClan)
    {
    return string.Empty;
    }
    else
    {
    if (string.IsNullOrEmpty(_role));
    {
    _role = string.Format("[{0}]", bl_DataBase.Instance.LocalUser.Clan.Name);
    }
    return _role;
    }
    }

    }

    My errors are:
    Assets\MFPS\Scripts\Core\bl_GameData.cs(183,16): error CS0103: The name 'bl_DataBase' does not exist in the current context
    Assets\MFPS\Scripts\Core\bl_GameData.cs(183,49): error CS0103: The name 'bl_DataBase' does not exist in the current context
    Assets\MFPS\Scripts\Core\bl_GameData.cs(183,83): error CS0103: The name 'bl_DataBase' does not exist in the current context
    Assets\MFPS\Scripts\Core\bl_GameData.cs(191,52): error CS0103: The name 'bl_DataBase' does not exist in the current context
     
  2. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    Please read up on how to use code tags properly-- it makes it so much easier to help!

    That error means that
    bl_DataBase
    isn't defined anywhere in your code. If It is a class you're trying to reference, make sure that the capitalization and spelling match exactly.
     
  3. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    Here it is
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using System.Linq;
    5. using System;
    6. using UnityEngine.SceneManagement;
    7. using Object = UnityEngine.Object;
    8. using MFPSEditor;
    9.  
    10. public class bl_GameData : ScriptableObject
    11. {
    12.     [Header("Game Settings")]
    13.     public bool offlineMode = true;
    14.     public bool UseLobbyChat = true;
    15.     public bool UseVoiceChat = false;
    16.     public bool BulletTracer = false;
    17.     public bool DropGunOnDeath = true;
    18.     public bool SelfGrenadeDamage = true;
    19.     public bool CanFireWhileRunning = true;
    20.     public bool HealthRegeneration = true;
    21.     public bool ShowTeamMateHealthBar = true;
    22.     public bool CanChangeTeam = false;
    23.     public bool ShowBlood = false;
    24.     public bool DetectAFK = true;
    25.     public bool MasterCanKickPlayers = true;
    26.     public bool ArriveKitsCauseDamage = true;
    27.     public bool CalculateNetworkFootSteps = false;
    28.     public bool ShowNetworkStats = false;
    29.     public bool RememberPlayerName = true;
    30.     public bool ShowWeaponLoadout = true;
    31.     public bool useCountDownOnStart = true;
    32.     public bool showCrosshair = true;
    33.     public bool doSpawnHandMeshEffect = true;
    34.     public bool playerCameraWiggle = true;
    35. #if MFPSM
    36.     public bool AutoWeaponFire = true;
    37. #endif
    38. #if LM
    39.     public bool LockWeaponsByLevel = true;
    40. #endif
    41.     public AmmunitionType AmmoType = AmmunitionType.Bullets;
    42.     public KillFeedWeaponShowMode killFeedWeaponShowMode = KillFeedWeaponShowMode.WeaponIcon;
    43.     public LobbyJoinMethod lobbyJoinMethod = LobbyJoinMethod.WaitingRoom;
    44.     public bl_KillCam.KillCameraType killCameraType = bl_KillCam.KillCameraType.ObserveDeath;
    45.  
    46.     [Header("Rewards")]
    47.     public ScoreRewards ScoreReward;
    48.     public VirtualCoin VirtualCoins;
    49.  
    50.     [Header("Settings")]
    51.     public string GameVersion = "1.0";
    52.     [Range(0, 10)] public int SpawnProtectedTime = 5;
    53.     [Range(1, 60)] public int CountDownTime = 15;
    54.     [Range(1, 10)] public float PlayerRespawnTime = 10.0f;
    55.     [Range(1, 100)] public int MaxFriendsAdded = 35;
    56.     public float AFKTimeLimit = 30;
    57.     public int MaxChangeTeamTimes = 1;
    58.     public string MainMenuScene = "MainMenu";
    59.     public string OnDisconnectScene = "MainMenu";
    60.     public Color highLightColor = Color.green;
    61.  
    62.     [Header("Levels Manager")]
    63.     [Reorderable]
    64.     public List<SceneInfo> AllScenes = new List<SceneInfo>();
    65.  
    66.     [Header("Weapons")]
    67.     /* [Reorderable]*/
    68.     public List<bl_GunInfo> AllWeapons = new List<bl_GunInfo>();
    69.  
    70.     [Header("Default Settings")]
    71.     public DefaultSettingsData DefaultSettings;
    72.  
    73.     [Header("Game Modes Available"), Reorderable]
    74.     public List<GameModesEnabled> gameModes = new List<GameModesEnabled>();
    75.  
    76.     [Header("Teams")]
    77.     public string Team1Name = "Team1";
    78.     public Color Team1Color = Color.blue;
    79.     [Space(5)]
    80.     public string Team2Name = "Team2";
    81.     public Color Team2Color = Color.green;
    82.  
    83.     [Header("Players")]
    84.     public bl_PlayerNetwork Player1;
    85.     public bl_PlayerNetwork Player2;
    86.  
    87.     [Header("Bots")]
    88.     public bl_AIShooterAgent BotTeam1;
    89.     public bl_AIShooterAgent BotTeam2;
    90.  
    91.     [Header("Game Team")]
    92.     public List<GameTeamInfo> GameTeam = new List<GameTeamInfo>();
    93.  
    94.     public GameTeamInfo CurrentTeamUser { get; set; } = null;
    95.     [HideInInspector] public bool isChating = false;
    96.  
    97.     [HideInInspector] public string _MFPSLicense = string.Empty;
    98.     [HideInInspector] public int _MFPSFromStore = 2;
    99.     [HideInInspector] public string _keyToken = "";
    100.  
    101.     public bl_GunInfo GetWeapon(int ID)
    102.     {
    103.         if (ID < 0 || ID > AllWeapons.Count - 1)
    104.             return AllWeapons[0];
    105.      
    106.         return AllWeapons[ID];
    107.     }
    108.  
    109.     public string[] AllWeaponStringList()
    110.     {
    111.         return AllWeapons.Select(x => x.Name).ToList().ToArray();
    112.     }
    113.  
    114.     public int GetWeaponID(string gunName)
    115.     {
    116.         int id = -1;
    117.         if(AllWeapons.Exists(x => x.Name == gunName))
    118.         {
    119.             id = AllWeapons.FindIndex(x => x.Name == gunName);
    120.         }
    121.         return id;
    122.     }
    123.  
    124.     /// <summary>
    125.     ///
    126.     /// </summary>
    127.     public int CheckPlayerName(string pName)
    128.     {
    129.         for (int i = 0; i < GameTeam.Count; i++)
    130.         {
    131.             if (pName == GameTeam[i].UserName)
    132.             {
    133.                 return 1;
    134.             }
    135.         }
    136.         if (pName.Contains('[') || pName.Contains('{'))
    137.         {
    138.             return 2;
    139.         }
    140.         CurrentTeamUser = null;
    141.         return 0;
    142.     }
    143.  
    144.     /// <summary>
    145.     ///
    146.     /// </summary>
    147.     public bool CheckPasswordUse(string PName, string Pass)
    148.     {
    149.         for (int i = 0; i < GameTeam.Count; i++)
    150.         {
    151.             if (PName == GameTeam[i].UserName)
    152.             {
    153.                if(Pass == GameTeam[i].Password)
    154.                 {
    155.                     CurrentTeamUser = GameTeam[i];
    156.                     return true;
    157.                 }
    158.             }
    159.         }
    160.         return false;
    161.     }
    162.  
    163.     /// <summary>
    164.     ///
    165.     /// </summary>
    166. #if CLANS
    167.     private string _role = string.Empty;
    168. #endif
    169.     public string RolePrefix
    170.     {
    171.         get
    172.         {
    173. #if !CLANS
    174.             if (CurrentTeamUser != null && !string.IsNullOrEmpty(CurrentTeamUser.UserName));
    175.             {
    176.                 return string.Format("<color=#{1}>[{0}]</color>", CurrentTeamUser.m_Role.ToString(), ColorUtility.ToHtmlStringRGBA(CurrentTeamUser.m_Color))
    177.             }
    178.             else
    179.             {
    180.                 return string.Empty;
    181.             }
    182. #else
    183.             if(bl_DataBase.Instance == null || !bl_DataBase.Instance.isLogged || !bl_DataBase.Instance.LocalUser.Clan.haveClan)
    184.             {
    185.                 return string.Empty;
    186.             }
    187.             else
    188.             {
    189.                 if (string.IsNullOrEmpty(_role));
    190.                 {
    191.                     _role = string.Format("[{0}]", bl_DataBase.Instance.LocalUser.Clan.Name);
    192.                 }
    193.                 return _role;
    194.             }
    195. #endif
    196.         }
    197.  
    198.     }
    199.  
    200.     void OnDisable()
    201.     {
    202.         isDataCached = false;
    203.     }
    204.  
    205.     [System.Serializable]
    206.     public class GameTeamInfo
    207.     {
    208.         public string UserName;
    209.         public Role m_Role = Role.Moderator;
    210.         public string Password;
    211.         public Color m_Color;
    212.  
    213.         public enum Role
    214.         {
    215.             Admin = 0,
    216.             Moderator = 1,
    217.         }
    218.     }
    219.  
    220.     /// <summary>
    221.     /// cache the GameData from Resources asynchronous to avoid overhead and freeze the main thread the first time we access to the instance
    222.     /// </summary>
    223.     /// <returns></returns>
    224.     public static IEnumerator AsyncLoadData()
    225.     {
    226.         if (m_Data == null)
    227.         {
    228.             isCaching = true;
    229.             ResourceRequest rr = Resources.LoadAsync("GameData", typeof(bl_GameData));
    230.             while (!rr.isDone) { yield return null; }
    231.             m_Data = rr.asset as bl_GameData;
    232.             isCaching = false;
    233.         }
    234.         isDataCached = true;
    235.     }
    236.  
    237.     public static bool isDataCached = false;
    238.     private static bool isCaching = false;
    239.     private static bl_GameData m_Data;
    240.     public static bl_GameData Instance
    241.     {
    242.         get
    243.         {
    244.             if (m_Data == null && !isCaching)
    245.             {
    246.                 m_Data = Resources.Load("GameData", typeof(bl_GameData)) as bl_GameData;
    247.             }
    248.             return m_Data;
    249.         }
    250.     }
    251.  
    252.     [System.Serializable]
    253.     public class ScoreRewards
    254.     {
    255.         public int ScorePerKill = 50;
    256.         public int ScorePerHeadShot = 25;
    257.         public int ScoreForWinMatch = 100;
    258.         [Tooltip("Per minute played")]
    259.         public int ScorePerTimePlayed = 3;
    260.     }
    261.  
    262.     [System.Serializable]
    263.     public class VirtualCoin
    264.     {
    265.         public int InitialCoins = 1000;
    266.         [Tooltip("how much score/xp worth one coin")]
    267.         public int CoinScoreValue = 1000;//how much score/xp worth one coin
    268.  
    269.         public int UserCoins { get; set; }
    270.  
    271.         public void LoadCoins(string userName)
    272.         {
    273.             UserCoins = PlayerPrefs.GetInt(string.Format("{0}.{1}", userName, PropertiesKeys.UserCoins), InitialCoins);
    274.         }
    275.  
    276.         public void SetCoins(int coins, string userName)
    277.         {
    278.             LoadCoins(userName);
    279.             int total = UserCoins + coins;
    280.             PlayerPrefs.SetInt(string.Format("{0}.{1}", userName, PropertiesKeys.UserCoins), total);
    281.             UserCoins = total;
    282.         }
    283.     }
    284.  
    285. #if UNITY_EDITOR
    286.     void OnValidate()
    287.     {
    288.         for (int i = 0; i < AllScenes.Count; i++)
    289.         {
    290.             if (AllScenes[i].m_Scene == null) continue;
    291.             AllScenes[i].RealSceneName = AllScenes[i].m_Scene.name;
    292.         }
    293.     }
    294. #endif
    295.  
    296.     [Serializable]
    297.     public class SceneInfo
    298.     {
    299.         public string ShowName;
    300.         [SerializeField]
    301.         public Object m_Scene;
    302.         [HideInInspector] public string RealSceneName;
    303.         [SpritePreview] public Sprite Preview;
    304.     }
    305.  
    306.     [Serializable]
    307.     public class DefaultSettingsData
    308.     {
    309.         [Range(1, 20)] public float DefaultSensitivity = 5.0f;
    310.         [Range(1, 20)] public float DefaultSensitivityAim = 2;
    311.         public int DefaultQualityLevel = 3;
    312.         public int DefaultAnisoTropic = 2;
    313.         [Range(0, 1)] public float DefaultVolume = 1;
    314.         [Range(40, 100)] public int DefaultWeaponFoV = 60;
    315.         public bool DefaultShowFrameRate = false;
    316.         public bool DefaultMotionBlur = true;
    317.         public int[] frameRateOptions = new int[] { 30, 60, 120, 144, 200, 260, 0 };
    318.         public int defaultFrameRate = 2;
    319.     }
    320.  
    321.     [Serializable]
    322.     public class GameModesEnabled
    323.     {
    324.         public string ModeName;
    325.         public GameMode gameMode;
    326.         public bool isEnabled = true;
    327.  
    328.         [Header("Settings")]
    329.         public bool AutoTeamSelection = false;
    330.         [Range(1,16)] public int RequiredPlayersToStart = 1;
    331.         public int[] GameGoalsOptions = new int[] { 50, 100, 150, 200 };
    332.         public string GoalName = "Kills";
    333.         public OnRoundStartedSpawn onRoundStartedSpawn = OnRoundStartedSpawn.SpawnAfterSelectTeam;
    334.         public OnPlayerDie onPlayerDie = OnPlayerDie.SpawnAfterDelay;
    335.  
    336.         public string GetGoalFullName(int goalID) { return string.Format("{0} {1}", GameGoalsOptions[goalID], GoalName); }
    337.  
    338.         [System.Serializable]
    339.         public enum OnRoundStartedSpawn
    340.         {
    341.             SpawnAfterSelectTeam,
    342.             WaitUntilRoundFinish,
    343.         }
    344.  
    345.         [System.Serializable]
    346.         public enum OnPlayerDie
    347.         {
    348.             SpawnAfterDelay,
    349.             SpawnAfterRoundFinish,
    350.         }
    351.     }
    352. }
     
  4. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    you try to use bl_DataBase but it´s never defined. So your have to define it global and set a value for it

    *Is bl_DataBase a static class ?
     
  5. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    That fixed it but there is another error. I have never seen this error before
    Assets\MFPS\Scripts\Core\bl_GameData.cs(42,5): error CS1585: Member modifier 'public' must precede the member type and name
     
  6. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    can you post your changed code again, cause in the "old" i can´t find any problem (at least on that line or on the lines before).
     
  7. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    Ok here you go
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using System.Linq;
    5. using System;
    6. using UnityEngine.SceneManagement;
    7. using Object = UnityEngine.Object;
    8. using MFPSEditor;
    9.  
    10. public class bl_GameData : ScriptableObject
    11. {
    12.     [Header("Game Settings")]
    13.     public bool offlineMode = true;
    14.     public bool UseLobbyChat = true;
    15.     public bool UseVoiceChat = false;
    16.     public bool BulletTracer = false;
    17.     public bool DropGunOnDeath = true;
    18.     public bool SelfGrenadeDamage = true;
    19.     public bool CanFireWhileRunning = true;
    20.     public bool HealthRegeneration = true;
    21.     public bool ShowTeamMateHealthBar = true;
    22.     public bool CanChangeTeam = false;
    23.     public bool ShowBlood = false;
    24.     public bool DetectAFK = true;
    25.     public bool MasterCanKickPlayers = true;
    26.     public bool ArriveKitsCauseDamage = true;
    27.     public bool CalculateNetworkFootSteps = false;
    28.     public bool ShowNetworkStats = false;
    29.     public bool RememberPlayerName = true;
    30.     public bool ShowWeaponLoadout = true;
    31.     public bool useCountDownOnStart = true;
    32.     public bool showCrosshair = true;
    33.     public bool doSpawnHandMeshEffect = true;
    34.     public bool playerCameraWiggle = true;
    35.     public static bl_DataBase
    36. #if MFPSM
    37.     public bool AutoWeaponFire = true;
    38. #endif
    39. #if LM
    40.     public bool LockWeaponsByLevel = true;
    41. #endif
    42.     public AmmunitionType AmmoType = AmmunitionType.Bullets;
    43.     public KillFeedWeaponShowMode killFeedWeaponShowMode = KillFeedWeaponShowMode.WeaponIcon;
    44.     public LobbyJoinMethod lobbyJoinMethod = LobbyJoinMethod.WaitingRoom;
    45.     public bl_KillCam.KillCameraType killCameraType = bl_KillCam.KillCameraType.ObserveDeath;
    46.  
    47.     [Header("Rewards")]
    48.     public ScoreRewards ScoreReward;
    49.     public VirtualCoin VirtualCoins;
    50.  
    51.     [Header("Settings")]
    52.     public string GameVersion = "1.0";
    53.     [Range(0, 10)] public int SpawnProtectedTime = 5;
    54.     [Range(1, 60)] public int CountDownTime = 15;
    55.     [Range(1, 10)] public float PlayerRespawnTime = 10.0f;
    56.     [Range(1, 100)] public int MaxFriendsAdded = 35;
    57.     public float AFKTimeLimit = 30;
    58.     public int MaxChangeTeamTimes = 1;
    59.     public string MainMenuScene = "MainMenu";
    60.     public string OnDisconnectScene = "MainMenu";
    61.     public Color highLightColor = Color.green;
    62.  
    63.     [Header("Levels Manager")]
    64.     [Reorderable]
    65.     public List<SceneInfo> AllScenes = new List<SceneInfo>();
    66.  
    67.     [Header("Weapons")]
    68.     /* [Reorderable]*/
    69.     public List<bl_GunInfo> AllWeapons = new List<bl_GunInfo>();
    70.  
    71.     [Header("Default Settings")]
    72.     public DefaultSettingsData DefaultSettings;
    73.  
    74.     [Header("Game Modes Available"), Reorderable]
    75.     public List<GameModesEnabled> gameModes = new List<GameModesEnabled>();
    76.  
    77.     [Header("Teams")]
    78.     public string Team1Name = "Team1";
    79.     public Color Team1Color = Color.blue;
    80.     [Space(5)]
    81.     public string Team2Name = "Team2";
    82.     public Color Team2Color = Color.green;
    83.  
    84.     [Header("Players")]
    85.     public bl_PlayerNetwork Player1;
    86.     public bl_PlayerNetwork Player2;
    87.  
    88.     [Header("Bots")]
    89.     public bl_AIShooterAgent BotTeam1;
    90.     public bl_AIShooterAgent BotTeam2;
    91.  
    92.     [Header("Game Team")]
    93.     public List<GameTeamInfo> GameTeam = new List<GameTeamInfo>();
    94.  
    95.     public GameTeamInfo CurrentTeamUser { get; set; } = null;
    96.     [HideInInspector] public bool isChating = false;
    97.  
    98.     [HideInInspector] public string _MFPSLicense = string.Empty;
    99.     [HideInInspector] public int _MFPSFromStore = 2;
    100.     [HideInInspector] public string _keyToken = "";
    101.  
    102.     public bl_GunInfo GetWeapon(int ID)
    103.     {
    104.         if (ID < 0 || ID > AllWeapons.Count - 1)
    105.             return AllWeapons[0];
    106.      
    107.         return AllWeapons[ID];
    108.     }
    109.  
    110.     public string[] AllWeaponStringList()
    111.     {
    112.         return AllWeapons.Select(x => x.Name).ToList().ToArray();
    113.     }
    114.  
    115.     public int GetWeaponID(string gunName)
    116.     {
    117.         int id = -1;
    118.         if(AllWeapons.Exists(x => x.Name == gunName))
    119.         {
    120.             id = AllWeapons.FindIndex(x => x.Name == gunName);
    121.         }
    122.         return id;
    123.     }
    124.  
    125.     /// <summary>
    126.     ///
    127.     /// </summary>
    128.     public int CheckPlayerName(string pName)
    129.     {
    130.         for (int i = 0; i < GameTeam.Count; i++)
    131.         {
    132.             if (pName == GameTeam[i].UserName)
    133.             {
    134.                 return 1;
    135.             }
    136.         }
    137.         if (pName.Contains('[') || pName.Contains('{'))
    138.         {
    139.             return 2;
    140.         }
    141.         CurrentTeamUser = null;
    142.         return 0;
    143.     }
    144.  
    145.     /// <summary>
    146.     ///
    147.     /// </summary>
    148.     public bool CheckPasswordUse(string PName, string Pass)
    149.     {
    150.         for (int i = 0; i < GameTeam.Count; i++)
    151.         {
    152.             if (PName == GameTeam[i].UserName)
    153.             {
    154.                if(Pass == GameTeam[i].Password)
    155.                 {
    156.                     CurrentTeamUser = GameTeam[i];
    157.                     return true;
    158.                 }
    159.             }
    160.         }
    161.         return false;
    162.     }
    163.  
    164.     /// <summary>
    165.     ///
    166.     /// </summary>
    167. #if CLANS
    168.     private string _role = string.Empty;
    169. #endif
    170.     public string RolePrefix
    171.     {
    172.         get
    173.         {
    174. #if !CLANS
    175.             if (CurrentTeamUser != null && !string.IsNullOrEmpty(CurrentTeamUser.UserName));
    176.             {
    177.                 return string.Format("<color=#{1}>[{0}]</color>", CurrentTeamUser.m_Role.ToString(), ColorUtility.ToHtmlStringRGBA(CurrentTeamUser.m_Color))
    178.             }
    179.             else
    180.             {
    181.                 return string.Empty;
    182.             }
    183. #else
    184.             if(bl_DataBase.Instance == null || !bl_DataBase.Instance.isLogged || !bl_DataBase.Instance.LocalUser.Clan.haveClan)
    185.             {
    186.                 return string.Empty;
    187.             }
    188.             else
    189.             {
    190.                 if (string.IsNullOrEmpty(_role));
    191.                 {
    192.                     _role = string.Format("[{0}]", bl_DataBase.Instance.LocalUser.Clan.Name);
    193.                 }
    194.                 return _role;
    195.             }
    196. #endif
    197.         }
    198.  
    199.     }
    200.  
    201.     void OnDisable()
    202.     {
    203.         isDataCached = false;
    204.     }
    205.  
    206.     [System.Serializable]
    207.     public class GameTeamInfo
    208.     {
    209.         public string UserName;
    210.         public Role m_Role = Role.Moderator;
    211.         public string Password;
    212.         public Color m_Color;
    213.  
    214.         public enum Role
    215.         {
    216.             Admin = 0,
    217.             Moderator = 1,
    218.         }
    219.     }
    220.  
    221.     /// <summary>
    222.     /// cache the GameData from Resources asynchronous to avoid overhead and freeze the main thread the first time we access to the instance
    223.     /// </summary>
    224.     /// <returns></returns>
    225.     public static IEnumerator AsyncLoadData()
    226.     {
    227.         if (m_Data == null)
    228.         {
    229.             isCaching = true;
    230.             ResourceRequest rr = Resources.LoadAsync("GameData", typeof(bl_GameData));
    231.             while (!rr.isDone) { yield return null; }
    232.             m_Data = rr.asset as bl_GameData;
    233.             isCaching = false;
    234.         }
    235.         isDataCached = true;
    236.     }
    237.  
    238.     public static bool isDataCached = false;
    239.     private static bool isCaching = false;
    240.     private static bl_GameData m_Data;
    241.     public static bl_GameData Instance
    242.     {
    243.         get
    244.         {
    245.             if (m_Data == null && !isCaching)
    246.             {
    247.                 m_Data = Resources.Load("GameData", typeof(bl_GameData)) as bl_GameData;
    248.             }
    249.             return m_Data;
    250.         }
    251.     }
    252.  
    253.     [System.Serializable]
    254.     public class ScoreRewards
    255.     {
    256.         public int ScorePerKill = 50;
    257.         public int ScorePerHeadShot = 25;
    258.         public int ScoreForWinMatch = 100;
    259.         [Tooltip("Per minute played")]
    260.         public int ScorePerTimePlayed = 3;
    261.     }
    262.  
    263.     [System.Serializable]
    264.     public class VirtualCoin
    265.     {
    266.         public int InitialCoins = 1000;
    267.         [Tooltip("how much score/xp worth one coin")]
    268.         public int CoinScoreValue = 1000;//how much score/xp worth one coin
    269.  
    270.         public int UserCoins { get; set; }
    271.  
    272.         public void LoadCoins(string userName)
    273.         {
    274.             UserCoins = PlayerPrefs.GetInt(string.Format("{0}.{1}", userName, PropertiesKeys.UserCoins), InitialCoins);
    275.         }
    276.  
    277.         public void SetCoins(int coins, string userName)
    278.         {
    279.             LoadCoins(userName);
    280.             int total = UserCoins + coins;
    281.             PlayerPrefs.SetInt(string.Format("{0}.{1}", userName, PropertiesKeys.UserCoins), total);
    282.             UserCoins = total;
    283.         }
    284.     }
    285.  
    286. #if UNITY_EDITOR
    287.     void OnValidate()
    288.     {
    289.         for (int i = 0; i < AllScenes.Count; i++)
    290.         {
    291.             if (AllScenes[i].m_Scene == null) continue;
    292.             AllScenes[i].RealSceneName = AllScenes[i].m_Scene.name;
    293.         }
    294.     }
    295. #endif
    296.  
    297.     [Serializable]
    298.     public class SceneInfo
    299.     {
    300.         public string ShowName;
    301.         [SerializeField]
    302.         public Object m_Scene;
    303.         [HideInInspector] public string RealSceneName;
    304.         [SpritePreview] public Sprite Preview;
    305.     }
    306.  
    307.     [Serializable]
    308.     public class DefaultSettingsData
    309.     {
    310.         [Range(1, 20)] public float DefaultSensitivity = 5.0f;
    311.         [Range(1, 20)] public float DefaultSensitivityAim = 2;
    312.         public int DefaultQualityLevel = 3;
    313.         public int DefaultAnisoTropic = 2;
    314.         [Range(0, 1)] public float DefaultVolume = 1;
    315.         [Range(40, 100)] public int DefaultWeaponFoV = 60;
    316.         public bool DefaultShowFrameRate = false;
    317.         public bool DefaultMotionBlur = true;
    318.         public int[] frameRateOptions = new int[] { 30, 60, 120, 144, 200, 260, 0 };
    319.         public int defaultFrameRate = 2;
    320.     }
    321.  
    322.     [Serializable]
    323.     public class GameModesEnabled
    324.     {
    325.         public string ModeName;
    326.         public GameMode gameMode;
    327.         public bool isEnabled = true;
    328.  
    329.         [Header("Settings")]
    330.         public bool AutoTeamSelection = false;
    331.         [Range(1,16)] public int RequiredPlayersToStart = 1;
    332.         public int[] GameGoalsOptions = new int[] { 50, 100, 150, 200 };
    333.         public string GoalName = "Kills";
    334.         public OnRoundStartedSpawn onRoundStartedSpawn = OnRoundStartedSpawn.SpawnAfterSelectTeam;
    335.         public OnPlayerDie onPlayerDie = OnPlayerDie.SpawnAfterDelay;
    336.  
    337.         public string GetGoalFullName(int goalID) { return string.Format("{0} {1}", GameGoalsOptions[goalID], GoalName); }
    338.  
    339.         [System.Serializable]
    340.         public enum OnRoundStartedSpawn
    341.         {
    342.             SpawnAfterSelectTeam,
    343.             WaitUntilRoundFinish,
    344.         }
    345.  
    346.         [System.Serializable]
    347.         public enum OnPlayerDie
    348.         {
    349.             SpawnAfterDelay,
    350.             SpawnAfterRoundFinish,
    351.         }
    352.     }
    353. }
     
  8. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    u missed the ; on line 35.

    but i´m not sure if it will work like that. If your bl_Database class itself is not static you will get nullpointexception with that way ( i guess).

    *If you make your bl_Database class static you don´t need the defining.

    do that in the class:

    Code (CSharp):
    1. public static class bl_DataBase()
    2. {
    3.     // Code of the class
    4. }
    Then it should work like you had it before with calling bl_DataBase.Instance
     
  9. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    it not work
     
  10. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    ok, so what you did now and what´s the error ?
     
  11. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    You also can try to remove the static modifier again from the class itself and do the following in the bl_DataBase class:

    Code (CSharp):
    1. public class bl_DataBase()
    2. {
    3.     private static final bl_DataBase _instance = new bl_DataBase();
    4.  
    5.     public static bl_DataBase Instance() {
    6.         return _instance;
    7.     }
    8. }
     
  12. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    back at square one
    My errors are:
    Assets\MFPS\Scripts\Core\bl_GameData.cs(183,16): error CS0103: The name 'bl_DataBase' does not exist in the current context
    Assets\MFPS\Scripts\Core\bl_GameData.cs(183,49): error CS0103: The name 'bl_DataBase' does not exist in the current context
    Assets\MFPS\Scripts\Core\bl_GameData.cs(183,83): error CS0103: The name 'bl_DataBase' does not exist in the current context
    Assets\MFPS\Scripts\Core\bl_GameData.cs(191,52): error CS0103: The name 'bl_DataBase' does not exist in the current context
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using System.Linq;
    5. using System;
    6. using UnityEngine.SceneManagement;
    7. using Object = UnityEngine.Object;
    8. using MFPSEditor;
    9.  
    10. public class bl_GameData : ScriptableObject
    11. {
    12.     [Header("Game Settings")]
    13.     public bool offlineMode = true;
    14.     public bool UseLobbyChat = true;
    15.     public bool UseVoiceChat = false;
    16.     public bool BulletTracer = false;
    17.     public bool DropGunOnDeath = true;
    18.     public bool SelfGrenadeDamage = true;
    19.     public bool CanFireWhileRunning = true;
    20.     public bool HealthRegeneration = true;
    21.     public bool ShowTeamMateHealthBar = true;
    22.     public bool CanChangeTeam = false;
    23.     public bool ShowBlood = false;
    24.     public bool DetectAFK = true;
    25.     public bool MasterCanKickPlayers = true;
    26.     public bool ArriveKitsCauseDamage = true;
    27.     public bool CalculateNetworkFootSteps = false;
    28.     public bool ShowNetworkStats = false;
    29.     public bool RememberPlayerName = true;
    30.     public bool ShowWeaponLoadout = true;
    31.     public bool useCountDownOnStart = true;
    32.     public bool showCrosshair = true;
    33.     public bool doSpawnHandMeshEffect = true;
    34.     public bool playerCameraWiggle = true;
    35. #if MFPSM
    36.     public bool AutoWeaponFire = true;
    37. #endif
    38. #if LM
    39.     public bool LockWeaponsByLevel = true;
    40. #endif
    41.     public AmmunitionType AmmoType = AmmunitionType.Bullets;
    42.     public KillFeedWeaponShowMode killFeedWeaponShowMode = KillFeedWeaponShowMode.WeaponIcon;
    43.     public LobbyJoinMethod lobbyJoinMethod = LobbyJoinMethod.WaitingRoom;
    44.     public bl_KillCam.KillCameraType killCameraType = bl_KillCam.KillCameraType.ObserveDeath;
    45.  
    46.     [Header("Rewards")]
    47.     public ScoreRewards ScoreReward;
    48.     public VirtualCoin VirtualCoins;
    49.  
    50.     [Header("Settings")]
    51.     public string GameVersion = "1.0";
    52.     [Range(0, 10)] public int SpawnProtectedTime = 5;
    53.     [Range(1, 60)] public int CountDownTime = 15;
    54.     [Range(1, 10)] public float PlayerRespawnTime = 10.0f;
    55.     [Range(1, 100)] public int MaxFriendsAdded = 35;
    56.     public float AFKTimeLimit = 30;
    57.     public int MaxChangeTeamTimes = 1;
    58.     public string MainMenuScene = "MainMenu";
    59.     public string OnDisconnectScene = "MainMenu";
    60.     public Color highLightColor = Color.green;
    61.  
    62.     [Header("Levels Manager")]
    63.     [Reorderable]
    64.     public List<SceneInfo> AllScenes = new List<SceneInfo>();
    65.  
    66.     [Header("Weapons")]
    67.     /* [Reorderable]*/
    68.     public List<bl_GunInfo> AllWeapons = new List<bl_GunInfo>();
    69.  
    70.     [Header("Default Settings")]
    71.     public DefaultSettingsData DefaultSettings;
    72.  
    73.     [Header("Game Modes Available"), Reorderable]
    74.     public List<GameModesEnabled> gameModes = new List<GameModesEnabled>();
    75.  
    76.     [Header("Teams")]
    77.     public string Team1Name = "Team1";
    78.     public Color Team1Color = Color.blue;
    79.     [Space(5)]
    80.     public string Team2Name = "Team2";
    81.     public Color Team2Color = Color.green;
    82.  
    83.     [Header("Players")]
    84.     public bl_PlayerNetwork Player1;
    85.     public bl_PlayerNetwork Player2;
    86.  
    87.     [Header("Bots")]
    88.     public bl_AIShooterAgent BotTeam1;
    89.     public bl_AIShooterAgent BotTeam2;
    90.  
    91.     [Header("Game Team")]
    92.     public List<GameTeamInfo> GameTeam = new List<GameTeamInfo>();
    93.  
    94.     public GameTeamInfo CurrentTeamUser { get; set; } = null;
    95.     [HideInInspector] public bool isChating = false;
    96.  
    97.     [HideInInspector] public string _MFPSLicense = string.Empty;
    98.     [HideInInspector] public int _MFPSFromStore = 2;
    99.     [HideInInspector] public string _keyToken = "";
    100.  
    101.     public bl_GunInfo GetWeapon(int ID)
    102.     {
    103.         if (ID < 0 || ID > AllWeapons.Count - 1)
    104.             return AllWeapons[0];
    105.      
    106.         return AllWeapons[ID];
    107.     }
    108.  
    109.     public string[] AllWeaponStringList()
    110.     {
    111.         return AllWeapons.Select(x => x.Name).ToList().ToArray();
    112.     }
    113.  
    114.     public int GetWeaponID(string gunName)
    115.     {
    116.         int id = -1;
    117.         if(AllWeapons.Exists(x => x.Name == gunName))
    118.         {
    119.             id = AllWeapons.FindIndex(x => x.Name == gunName);
    120.         }
    121.         return id;
    122.     }
    123.  
    124.     /// <summary>
    125.     ///
    126.     /// </summary>
    127.     public int CheckPlayerName(string pName)
    128.     {
    129.         for (int i = 0; i < GameTeam.Count; i++)
    130.         {
    131.             if (pName == GameTeam[i].UserName)
    132.             {
    133.                 return 1;
    134.             }
    135.         }
    136.         if (pName.Contains('[') || pName.Contains('{'))
    137.         {
    138.             return 2;
    139.         }
    140.         CurrentTeamUser = null;
    141.         return 0;
    142.     }
    143.  
    144.     /// <summary>
    145.     ///
    146.     /// </summary>
    147.     public bool CheckPasswordUse(string PName, string Pass)
    148.     {
    149.         for (int i = 0; i < GameTeam.Count; i++)
    150.         {
    151.             if (PName == GameTeam[i].UserName)
    152.             {
    153.                if(Pass == GameTeam[i].Password)
    154.                 {
    155.                     CurrentTeamUser = GameTeam[i];
    156.                     return true;
    157.                 }
    158.             }
    159.         }
    160.         return false;
    161.     }
    162.  
    163.     /// <summary>
    164.     ///
    165.     /// </summary>
    166. #if CLANS
    167.     private string _role = string.Empty;
    168. #endif
    169.     public string RolePrefix
    170.     {
    171.         get
    172.         {
    173. #if !CLANS
    174.             if (CurrentTeamUser != null && !string.IsNullOrEmpty(CurrentTeamUser.UserName));
    175.             {
    176.                 return string.Format("<color=#{1}>[{0}]</color>", CurrentTeamUser.m_Role.ToString(), ColorUtility.ToHtmlStringRGBA(CurrentTeamUser.m_Color))
    177.             }
    178.             else
    179.             {
    180.                 return string.Empty;
    181.             }
    182. #else
    183.             if(bl_DataBase.Instance == null || !bl_DataBase.Instance.isLogged || !bl_DataBase.Instance.LocalUser.Clan.haveClan)
    184.             {
    185.                 return string.Empty;
    186.             }
    187.             else
    188.             {
    189.                 if (string.IsNullOrEmpty(_role));
    190.                 {
    191.                     _role = string.Format("[{0}]", bl_DataBase.Instance.LocalUser.Clan.Name);
    192.                 }
    193.                 return _role;
    194.             }
    195. #endif
    196.         }
    197.  
    198.     }
    199.  
    200.     void OnDisable()
    201.     {
    202.         isDataCached = false;
    203.     }
    204.  
    205.     [System.Serializable]
    206.     public class GameTeamInfo
    207.     {
    208.         public string UserName;
    209.         public Role m_Role = Role.Moderator;
    210.         public string Password;
    211.         public Color m_Color;
    212.  
    213.         public enum Role
    214.         {
    215.             Admin = 0,
    216.             Moderator = 1,
    217.         }
    218.     }
    219.  
    220.     /// <summary>
    221.     /// cache the GameData from Resources asynchronous to avoid overhead and freeze the main thread the first time we access to the instance
    222.     /// </summary>
    223.     /// <returns></returns>
    224.     public static IEnumerator AsyncLoadData()
    225.     {
    226.         if (m_Data == null)
    227.         {
    228.             isCaching = true;
    229.             ResourceRequest rr = Resources.LoadAsync("GameData", typeof(bl_GameData));
    230.             while (!rr.isDone) { yield return null; }
    231.             m_Data = rr.asset as bl_GameData;
    232.             isCaching = false;
    233.         }
    234.         isDataCached = true;
    235.     }
    236.  
    237.     public static bool isDataCached = false;
    238.     private static bool isCaching = false;
    239.     private static bl_GameData m_Data;
    240.     public static bl_GameData Instance
    241.     {
    242.         get
    243.         {
    244.             if (m_Data == null && !isCaching)
    245.             {
    246.                 m_Data = Resources.Load("GameData", typeof(bl_GameData)) as bl_GameData;
    247.             }
    248.             return m_Data;
    249.         }
    250.     }
    251.  
    252.     [System.Serializable]
    253.     public class ScoreRewards
    254.     {
    255.         public int ScorePerKill = 50;
    256.         public int ScorePerHeadShot = 25;
    257.         public int ScoreForWinMatch = 100;
    258.         [Tooltip("Per minute played")]
    259.         public int ScorePerTimePlayed = 3;
    260.     }
    261.  
    262.     [System.Serializable]
    263.     public class VirtualCoin
    264.     {
    265.         public int InitialCoins = 1000;
    266.         [Tooltip("how much score/xp worth one coin")]
    267.         public int CoinScoreValue = 1000;//how much score/xp worth one coin
    268.  
    269.         public int UserCoins { get; set; }
    270.  
    271.         public void LoadCoins(string userName)
    272.         {
    273.             UserCoins = PlayerPrefs.GetInt(string.Format("{0}.{1}", userName, PropertiesKeys.UserCoins), InitialCoins);
    274.         }
    275.  
    276.         public void SetCoins(int coins, string userName)
    277.         {
    278.             LoadCoins(userName);
    279.             int total = UserCoins + coins;
    280.             PlayerPrefs.SetInt(string.Format("{0}.{1}", userName, PropertiesKeys.UserCoins), total);
    281.             UserCoins = total;
    282.         }
    283.     }
    284.  
    285. #if UNITY_EDITOR
    286.     void OnValidate()
    287.     {
    288.         for (int i = 0; i < AllScenes.Count; i++)
    289.         {
    290.             if (AllScenes[i].m_Scene == null) continue;
    291.             AllScenes[i].RealSceneName = AllScenes[i].m_Scene.name;
    292.         }
    293.     }
    294. #endif
    295.  
    296.     [Serializable]
    297.     public class SceneInfo
    298.     {
    299.         public string ShowName;
    300.         [SerializeField]
    301.         public Object m_Scene;
    302.         [HideInInspector] public string RealSceneName;
    303.         [SpritePreview] public Sprite Preview;
    304.     }
    305.  
    306.     [Serializable]
    307.     public class DefaultSettingsData
    308.     {
    309.         [Range(1, 20)] public float DefaultSensitivity = 5.0f;
    310.         [Range(1, 20)] public float DefaultSensitivityAim = 2;
    311.         public int DefaultQualityLevel = 3;
    312.         public int DefaultAnisoTropic = 2;
    313.         [Range(0, 1)] public float DefaultVolume = 1;
    314.         [Range(40, 100)] public int DefaultWeaponFoV = 60;
    315.         public bool DefaultShowFrameRate = false;
    316.         public bool DefaultMotionBlur = true;
    317.         public int[] frameRateOptions = new int[] { 30, 60, 120, 144, 200, 260, 0 };
    318.         public int defaultFrameRate = 2;
    319.     }
    320.  
    321.     [Serializable]
    322.     public class GameModesEnabled
    323.     {
    324.         public string ModeName;
    325.         public GameMode gameMode;
    326.         public bool isEnabled = true;
    327.  
    328.         [Header("Settings")]
    329.         public bool AutoTeamSelection = false;
    330.         [Range(1,16)] public int RequiredPlayersToStart = 1;
    331.         public int[] GameGoalsOptions = new int[] { 50, 100, 150, 200 };
    332.         public string GoalName = "Kills";
    333.         public OnRoundStartedSpawn onRoundStartedSpawn = OnRoundStartedSpawn.SpawnAfterSelectTeam;
    334.         public OnPlayerDie onPlayerDie = OnPlayerDie.SpawnAfterDelay;
    335.  
    336.         public string GetGoalFullName(int goalID) { return string.Format("{0} {1}", GameGoalsOptions[goalID], GoalName); }
    337.  
    338.         [System.Serializable]
    339.         public enum OnRoundStartedSpawn
    340.         {
    341.             SpawnAfterSelectTeam,
    342.             WaitUntilRoundFinish,
    343.         }
    344.  
    345.         [System.Serializable]
    346.         public enum OnPlayerDie
    347.         {
    348.             SpawnAfterDelay,
    349.             SpawnAfterRoundFinish,
    350.         }
    351.     }
    352. }
     
  13. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    hmm that´s strange. but bl_DataBase is a script that exists correct ? Is it an "L" in the name or a "1" (one) in the name ? Could that be the problem ?
     
  14. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    it's an L, not a one. I have double-checked it
     
  15. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    then i have no more ideas to be honest. can you post your bl_DataBase script maybe there is something missing
     
  16. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    well, I could simplify it. Actually I don't really need this line of code?
     
  17. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    yes sure you can, but if you have to check that values you will need it i guess.

    *Can you post the bl_DataBase script ?
     
  18. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    i can do it but it's just the role prefix that is the issue
     
  19. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    That´s the only thing we can check for now. It´s up to you, but otherwise i have no more idea
     
  20. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    alright i fixed it! thanks
     
  21. TwoTeraBytes

    TwoTeraBytes

    Joined:
    Oct 8, 2020
    Posts:
    14
    have a nice day!
     
  22. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    thx u². and gl furthermore :)