Jump to content

Is it possible?


mgdmgd

Recommended Posts

Well sure, You will need the functions;

dxCreateRenderTarget, dxDrawRext, dxSetRenderTarget, dxDrawImage3D.

It won't be that hard if you can script.

You simply need to create a render target then create a text inside that render target using dxDrawText and dxSetRenderTarget and then you can draw the texture of this render target as a 3D image on the car.

I can give a short example if you are not familiar with those functions.

  • Like 1
Link to comment

Actually i am not familiar with scripting that well, if you could help me with a PM having some tips and the script if you can <3 It would be great help buddy.

and i want the tag to be saved to the car even if the car respawns if it's possible buddy!

Link to comment

Well, if you were familiar with those functions then a small example could help you, but since you are not then this is going to take some time and I actually don't have free time now to write a whole script but I'll make sure to help you tomorrow on my free time.

So keep me updated about this issue.

Link to comment
local modelNames = {
	[402] = "Nissan 240SX", 
	[529] = "529",
	[420] = "420",
	[550] = "550",
	[546] = "546",
	[540] = "540",
	[580] = "580",
	[527] = "Honda Civic Si",
	[587] = "Nissan Silvia S14",
	[436] = "Nissan Silvia S15",
	[426] = "BMW E39",
	--[526] = "BMW E34",
	[401] = "Nissan Skyline R34",
	[559] = "Toyota Supra",
	[562] = "BMW E36 M3",
	[477] = "Mazda RX7",
	[480] = "Porsche 911",
	[533] = "Honda S2000",
	[517] = "Toyota Celica",
	[405] = "Toyota Chaser Tourer V",
	[560] = "Subaru Impreza",
	[526] = "Audi S1 Quattro",
	[600] = "Audi S4"
}

function getVehicleNameFromModel(model)
	if not model then
		return false
	end
	if not modelNames[model] then
		return "Nav zināms:" .. model
	end
	return modelNames[model]
end

function getAllVehiclesModels()
	local models = {}
	for k,_ in pairs(modelNames) do
		table.insert(models, tonumber(k))
	end
	return models
end

this one is for the names


and this one is for drawing:

 

addEventHandler("onClientRender", root, 
	function()
		if not drawingName then
			return
		end
		offsetY = offsetY + (offsetTargetY - offsetY) * 0.15
		local y = screenHeight - height + offsetY
		local h = screenHeight + offsetY
		      local vehicle = getPedOccupiedVehicle ( localPlayer )
		local vehids = getElementData(getPedOccupiedVehicle ( localPlayer ),"handlingType")
	
		dxDrawText(""..drawingName, 3, y + 3, screenWidth + 3, h + 3, tocolor(0, 0, 0, 170), 3, "default-bold", "center", "center",false,false,false,true)
		dxDrawText(""..drawingName, 0, y, screenWidth, h, tocolor(255, 255, 255), 3, "default-bold", "center", "center",false,false,false,true)

		if drawingOwner then
			local ownerOffset = dxGetFontHeight(3, "default-bold")
			y = y + ownerOffset
			h = h + ownerOffset
			dxDrawText(drawingOwner, 0, y, screenWidth, h, tocolor(48, 113, 138), 2, "default-bold", "center", "center", false, false, false, true)
		end
	end
)

local function hide()
	drawingName = false
end

local function startHiding()
	offsetTargetY = height
	setTimer(hide, 1000, 1)
end

addEventHandler("onClientVehicleEnter", root,
	function(player)
		if player ~= localPlayer then
			return
		end
		drawingName = getVehicleNameFromModel(getElementModel(source))
		local ownerName = getElementData(source, "tws-ownerName")
		if ownerName then
			drawingOwner = "" .. tostring(drawingName)
		else
			drawingOwner = false
		end
		offsetY = height
		offsetTargetY = 0

		setTimer(startHiding, 4000, 1)
	end
)

 

Link to comment
16 hours ago, SuperCroz said:

@Daniels69 Well, I'd rather understand what the main issue here before posting some random script.

The guy wants to draw a text on the vehicle which exists on the 3D world, not to create custom vehicle names for certain vehicles.

Thats actually what i mean, if somebody can help me and thank you for your time @Daniels69 but it's not what i need :/

Link to comment

Guys

I want to do /maketext and it shows a normal TEXT, normal text like "Hey sup" on the car

I want it to be shown on the top of the car or on the back, floating in the air, not a texture or shaders or anything, just a normal TEXT, anybody know how to do it?

Link to comment

Ohh, just in the air?

For the server side. Later on, you can use the customNames table to set their custom name back after respawn.

customNames = {}

addCommandHandler("customname", function(thePlayer, cmdName, customName)
	local cVeh = getPedOccupiedVehicle(thePlayer)
	setElementData(cVeh, "customName", customName)
	customNames[cVeh] = customName
end)

For the client side.

addEventHandler("onClientRender", getRootElement(), function()
	local pX, pY, pZ = getElementPosition(localPlayer)
	for i, k in ipairs(getElementsByType("vehicle")) do
		if getElementData(k, "customName") then
			local cX, cY, cZ = getElementPosition(k)
			if getDistanceBetweenPoints3D(cX, cY, cZ, pX, pY, pZ) <= 20 then
				if isLineOfSightClear(cX, cY, cZ+1, pX, pY, pZ+1) then
				local cX, cY = getScreenFromWorldPosition(cX, cY, cZ+1)
				if cX and cY then
					dxDrawText(getElementData(k, "customName"), cX, cY)
				end
			end
		end
	end		
end)

This one should work just fine. Not tested tho. Give me a feedback of it. Still working on the texture one.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...