Пример #1
0
        public object Invoke(EventContext context, IEntityManager entityManager)
        {
            var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]);

            var objectType = (int)context.Arguments[1];
            var objectId   = (int)context.Arguments[2];

            var objectEntity = objectType == (int)ObjectType.PlayerObject
                ? SampEntities.GetPlayerObjectId(playerEntity, objectId)
                : SampEntities.GetObjectId(objectId);

            if (!entityManager.Exists(playerEntity))
            {
                return(null);
            }

            // Allow unknown objects to be passed through to the event.

            _context.BaseContext = context;

            _context.Arguments[0] = playerEntity;
            _context.Arguments[1] = objectEntity;
            _context.Arguments[2] = context.Arguments[3];                     // modelId
            _context.Arguments[3] = new Vector3((float)context.Arguments[4], (float)context.Arguments[5],
                                                (float)context.Arguments[6]); // position

            return(_next(_context));
        }
        public object Invoke(EventContext context)
        {
            var inArgs       = context.Arguments;
            var playerEntity = SampEntities.GetPlayerId((int)inArgs[0]);

            var isPlayerObject = (bool)inArgs[1];
            var objectId       = (int)inArgs[2];

            var objectEntity = isPlayerObject
                ? SampEntities.GetPlayerObjectId(playerEntity, objectId)
                : SampEntities.GetObjectId(objectId);

            // Allow unknown objects to be passed through to the event.

            _context.BaseContext = context;

            var args = _context.Arguments;

            args[0] = playerEntity;
            args[1] = objectEntity;
            args[2] = inArgs[3];                                                         // response
            args[3] = new Vector3((float)inArgs[4], (float)inArgs[5], (float)inArgs[6]); // position
            args[4] = new Vector3((float)inArgs[7], (float)inArgs[8], (float)inArgs[9]); // rotation

            return(_next(_context));
        }
Пример #3
0
        public object Invoke(EventContext context, IEntityManager entityManager)
        {
            var inArgs       = context.Arguments;
            var playerEntity = SampEntities.GetPlayerId((int)inArgs[0]);

            if (!entityManager.Exists(playerEntity))
            {
                return(null);
            }

            var hitType = (int)context.Arguments[2];
            var hitId   = (int)context.Arguments[3];

            EntityId hit;

            switch ((BulletHitType)hitType)
            {
            case BulletHitType.Vehicle:
                hit = SampEntities.GetVehicleId(hitId);
                break;

            case BulletHitType.Object:
                hit = SampEntities.GetObjectId(hitId);
                break;

            case BulletHitType.Player:
                hit = SampEntities.GetPlayerId(hitId);
                break;

            case BulletHitType.PlayerObject:
                hit = SampEntities.GetPlayerObjectId(playerEntity, hitId);
                break;

            default:
                hit = default;
                break;
            }

            // It could be the hit entity does not exist, for instance if it is a player object created by
            // the streamer plugin. We can't however dismiss this event or else the user will not be able
            // to handle the event in some other way.

            _context.BaseContext = context;

            var args = _context.Arguments;

            args[0] = playerEntity;
            args[1] = inArgs[1];                                                         // weapon
            args[2] = hit;
            args[3] = new Vector3((float)inArgs[4], (float)inArgs[5], (float)inArgs[6]); // position

            return(_next(_context));
        }
Пример #4
0
        public object Invoke(EventContext context, IEntityManager entityManager)
        {
            var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]);
            var objectEntity = SampEntities.GetPlayerObjectId(playerEntity, (int)context.Arguments[1]);

            if (!entityManager.Exists(playerEntity))
            {
                return(null);
            }

            // Allow unknown objects to be passed through to the event.

            context.Arguments[0] = playerEntity;
            context.Arguments[1] = objectEntity;

            return(_next(context));
        }