Jump to content

Infra

Member
  • Content Count

    3
  • Joined

  • Last visited

  • Days Won

    2

Infra last won the day on May 29

Infra had the most liked content!

Community Reputation

9 Neutral

Personal Information

  • Discord
    dnlk#1337

Recent Profile Visitors

179 profile views
  1. create3DText This function lets you create "3D Texts" anywhere in the world with no effort. Required Arguments: string: the text to create x: A floating point number representing the X coordinate on the map y: A floating point number representing the Y coordinate on the map z: A floating point number representing the Z coordinate on the map Optional Arguments: font: Either a custom DX font element or the name of a built-in DX font (default (Tahoma), default-bold, clear (Verdana), arial, sans, pricedown, bankgothic, diploma, beckett) fontsize: The size of the text r: The amount of red in the color (0-255) g: The amount of green in the color (0-255) b: The amount of blue in the color (0-255) a: The amount of alpha in the color (0-255) distance: Draw distance value in San Andreas units testlos: Test for line of sight (true/false) 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) ^ Paste this code somewhere in your script file ^ Example Usage addEventHandler("onClientResourceStart", root, function() create3DText("*some text* no testlos", 705.83, -159.25, 32.01, "beckett", 3.0, 255, 255, 255, 255, 200, false) create3DText("*some #FF0000c#ffa500o#ffff00l#00ff00o#0000ffr#551a8be#ff69b4d#FFFFFF text* with testlos", 705.83, -159.25, 25.01, "arial", 2.0, 255, 255, 255, 255, 200, true) end)
  2. I've updated the code because apparently there was a small issue when using a low overTime value (like ~500ms), which would sometimes lead to the ease process not ending cuz it, why the fuck ever, could overshoot sometimes.
  3. easeGameSpeed This function changes the players game speed step by step (that way it appears smoother) I'm using this in my maps a lot and in my opinion it makes a huge difference Difference between setGameSpeed and easeGameSpeed: local ease = {} function easeGameSpeed(targetSpeed, overTime, callback) ease.startedAt = getTickCount() ease.startSpeed = getGameSpeed() ease.targetSpeed = math.round(targetSpeed, 4, "floor") ease.overTime = overTime ease.callback = (type(callback) == "function" or type(callback) == "nil") and (type(callback) == "function" and callback or nil) or nil ease.isActive = true end addEventHandler("onClientRender", root, function() if ease.isActive then local progress = (getTickCount() - ease.startedAt) / ((ease.startedAt + ease.overTime) - ease.startedAt) local currentSpeed = math.round(getGameSpeed(), 1, (ease.startSpeed > ease.targetSpeed and "ceil" or "floor")) local X, Y, Z = interpolateBetween(currentSpeed, 0.0, 0.0, ease.targetSpeed, 0.0, 0.0, progress, "InOutQuad") X = math.round(X, 4, (ease.startSpeed > ease.targetSpeed and "floor" or "ceil")) if ease.startSpeed > ease.targetSpeed and X <= ease.targetSpeed then X = math.round(X, 1, "ceil") elseif ease.startSpeed < ease.targetSpeed and X >= ease.targetSpeed then X = math.round(X, 1, "floor") end setGameSpeed(X) if X == ease.targetSpeed then ease.isActive = false if type(ease.callback) == "function" then ease.callback(); end end end end) function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end ^ Paste this code somewhere in your script file ^ Example Usage local Marker = createMarker(X, Y, Z, "corona", SIZE, 0, 0, 0) addEventHandler("onClientMarkerHit", getRootElement(), function(playerid) if playerid == getLocalPlayer() then if isPedInVehicle(playerid) then local vehicleid = getPedOccupiedVehicle(playerid) if source == Marker then --Params: (targetSpeed, overTime, callback) easeGameSpeed(0.6, 1500, function() -- Target game speed reached -- Now you can either delay the reversal by using setTimer: -- This example waits 1500ms before it starts reversing the game speed back to 1.0 over a time of 1000ms setTimer(function() easeGameSpeed(1.0, 1000) end, 1500, 1) --OR instantly start the reversal back to 1.0: easeGameSpeed(1.0, 1500) end) end end end end) -- And obviously the function somewhere down here..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.