Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Example usage:
- addEventHandler("onClientResourceStart", root, function()
- create3DText("Test", 705.83, -159.25, 32.01, "arial", 1.0, 255, 255, 255, 255, 200, true)
- create3DText("Test String but below the other one", 705.83, -159.25, 25.01, "bankgothic", 2.0, 255, 255, 255, 255, 200, true)
- -- Arguments: text, X, Y, Z, font, size, r, g, b, a, d, testlos
- end)
- local texts = {}
- function create3DText(string, x, y, z, font, fontsize, r, g, b, a, distance, testlos)
- local text = {}
- text.string = string
- text.x = x
- text.y = y
- text.z = z
- text.font = font or "arial"
- text.fontsize = fontsize or 1.0
- text.r = r or 255
- text.g = g or 255
- text.b = b or 255
- text.a = a or 255
- text.distance = distance or 150
- text.testlos = (type(testlos) == "nil" and false or testlos)
- table.insert(texts, text)
- end
- addEventHandler("onClientRender", root, function()
- for i, value in ipairs(texts) do
- local self = texts[i]
- local x, y, z = getElementPosition(getLocalPlayer())
- local distance = getDistanceBetweenPoints3D(self.x, self.y, self.z, x, y, z)
- if distance <= self.distance then
- local cx, cy, cz, clx, cly, clz = getCameraMatrix()
- if not self.testlos or (self.testlos and isLineOfSightClear(cx, cy, cz, self.x, self.y, self.z, true, false, true, true, false, false, true)) then
- local scale = self.fontsize - ((distance / self.distance) * self.fontsize)
- local sx, sy = getScreenFromWorldPosition(self.x, self.y, self.z, dxGetTextWidth(self.string, scale, self.font, true), false)
- if sx and sy then
- dxDrawText(self.string, sx, sy, _, _, tocolor(self.r, self.g, self.b, self.a), scale, self.font, "center", "center", false, false, false, true)
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment