Jump to content

[Ajuda] Adaptar código


Recommended Posts

Posted

Eaê pessou, joia?

Seguindo, eu kria saber adaptar isso aq:

local x,y,z = getElementPosition(getLocalPlayer()) 
local som = playSound3D("caminho", x,y,z) 
setSoundMaxDistance( som, 30 ) 

para pôr juntamente com essa função:

 if itemName == "repairvehicle" then 
      local col = getElementData(getLocalPlayer(), "currentCol") 
      triggerServerEvent("repairVehicle", getLocalPlayer(), getElementData(col, "parent")) 
      playSound("sounds/repair.mp3") 
      disableMenu() 
      return 
    end 

tipo, seguinte, quem tá próximo, irá escutar a ação q 1 player individualmente executar, entendem?

Grato!

Posted

DayZ descompilado né, malandrão? Conheeeeeço, haha.

Cara, só substituir a função "playSound()" presente no segundo código apresentado pelas linhas do primeiro código. Mais ou menos assim:

if itemName == "repairvehicle" then 
      local col = getElementData(getLocalPlayer(), "currentCol") 
      triggerServerEvent("repairVehicle", getLocalPlayer(), getElementData(col, "parent")) 
      local soundX,soundY,soundZ = getElementPosition(getLocalPlayer()) 
      local som = playSound3D("sounds/repair.mp3", soundX, soundY, soundZ) 
      setSoundMaxDistance( som, 30 ) 
      disableMenu() 
      return 
    end 

Acho que isso funciona. Nomeei as variáveis como "soundX, soundY e soundZ" pra não correr o risco de dar conflito com qualquer outra ocorrência de variáveis com o nome "x,y,z" que possa existir no código.

Software Engineer & Entrepreneur Running Lustrel and VilarikA • Highly engaged on open source community

Posted

vlws lekao! ^^ rs

vou testar aq, qualquer coisa aviso.

@EDIT

function playerUseItem(itemName, itemInfo) 
  if itemInfo == "Beber" then 
    local soundX,soundY,soundZ = getElementPosition(getLocalPlayer()) 
    local som = playSound3D("sounds/bebendo.ogg", soundX, soundY, soundZ) 
    triggerServerEvent("onPlayerRequestChangingStats", getLocalPlayer(), itemName, itemInfo, "thirst") 
    setSoundMaxDistance(som, 15) 

Aí lek, testei e tals com um parça aq, mais aí só quem ouve é quem executa a ação. :S

Posted

playSound3D é tocado apenas para o jogador local.

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

Posted
playSound3D é tocado apenas para o jogador local.

Então no caso ficaria como, se fosse pra adaptar como falei? E qual a função q se usa para um player próximo?

Grato!

Posted

Você pode usar triggerClientEvent, e acionar a função para todos os jogadores usando o primeiro argumento da função.

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