d0p3t / fivem-js

Javascript and Typescript wrapper for the FiveM natives API
https://d0p3t.nl
Other
143 stars 57 forks source link

UI doesn't apper #27

Closed DaBultz closed 4 years ago

DaBultz commented 5 years ago

Hey, currently testing out this libary and trying to have a text appear on the screen using the following code:

import * as Cfx from 'fivem-js';

setInterval(async () => {
    let test = new Cfx.Text("", {x: 0.5, y: 0.5}, 0.5, {r: 0, g: 0, b: 0, a: 255}, 0, false);
    test.draw("Hello World!")
}, 1000/240);

Compiles fine and run fine, but no text appears on the screen.

d0p3t commented 5 years ago

I've gotten some questions elsewhere about this. I'll review Cfx.Text by the end of the weekend

d0p3t commented 5 years ago

I was able to draw text on the screen, but it does not behave as it should. https://i.d0p3t.nl/u/C34sJ8BWaA.png

import * as Cfx from 'fivem-js';

let enabled = false;
let test;

setImmediate(() => {
  test = new Cfx.Text("", new Cfx.Point(500, 500), 1, new Cfx.Color(255, 255, 0, 0), 0, true);
})
setTick(() => {

  if(enabled){
    test.draw("DaBultz", new Cfx.Point(500, 500), 1, new Cfx.Color(255, 255, 0, 0), 0, true);
  }

  if(Cfx.Game.isControlJustPressed(0, Cfx.Control.Context)) {
    enabled = !enabled;
  }
})

One shouldn't have to call draw() with more than just the caption (if at all). Therefore, there's little flexibility to this class. I will change this issue to a bug and fix it in the next update.