Jump to content

Voice


Recommended Posts

Posted

opa tudo bom ? , eu queria saber pq esta aparecendo o nome sendo que era pra aparecer o id do jogador que esta falando script do < voice >

local g_screenX,g_screenY = guiGetScreenSize()
local BONE_ID = 8
local WORLD_OFFSET = 0.4
local ICON_PATH = "images/voice.png"
local ICON_WIDTH = 0.35*g_screenX
-- local ICON_HEIGHT = 0.213333333333*g_screenY
--
local iconHalfWidth = ICON_WIDTH/2
-- local iconHalfHeight = ICON_HEIGHT/2

local ICON_DIMENSIONS = 16
local ICON_LINE = 20
local ICON_TEXT_SHADOW = tocolor ( 0, 0, 0, 255 )

--Draw the voice image
addEventHandler ( "onClientRender", root,
	function()
		local index = 0
		if not bShowChatIcons then return end
		for player in pairs(voicePlayers) do
			local color = tocolor(255, 255, 255)
			dxDrawVoiceLabel ( player, index, color )
			index = index + 1
			while true do
				--is he streamed in?
				if not isElementStreamedIn(player) then
					break
				end
				--is he on screen?
				if not isElementOnScreen(player) then 
					break
				end
				local headX,headY,headZ = getPedBonePosition(player,BONE_ID)
				headZ = headZ + WORLD_OFFSET
				--is the head position on screen?
				local absX,absY = getScreenFromWorldPosition ( headX,headY,headZ )
				if not absX or not absY then
					break
				end
				local camX,camY,camZ = getCameraMatrix()
				--is there anything obstructing the icon?
				if not isLineOfSightClear ( camX, camY, camZ, headX, headY, headZ, true, false, false, true, false, true, false, player ) then
					break
				end
				dxDrawVoice ( absX, absY - 2, color, getDistanceBetweenPoints3D(camX, camY, camZ, headX, headY, headZ) )
				break
			end
		end
	end
)

function dxDrawVoice ( posX, posY, color, distance )
	distance = 1/distance
	dxDrawImage ( posX - iconHalfWidth*distance, posY - iconHalfWidth*distance, ICON_WIDTH*distance, ICON_WIDTH*distance, ICON_PATH, 0, 0, 0, tocolor(255, 255, 255, 195), false )
end

function dxDrawVoiceLabel ( player, index, color )
	local sx, sy = guiGetScreenSize ()
	local scale = sy / 800
	local spacing = ( ICON_LINE * scale )
	local px, py = sx - 200, sy * 0.7 + spacing * index
	local icon = ICON_DIMENSIONS * scale

	dxDrawImage ( px, py, icon, icon, ICON_PATH, 0, 0, 0, tocolor(255, 255, 255, 195), false )

	px = px + spacing


	-- text
	local ID = getElementData(player, "ID") or "N/A"
    local w = dxGetTextWidth(ID, 0.1, "default-bold")
    local h = dxGetFontHeight(1, "default-bold")
	dxDrawText ( getPlayerName ( player ), px, py, px, py, tocolor(255, 255, 255, 195), 1.00, "default-bold", "left", "top", false, false, false, true, false)
end

 

  • Moderators
Posted

Linha 73. Troque o getPlayerName (player) por ID.

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted (edited)
16 minutes ago, Lord Henry said:

Linha 73. Troque o getPlayerName (player) por ID.

	-- text
	local ID = getElementData(player, "ID") or "N/A"
    local w = dxGetTextWidth(ID, 0.1, "default-bold")
    local h = dxGetFontHeight(1, "default-bold")
	dxDrawText ( ID ), px, py, px, py, tocolor(255, 255, 255, 195), 1.00, "default-bold", "left", "top", false, false, false, true, false)
end

troquei aki porem não aparece mais nem o nome e nem o id do jogador

debugscript esta assim , : ERROR: Loading script falied: s-voice\cDrawIcon.Lua:73:unexpected Symbol near ','

Edited by HG Snuuk
Posted
31 minutes ago, HG Snuuk said:

	-- text
	local ID = getElementData(player, "ID") or "N/A"
    local w = dxGetTextWidth(ID, 0.1, "default-bold")
    local h = dxGetFontHeight(1, "default-bold")
	dxDrawText ( ID ), px, py, px, py, tocolor(255, 255, 255, 195), 1.00, "default-bold", "left", "top", false, false, false, true, false)
end

troquei aki porem não aparece mais nem o nome e nem o id do jogador

debugscript esta assim , : ERROR: Loading script falied: s-voice\cDrawIcon.Lua:73:unexpected Symbol near ','

 

"..ID.."

 

j3HZ2yM.gif  Eu te ajudei? deixe seu Thanks

Posted
dxDrawText ( ID ), px, py, px, py, tocolor(255, 255, 255, 195), 1.00, "default-bold", "left", "top", false, false, false, true, false)

Remova o parentese depois de "ID".

Please do not PM me with scripting related question nor support, use the forums instead.

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...