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
49 stars 10 forks source link

GM Command #2629

Closed moepi2k closed 5 days ago

moepi2k commented 1 week ago

default gm command now works across map server but there is still a problem when wnat to modify e.g this

protected void HandleGMCommand_kick(string sender, BasePlayerCharacterEntity characterEntity, string command, string[] data)
{
    if (command.Equals(kickCommand.ToLower()) && data.Length == 2)// && characterEntity != null)
    {
        BasePlayerCharacterEntity targetCharacter;
        if (!GameInstance.ServerUserHandlers.TryGetPlayerCharacterByName(data[1], out targetCharacter))
        {
            s_responseGmCommand = "<color=red>Data invalid</color>";
        }
        else if (enforceRelativePlayerLevel && targetCharacter.UserLevel > characterEntity.UserLevel)
        {
            s_responseGmCommand = $"<color=red>You cannot perform this command on {data[1]}</color>";
        }
        else
        {
            BaseGameNetworkManager.Singleton.KickClient(targetCharacter.ConnectionId, UITextKeys.UI_ERROR_KICKED_FROM_SERVER);
            s_responseGmCommand = $"<color=green>{data[1]} kicked from server</color>";
        }
    }
}

added logic so player with lower level cant perform commands on higher level gm. but the problem is across map server the characterEntity is always null which means this function would work only when both player are on same mapserver

insthync commented 6 days ago

If you are running MMORPG game then you can get user level from a database, you may find which character is sending command by using the sender value, then find user level by character's user id

moepi2k commented 6 days ago

its not the problem to get user level. the proble is that characterEntity is null across map server. the userlevel thing works fine on same mapserver

insthync commented 6 days ago

Yes, characterEntity will be null so I told you to get it from database by using sender parameter

moepi2k commented 6 days ago

Yea i get this, but why we have characterentity in the argument then, when its not working.is it something u will change in future?

insthync commented 6 days ago

For better performance and convenience but if it is really not be able to get character entity because it is in difference server then you must get info from database.

moepi2k commented 6 days ago

Ok thx for clarify that helped