when I call this function
float x = 0, y = 0;
bool toscreen = API.World3dToScreen2d(x1, y1, z1, ref x, ref y);
I’m sure it’s because I’m using the ref
Does anyone have any solution?
when I call this function
float x = 0, y = 0;
bool toscreen = API.World3dToScreen2d(x1, y1, z1, ref x, ref y);
I’m sure it’s because I’m using the ref
Does anyone have any solution?
Can anybody help me?
are you sure that API.World3dToScreen2d(x1, y1, z1, ref x, ref y); returns a bool?
yes
it returns a bool and passes the values of x and y of the screen by ref
Try using GetScreenCoordFromWorldCoord
with the same arguments instead of World3dToScreen2d
, the native reference seems to have a note about World3dToScreen2d
being deprecated.
I.e.
float x = 0.0f;
float y = 0.0f;
bool onScreen = GetScreenCoordFromWorldCoord(posX, posY, posZ, ref y, ref x);
Thanks for the help, but the problem continues.
There’s also another method GetScreenCoordFromWorldCoord2
which does the same thing, have you given that a go?
Not yet, I’m going to test now.
by what I saw, the problem is in the arguments that use the ref
It worked, but it’s not working as it should.
is returning the wrong x and y values
it works, but it’s as if the function had a sleep
Use SetDrawOrigin
and ClearDrawOrigin
not World3dToScreen2d
I’ve never worked with these two, can you give me an example?
static void Texto3D(float x1, float y1,float z1,string text, int opacidade)
{
SetDrawOrigin(x1, y1, z1, 0);
SetTextScale(0.54f, 0.54f);
SetTextFont(4);
SetTextProportional(true);
SetTextColour(255, 255, 255, opacidade);
SetTextDropshadow(0, 0, 0, 0, opacidade);
SetTextEdge(2, 0, 0, 0, 150);
SetTextDropShadow();
SetTextOutline();
SetTextEntry(“STRING”);
SetTextCentre(true);
AddTextComponentString(text);
DrawText(0, 0);
ClearDrawOrigin();
}
I’m trying to use it this way.
private async Task OnTick()
{
Render3DText(Game.PlayerPed.Position, "Hello", 0);
await Delay(0);
}
static void Render3DText(Vector3 coords, string text, int opacidade)
{
SetTextScale(0.54f, 0.54f);
SetTextFont(4);
SetTextProportional(true);
SetTextColour(255, 255, 255, opacidade);
SetTextDropshadow(0, 0, 0, 0, opacidade);
SetTextEdge(2, 0, 0, 0, 150);
SetTextDropShadow();
SetTextOutline();
SetTextCentre(true);
SetDrawOrigin(coords.x, coords.y, coords.z, 0);
BeginTextCommandDisplayText("STRING");
AddTextComponentSubstringPlayerName(text) ;
EndTextCommandDisplayText(0, 0);
ClearDrawOrigin();
}
Try this?
I solved the problem, I created a loop inside the ontick, I thought this looping would be called several times, plus I was wrong, it was called only once.
I wanted to thank you for helping me, thank you.