Jump to content
alt:V Multiplayer Forum

abstractFlo

Member
  • Content Count

    2
  • Joined

  • Last visited

  • Days Won

    1

abstractFlo last won the day on June 10

abstractFlo had the most liked content!

Community Reputation

2 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. The purpose of a community is to share things. So once you've found a solution, share it with the community just as the community shares things with you.
  2. Hey guys, this is my port of Scaleform Class from a RageMP User Here you can use it if you want. import alt from 'alt' import game from 'natives' export default class Scaleforms { constructor (scaleform, name) { this.scaleform = game.requestScaleformMovieInstance(scaleform) this.queue = new Map() this.renderTargetID = -1 } get isLoaded () { return game.hasScaleformMovieLoaded(this.scaleform) } get isValid () { return this.scaleform !== 0 } call (name, ...args) { if(this.isLoaded && this.isValid) { game.beginScaleformMovieMethod(this.scaleform, name) args.forEach(arg => { switch(typeof arg) { case 'string': game.addScaleformMovieMethodParameterString(arg) break case 'boolean': game.addScaleformMovieMethodParameterBool(arg) break case 'number': if(Number(arg) === arg && arg % 1 !== 0) { game.addScaleformMovieMethodParameterFloat(arg) } else { game.addScaleformMovieMethodParameterInt(arg) } } }) game.endScaleformMovieMethod() } else { this.queue.set(name, args) } } onUpdate () { if(this.isLoaded && this.isValid) { this.queue.forEach((args, name) => { this.call(name, ...args) this.queue.delete(name) }) } } renderOnUpdate (render, methodName, ...args) { alt.on('update', () => { if(render) { this[methodName].call(this, ...args) } }) } render2D (x = 0, y = 0, width = 1, height = 1) { this.onUpdate() if(this.isLoaded && this.isValid) { if(this.renderTargetID !== -1) { game.setTextRenderId(this.renderTargetID) } if(typeof x === 'boolean') { game.drawScaleformMovieFullscreen(this.scaleform, 255, 255, 255, 255, false) } else { game.drawScaleformMovie(this.scaleform, x, y, width, height, 255, 255, 255, 255, false) } if(this.renderTargetID !== -1) { game.setTextRenderId(1) } } } render3D (position, rotation, scale) { this.onUpdate() if(this.isLoaded && this.isValid) { if(this.renderTargetID !== -1) { game.setTextRenderId(this.renderTargetID) } game.drawScaleformMovie3dNonAdditive(this.scaleform, position.x, position.y, position.z, rotation.x, rotation.y, rotation.z, 2, 2, 1, scale.x, scale.y, scale.z, 2) if(this.renderTargetID !== -1) { game.setTextRenderId(1) } } } render3DAdditive (position, rotation, scale) { this.onUpdate() if(this.isLoaded && this.isValid) { if(this.renderTargetID !== -1) { game.setTextRenderId(this.renderTargetID) } game.drawScaleformMovie3d(this.scaleform, position.x, position.y, position.z, rotation.x, rotation.y, rotation.z, 2, 2, 1, scale.x, scale.y, scale.z, 2) if(this.renderTargetID !== -1) { game.setTextRenderId(1) } } } /** * Create a render target * * @param name * @param model */ createRenderTarget (name, model) { let modelHash = game.getHashKey(model) if(!game.isNamedRendertargetRegistered(name)) { game.registerNamedRendertarget(name) } if(!game.isNamedRendertargetLinked(modelHash)) { game.linkNamedRendertarget(modelHash) } if(game.isNamedRendertargetRegistered(name)) { this.renderTargetID = game.getNamedRendertargetRenderId(name) } } } You can use it like so import alt from 'alt' import game from 'natives' import Scaleform from 'path/to/resource/scaleform.mjs' let scaleform = new Scaleform('yourScaleForm') scaleform.createRenderTarget('RENDERTARGET_TYPE', 'PROP') scaleform.call('METHOD', ...props) scaleform.renderOnUpdate(true, 'render2D', x, y, w, h) There are so many methods, if you do not understand something, feel free to ask questions 😉 Kind regards abstractFlo
×
×
  • Create New...