import express from 'express';

export async function CharacterIsIngame(req: express.Request, res: express.Response): Promise<void> {
    if (!req.params.characterId) {
        res.status(400).send('Missing parameter');
    }

    if (!Number(req.params.characterId)) {
        res.status(500).send('Unable to parse given parameter');
    }

    const character = mp.players.toArray().find((player) => player.character?.id === Number(req.params.characterId));
    res.send(character ? 'yes' : 'no');
}
