我做了这个脚本:
setInterval(myTimer, 1000);
function myTimer() {
const player = PlayerId()
const ped = GetPlayerPed(player);
const [playerX, playerY, playerZ] = GetEntityCoords(ped);
coordsX(playerX)
coordsY(playerY)
coordsZ(playerZ)
setTimeout(() => {
coordsX(playerX);
coordsY(playerY);
coordsZ(playerZ);
}, 5000);
}
基本上,它每秒都会更改 coordsX、coordsY 和 coordsZ 函数,但问题是文本不会在屏幕上停留超过一个刻度,并且它只会在一秒钟后再次显示,再次只有一个刻度。我想要它使文本保持打开并冻结一秒钟,然后再次重新加载。
这是其余的代码(即上面):
const height = 0.780
const beginning = 0.020
const add = 0.050
function coordsX(coordsX) {
SetTextFont(0);
SetTextProportional(1);
SetTextScale(0.0, 0.3);
SetTextColour(26, 255, 0, 255);
SetTextDropshadow(0, 0, 0, 0, 255);
SetTextEdge(1, 0, 0, 0, 255);
SetTextDropShadow();
SetTextOutline();
SetTextEntry("STRING");
AddTextComponentString('X: ' + coordsX.toFixed(2));
DrawText(beginning, height);
}
function coordsY(coordsY) {
SetTextFont(0);
SetTextProportional(1);
SetTextScale(0.0, 0.3);
SetTextColour(26, 255, 0, 255);
SetTextDropshadow(0, 0, 0, 0, 255);
SetTextEdge(1, 0, 0, 0, 255);
SetTextDropShadow();
SetTextOutline();
SetTextEntry("STRING");
AddTextComponentString('Y: ' + coordsY.toFixed(2));
DrawText(beginning + add, height);
}
function coordsZ(coordsZ) {
SetTextFont(0);
SetTextProportional(1);
SetTextScale(0.0, 0.3);
SetTextColour(26, 255, 0, 255);
SetTextDropshadow(0, 0, 0, 0, 255);
SetTextEdge(1, 0, 0, 0, 255);
SetTextDropShadow();
SetTextOutline();
SetTextEntry("STRING");
AddTextComponentString('Z: ' + coordsZ.toFixed(2));
DrawText(beginning + add*2, height);
}