suriyun-production / mmorpg-kit-docs

This is document for MMORPG KIT project (https://www.assetstore.unity3d.com/#!/content/110188?aid=1100lGeN)
https://suriyun-production.github.io/mmorpg-kit-docs
48 stars 11 forks source link

I cannot access the properties of people in the game #2320

Closed CLAXES closed 1 month ago

CLAXES commented 9 months ago

I'm trying to add a kingdom system to the game, but I can't reset the score of the people who are in the game GameInstance.ServerUserHandlers translates this as null Can you help at a time when you are available

namespace MultiplayerARPG.MMO
{
    public partial class MySQLDatabase
    {
        private void Start()
        {
            _ = CheckKing();
        }

        public async UniTask CheckKing()
        {
            while (true)
            {
                await UniTask.Delay(TimeSpan.FromSeconds(10));
                DateTime dailyCheck = new DateTime();
                await ExecuteReader((reader) =>
                {
                    if (reader.Read())
                    {
                        dailyCheck = reader.GetDateTime(0);
                    }
                }, "SELECT dailyCheck FROM checkking LIMIT 1");

                if (DateTime.Now.Date == dailyCheck.Date)
                {
                    await ExecuteNonQuery("CALL UpdateRank();");
                    await ExecuteNonQuery("CALL UpdateKing();");

                    foreach (IPlayerCharacterData playerCharacter in GameInstance.ServerUserHandlers.GetPlayerCharacters())
                        playerCharacter.kPoints = 0;
                }
            }
        }
    }
}
insthync commented 9 months ago

You can't access it, database management server is not part of map server, only map server can access GameInstance.ServerUserHandlers

insthync commented 9 months ago

Can you implement this part by using web-service? it actually can extend many things easily (mostly easier I think) by using web-service outside the Unity project.

CLAXES commented 9 months ago

Can you implement this part by using web-service? it actually can extend many things easily (mostly easier I think) by using web-service outside the Unity project.

is rest database client or something else

insthync commented 9 months ago

You can create a new service, it actually doesn't always have to extends from my codes