Death drawText - requesting dev assistance

I’m trying to setup drawText for when any player dies and only when they die this text will appear.

__resource.lua:

resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'

client_script {
'client.lua'
}

Client.lua:

Citizen.CreateThread(function()
	alreadyDead = false
    while true do
        Citizen.Wait(50)
		local playerPed = GetPlayerPed(-1)
		if IsEntityDead(playerPed) and not alreadyDead then
		    TriggerEvent("drawText")
		end
			alreadyDead = true
		end
		if not IsEntityDead(playerPed) then
			alreadyDead = false
		end
	end
end)

function drawText(x,y ,width,height,scale, text, r,g,b,a, outline)
    SetTextFont(0)
    SetTextProportional(0)
    SetTextScale(scale, scale)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(1, 0, 0, 0, 255)
    SetTextDropShadow()
    if(outline)then
	    SetTextOutline()
	end
    SetTextEntry("STRING")
    AddTextComponentString("~r~You can use /revive in 2.5 minute's")
    DrawText(x - width/2, y - height/2 + 0.005)
end

You’re triggering an event … but your drawText is a function???

Shit :laughing: Let me sort that

Its also a bad idea to use a wait of 50ms as drawText needs to be drawn every frame

Okay I am pretty sure I have fixed most of that, any idea why it isn’t displaying when the entity/player is dead.

function drawTxt(x,y ,width,height,scale, text, r,g,b,a)
    SetTextFont(0)
    SetTextProportional(0)
    SetTextScale(scale, scale)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(1, 0, 0, 0, 255)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(x - width/2, y - height/2 + 0.005)
end

Citizen.CreateThread(function()
	alreadyDead = false
    while true do
        Citizen.Wait(0)
		local playerPed = GetPlayerPed(-1)
		if IsEntityDead(playerPed) and not alreadyDead then do
		    drawTxt("~r~You can use /revive in 2.5 minute's", 0.177, 0.239, 0.25, 0.03, 0.40 ,255,255,255,255)
		end
			alreadyDead = true
		end
		if not IsEntityDead(playerPed) then
			alreadyDead = false
		end
	end
end)

Why is there 2 ends? Make sure to check your console (F8) for errors

My mistake thought I needed a second end for drawtxt, my mistake.

There are no console errors, it just refuses to output the text.

also then do should just be then

Oh I see thought I needed then do to perform an after action.

do is for things like for loops and while loops

Oh, I see, still doesn’t want to work. I think it is the drawTxt, something about that must be having an error.

function declaration: function drawTxt(x,y ,width,height,scale, text, r,g,b,a)

function usage: drawTxt("~r~You can use /revive in 2.5 minute's", 0.177, 0.239, 0.25, 0.03, 0.40 ,255,255,255,255) ??? why ??? x = "~r~You .." ??

First of all: here


Try:

function drawTxt(x,y, scale, text, r,g,b,a)
    SetTextFont(0)
    SetTextProportional(0)
    SetTextScale(scale, scale)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(1, 0, 0, 0, 255)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(x, y)
end

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
		local playerPed = GetPlayerPed(-1)

		if IsEntityDead(playerPed) then
		    drawTxt(0.5, 0.9, 0.5, "~r~You can use /revive in 2.5 minute's", 255,255,255,255)
		end

	end
end)

I’ll give it a shot, I know most of the basics about Lua but I’m not a pro.

~r~ is for sublime text to set the text a specific shade of red, rather than acquiring it in SetTextColour.

Cheers mate.

:mascot: I do not think so:


Wuuuut??
Click me, PLEASE !

I think he was just saying using ~r~ and ^8 etc limits the choices. RGB one can make any color.

What if it was just coma as I would call the function?