Ejemplo n.º 1
0
        public override async Task RunImpl()
        {
            await Task.Run(() =>
            {
                L2Player player = _client.CurrentPlayer;
                L2Object obj    = null;

                if (_objectId == player.ObjId)
                {
                    obj = player;
                }
                else
                {
                    if (L2World.Instance.GetObject(_objectId) != null)
                    {
                        obj = L2World.Instance.GetObject(_objectId);
                    }
                }
                //fixed nullreference exception when obj is null
                Log.Debug($"Action Requested with { Utilz.GetTypeLower(obj).ToString() }  of ID : { _objectId.ToString()}");

                if (obj == null)
                {
                    Log.Debug("Action Requested Failed");
                    player.SendActionFailedAsync();
                    return;
                }

                switch (_actionId)
                {
                case 0:
                    obj.OnActionAsync(player);
                    break;

                case 1:
                    obj.OnActionShiftAsync(player);
                    break;

                default:
                    player.SendActionFailedAsync();
                    break;
                }
            });
        }