export default function relativeVector() {
    mp.events.add("SERVER:setMarkerBehindVehicle", (vehicle: EntityMp) => {
        var boneIndex2 = vehicle.getBoneIndexByName("platelight");
        var boneIndex1 = vehicle.getBoneIndexByName("chassis_dummy");

        let posPlate = vehicle.getWorldPositionOfBone(boneIndex2);
        let posCentre = vehicle.getWorldPositionOfBone(boneIndex1);

        let plateVec = new mp.Vector3(posPlate.x, posPlate.y, posPlate.z);
        let lightVec = new mp.Vector3(posCentre.x, posCentre.y, posCentre.z);

        let posPL = lightVec.subtract(plateVec);

        let temp = new mp.Vector3(posPL.x * -1, posPL.y * -1, posPL.z * -1)

        let length = Math.sqrt((temp.x * temp.x) + (temp.y * temp.y) + (temp.z * temp.z));

        let x = temp.x / length;
        let y = temp.y / length;
        let z = temp.z / length;

        temp = new mp.Vector3(x, y, z - 1);

        let pos = plateVec.add(temp);

        mp.events.callRemote("CLIENT:setMarkerBehindVehicle", JSON.stringify(vehicle.remoteId), JSON.stringify(pos.x), JSON.stringify(pos.y), JSON.stringify(pos.z));
    });
}