Taty Posted January 26, 2023 Posted January 26, 2023 mp.events.add({ 'entityStreamIn': (entity) => { if (entity.type !== 'vehicle') return; // Not a vehicle //create a basic label let label = mp.labels.new('my text here', entity.position, { los: false, font: 1, drawDistance: 100, } ); //trying to attach label to vehicle //i traied to delete this line to check if mp.labesl.new is the problem but everything that happens above is ok label.attachTo(entity, 0, 0, 0, 0, 0, 0, 0, false, false, false, false, 2, true); }, 'entityStreamOut': (entity) => { mp.events.callRemote('server:responseStream', (entity)); if (entity.type !== 'vehicle') return; // Not a vehicle //rest of code where label need to be deleted and other stuff.. } }); I'm trying to attach a label to a vehicle in 'entityStreamIn' and delete it in 'entityStreamOut'. Everything goes well but when I add the line to attach the vehicle label I get the error 'label.attachTo(entity, .....) is not a function' I understood that this function is used for the 'camera' but I looked for another function for attaching a text label to the car and I can't find it.
Xabi Posted January 27, 2023 Posted January 27, 2023 You need to wait for the label to be streamed until you can attach it.
Nutter Posted January 29, 2023 Posted January 29, 2023 (edited) Labels are not really world entities. They don't have script handles, and so you cannot use EntityMp.attachTo. Maybe constantly setting position could work, but that seems impractical. You're better off using mp.game.graphics.world3dToScreen2d to get the position of the vehicle or the position of a bone on the vehicle, and then draw your text using mp.game.graphics.drawText each frame using the render event. Edited January 29, 2023 by Nutter
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now