Lyra

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Lyra

  • Rank
    I ordered some spaghetti with marinara sauce and I got egg noodles and ketchup. I'm an average nobody.
  1. Boa tarde! Comecei a tentar mexer em scripter a pouco tempo. Modifiquei um código de sistema de som de carro que funciona perfeitamente, porém: Quando desligo o som ele só desliga pra mim. Todas outras pessoas escutam o som. Elas mesmas precisam ir la no carro, entrar e desligar o painel para desligar o som. O volume só aumenta ou diminui para quem está mexendo no painel de som. Se reinicia o servidor todos carros explodidos voltam a tocar a música antes da explosão. Agradeço desde já a ajuda! Já tentei alterar o código todo e nada de conseguir, estou alterando esse código ha 2 dias e não consigo consertar. Aceito até mesmo apoio profissional (eu pago). local positions = {} local radius = 180 local step = (360 / #playlist) local visible = false local width, height = guiGetScreenSize() sW = (width / 2) sH = (height / 2) local function GeneratePositions(posX,posY,radius,width,angleAmount,startAngle,stopAngle,color,postGUI) if (type( posX ) ~= "number") or (type( posY ) ~= "number") then return false end local function clamp( val, lower, upper ) if ( lower > upper ) then lower, upper = upper, lower end return math.max( lower, math.min( upper, val ) ) end radius = type( radius ) == "number" and radius or 50 width = type( width ) == "number" and width or 5 angleAmount = type( angleAmount ) == "number" and angleAmount or 1 startAngle = clamp( type( startAngle ) == "number" and startAngle or 0, 0, 360 ) stopAngle = clamp( type( stopAngle ) == "number" and stopAngle or 360, 0, 360 ) color = color or tocolor( 255, 255, 255, 200 ) postGUI = type( postGUI ) == "boolean" and postGUI or false if ( stopAngle < startAngle ) then local tempAngle = stopAngle stopAngle = startAngle startAngle = tempAngle end local count = 0; for i = startAngle, stopAngle, angleAmount do local startX = math.cos( math.rad( i ) ) * ( radius - width ) local startY = math.sin( math.rad( i ) ) * ( radius - width ) local endX = math.cos( math.rad( i ) ) * ( radius + width ) local endY = math.sin( math.rad( i ) ) * ( radius + width ) count = count + 1 if count >= step then table.insert(positions, { startX + posX, startY + posY } ) count = 0 end end return true end local function isCursorOnElement(posX,posY,width,height) if isCursorShowing() then local mouseX, mouseY = getCursorPosition() local clientW, clientH = guiGetScreenSize() local mouseX, mouseY = mouseX * clientW, mouseY * clientH if (mouseX > posX and mouseX < (posX + width) and mouseY > posY and mouseY < (posY + height)) then return true end end return false end local function draw() if visible then local veh = getPedOccupiedVehicle(localPlayer) if veh then for i, data in ipairs(positions) do local isPosition = isCursorOnElement(data[1] - 30,data[2] - 30,60,60) dxDrawImage(data[1] - 30,data[2] - 30,60,60,playlist[i][1],0,0,0,tocolor(255,255,255,isPosition and 100 or 255),false) end dxDrawImage(0, 0, width, height, "Assets/bg.png", 0, 0, 0, tocolor(255,255,255,120), false) dxDrawImage(positions[3][1] - 30,positions[3][2] - 120,60,60,"Assets/off.png",0,0,0,tocolor(255,255,255,isCursorOnElement(positions[3][1] - 30,positions[3][2] - 120,60,60) and 100 or 255),false) dxDrawText("VOLUME", sW, sH, width / 2, height / 3,tocolor(255,255,255,255),1.15,"bankgothic","center","center",false,false,true,false,false) local meta = "" local sound = getElementData(veh,"music:attach") if (sound) then if isElement(sound) then local id = getElementData(veh,"music:id") or 0 if id then dxDrawText(playlist[id][3],sW,-180,width / 2,height / 2,tocolor(255,255,255,255),1.65,"default-bold","center","center",false,false,true,false,false) end meta = getSoundMetaTags(sound) if meta.stream_title then dxDrawText("On the air: "..meta.stream_title,sW,-130,width / 2,height / 2,tocolor(255,255,255,255),1,"default-bold","center","center",false,false,true,false,false) end end end local k = "" for i = 1, volume do k = k .. "+" end local s = "" local lenght = string.len(k) if lenght < 10 then for i = 1, (10 - lenght) do s = s .. "−" end end k = "#00cc00" .. k s = "#ff0000" .. s dxDrawText("\n\n["..k..""..s.."#ffffff]",sW,sH,width / 2,height / 3,tocolor(255,255,255,255),2,"default","center","center",false,false,true,true,false) dxDrawText("Para mudar o volume use '-' ou '='",sW,sH,width / 2,height / 2,tocolor(255,255,255,255),1,"default","center","center",false,false,true,true,false) else visible = false end end end volume = 2 function VehicleRadio(vehicle) setRadioChannel(0) setPlayerHudComponentVisible("radio",false) if isElement(vehicle) and getElementType(vehicle) == "vehicle" then local music = getElementData(vehicle,"music:attach") if isElement(music) then destroyElement(music) end local x,y,z = getElementPosition(vehicle) local id = getElementData(vehicle,"music:id") or 0 if playlist[id] then local music = playSound3D(playlist[id][2],x,y,z) setSoundMaxDistance(music,25) attachElements(music,vehicle) setElementData(vehicle,"music:attach",music,false) setSoundVolume(music,volume * 1 / 1) end end end addEventHandler("onClientElementDataChange",getRootElement(), function(dataName,oldValue) if getElementType(source) == "vehicle" and dataName == "music:id" then if isElementStreamedIn(source) then VehicleRadio(source) end end end ); addEventHandler("onClientElementStreamIn",getRootElement(), function() if getElementType(source) == "vehicle" then VehicleRadio(source) end end ); addEventHandler( "onClientElementStreamOut",getRootElement(), function() if getElementType(source) == "vehicle" then local music = getElementData(source,"music:attach") if isElement(music) then destroyElement(music) end end end ); addEventHandler("onClientVehicleExplode",getRootElement(), function() local music = getElementData(source,"music:attach") if isElement(music) then destroyElement(music) end end ); addEventHandler("onClientVehicleExplode",getRootElement(), function() local music = getElementData(source,"music:attach") if isElement(music) then destroyElement(music) end end ); addEventHandler("onClientElementDestroy",getRootElement(), function() if getElementType(source) == "vehicle" then local music = getElementData(source,"music:attach") if isElement(music) then destroyElement(music) end end end ); addEventHandler("onClientResourceStart",resourceRoot, function() setRadioChannel(0) addEventHandler("onClientPlayerRadioSwitch",root, function() cancelEvent() end) local vehicles = getElementsByType("vehicle",root,true) for i, vehicle in ipairs(vehicles) do VehicleRadio(vehicle) end GeneratePositions(sW,sH,radius,nil,nil,nil,360) addEventHandler("onClientRender",root,draw) bindKey(key,"both", function() showCursor(visible) local veh = getPedOccupiedVehicle(localPlayer) if veh then visible = not visible showCursor(visible) end end) function changeVolume(key) local veh = getPedOccupiedVehicle(localPlayer) if veh then local music = getElementData(veh,"music:attach") if isElement(music) then volume = getSoundVolume(music) * 2 if key == down then volume = volume - 1 if volume < 0 then volume = 0 end elseif key == up then volume = volume + 1 if volume > 10 then volume = 10 end end setSoundVolume(music,volume * 1 / 2) end end end bindKey(down,"down",changeVolume) bindKey(up,"down",changeVolume) addEventHandler("onClientClick",root, function(button,state) if (button == "left" and state) then local veh = getPedOccupiedVehicle(localPlayer) if isCursorOnElement(positions[3][1] - 30,positions[3][2] - 120,60,60) then local music = getElementData(veh,"music:attach") if isElement(music) then setElementData(vehicle,"music:attach",music,false) destroyElement(music) stopSound (music) end return true end for i, data in ipairs(positions) do local isPosition = isCursorOnElement(data[1] - 30,data[2] - 30,60,60) if isPosition then setElementData(veh,"music:id",i) setElementData(vehicle,"music:attach",music,false) stopSound (music) break end end end end) end)
  2. Boa noite. Estou tentando melhorar um sistema de voz de mta parecido com o FIVE M. Ele está funcionando tudo, exceto o circulo abaixo do personagem. O circulo so aparece no meu personagem, seja eu falando ou outros mas apenas eu vejo o circulo. O mesmo acontece com os outros jogadores, apenas eles veem o circulo no personagens deles quando ele ou alguém aciona o microfone. Gostaria de uma luz se possível. Quando utilizo as imagens, não tenho esse problema, cada um fica com sua imagem acionada. Apenas o circulo esta com problemas. Obrigado! Código: local g_screenX,g_screenY = guiGetScreenSize() local BONE_ID = 8 local WORLD_OFFSET = 0.4 local ICON_PATH = "voice.png" local ICON_WIDTH = 0.10*g_screenX local iconHalfWidth = ICON_WIDTH/2 local ICON_DIMENSIONS = 16 local ICON_LINE = 20 local ICON_TEXT_SHADOW = tocolor ( 0, 0, 0, 255 ) addEventHandler ( "onClientRender", root, function() local index = 0 if not bShowChatIcons then return end for player in pairs(voicePlayers) do local color = tocolor(getPlayerNametagColor ( player )) dxDrawVoiceLabel ( player, index, color ) circulo ( player, index, color ) index = index + 1 while true do if not isElementStreamedIn(player) then break end if not isElementOnScreen(player) then break end local headX,headY,headZ = getPedBonePosition(player,BONE_ID) headZ = headZ + WORLD_OFFSET local absX,absY = getScreenFromWorldPosition ( headX,headY,headZ ) if not absX or not absY then break end local camX,camY,camZ = getCameraMatrix() if not isLineOfSightClear ( camX, camY, camZ, headX, headY, headZ, true, false, false, true, false, true, false, player ) then break end dxDrawVoice ( absX, absY, color, getDistanceBetweenPoints3D(camX, camY, camZ, headX, headY, headZ) ) break end end end ) function dxDrawCircle3D( x, y, z, radius, segments, color, width ) segments = segments or 16; width = width or 1; local segAngle = 360 / segments; local fX, fY, tX, tY; for i = 1, segments do fX = x + math.cos( math.rad( segAngle * i ) ) * radius; fY = y + math.sin( math.rad( segAngle * i ) ) * radius; tX = x + math.cos( math.rad( segAngle * (i+1) ) ) * radius; tY = y + math.sin( math.rad( segAngle * (i+1) ) ) * radius; dxDrawLine3D( fX, fY, z, tX, tY, z, color, width ); 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, color, false ) end function dxDrawVoiceLabel ( player, index, color ) local sx, sy = guiGetScreenSize () local scale = sy / 800 local spacing = ( ICON_LINE * scale ) local px, py = sx - 300, sy * 0.7 + spacing * index local icon = ICON_DIMENSIONS * scale dxDrawImage ( px, py, ICON_PATH, 0, 0, 0, color, false ) px = px + spacing x, y, z = getElementPosition(getLocalPlayer()) dxDrawCircle3D( x, y, z -0.7, 0.5, 30, tocolor( 0, 186, 235 ),9) end