Jump to content

Sound doesn't play


BriGhtx3

Recommended Posts

This is my Client File :

  
function nHalt() 
local sound = playSound("sounds/Bus/nHalt.ogg") 
end 
  
function lt() 
nHalt() 
local ltr = playSound("sounds/Bus/Bushaltestellen/LTR.ogg") 
end 
addEvent("LTR", true) 
addEventHandler("LTR", getRootElement(), lt) 
  
function SchrottP() 
nHalt() 
local schrott = playSound("sounds/Bus/Bushaltestellen/Schrott.ogg") 
end 
addEvent("Schrott", true) 
addEventHandler("Schrott", getRootElement(), SchrottP) 
  
function AngelP() 
nHalt() 
local angel = playSound("sounds/Bus/Bushaltestellen/Angel.ogg") 
end 
addEvent("Angel", true) 
addEventHandler("Angel", getRootElement(), AngelP) 
  

My Server File :

local HalteNr1 
function startJob(thePlayer) 
HalteNr1 = createMarker ( -2435, -595, 132, "checkpoint", 10, 125, 0, 0, 255, thePlayer ) 
HalteNr1B = createBlip ( -2435, -595, 132, 0, 2, 255, 0, 0, 255, 0, 99999.0, thePlayer ) 
triggerClientEvent ( thePlayer, "LTR", getRootElement() ) 
triggerClientEvent ( thePlayer, "infobox_start", getRootElement(), "\nDienst gestartet!", 5000, 125, 0, 0 ) 
addEventHandler("onMarkerHit", HalteNr1, cMarker) 
end 
  
local HalteNr2 
function cMarker(thePlayer) 
    local money = vioGetElementData(thePlayer, "money") 
    vioSetElementData ( thePlayer, "money", tonumber(money)+50 ) 
    givePlayerMoney(thePlayer, 50) 
  
    destroyElement(HalteNr1B) 
    destroyElement(HalteNr1) 
    triggerClientEvent ( thePlayer, "Schrott", getRootElement() ) 
    HalteNr2 = createMarker ( -1923, -1785, 32, "checkpoint", 10, 125, 0, 0, 255, thePlayer ) 
    HalteNr2B = createBlip ( -1923, -1785, 32, 0, 2, 255, 0, 0, 255, 0, 99999.0, thePlayer ) 
    addEventHandler("onMarkerHit", HalteNr2, dMarker) 
end 

When I hit the first marker, both sounds are played.

When I hit the second marker, just the "nHalt" is played.

How can I change the script, that both sounds are played? Everything is in the meta.xml

No errors are shown

Link to comment

ClientSide ....

function nHalt() 
local sound = playSound("sounds/Bus/nHalt.ogg") 
end 
addEvent("N", true) 
addEventHandler("N", getRootElement(), nHalt) 
function lt() 
nHalt() 
local ltr = playSound("sounds/Bus/Bushaltestellen/LTR.ogg") 
end 
addEvent("LTR", true) 
addEventHandler("LTR", getRootElement(), lt) 
  
function SchrottP() 
nHalt() 
local schrott = playSound("sounds/Bus/Bushaltestellen/Schrott.ogg") 
end 
addEvent("Schrott", true) 
addEventHandler("Schrott", getRootElement(), SchrottP) 
  
function AngelP() 
nHalt() 
local angel = playSound("sounds/Bus/Bushaltestellen/Angel.ogg") 
end 
addEvent("Angel", true) 
addEventHandler("Angel", getRootElement(), AngelP) 

ServerSide ....

local HalteNr1 
function startJob(thePlayer) 
HalteNr1 = createMarker ( -2435, -595, 132, "checkpoint", 10, 125, 0, 0, 255, thePlayer ) 
HalteNr1B = createBlip ( -2435, -595, 132, 0, 2, 255, 0, 0, 255, 0, 99999.0, thePlayer ) 
triggerClientEvent ( thePlayer, "LTR", getRootElement() ) 
triggerClientEvent ( thePlayer, "infobox_start", getRootElement(), "\nDienst gestartet!", 5000, 125, 0, 0 ) 
addEventHandler("onMarkerHit", HalteNr1, cMarker) 
end 
  
local HalteNr2 
function cMarker(thePlayer) 
    local money = vioGetElementData(thePlayer, "money") 
    vioSetElementData ( thePlayer, "money", tonumber(money)+50 ) 
    givePlayerMoney(thePlayer, 50) 
    destroyElement(HalteNr1B) 
    destroyElement(HalteNr1) 
    triggerClientEvent ( thePlayer, "Schrott", getRootElement() ) 
    triggerClientEvent ( thePlayer, "N", getRootElement() ) 
    HalteNr2 = createMarker ( -1923, -1785, 32, "checkpoint", 10, 125, 0, 0, 255, thePlayer ) 
    HalteNr2B = createBlip ( -1923, -1785, 32, 0, 2, 255, 0, 0, 255, 0, 99999.0, thePlayer ) 
    addEventHandler("onMarkerHit", HalteNr2, dMarker) 
  

 and tell me if it work

Link to comment
myabe you have to Put x,y,z for Play Sound

Like This example

https://wiki.multitheftauto.com/wiki/PlaySound3D

PlaySound is not the same as PlaySound3D. PlaySound does it globally, 3D does it locally.

The problem in the script is that you don't have setSoundVolume there.

Do this to get it working (client-side):

  
function nHalt() 
local sound = playSound("sounds/Bus/nHalt.ogg") 
setSoundVolume(sound, 1.0) -- Valid: 0-1 
end 
  
function lt() 
nHalt() 
local ltr = playSound("sounds/Bus/Bushaltestellen/LTR.ogg") 
setSoundVolume(ltr, 1.0) -- Valid: 0-1 
end 
addEvent("LTR", true) 
addEventHandler("LTR", getRootElement(), lt) 
  
function SchrottP() 
nHalt() 
local schrott = playSound("sounds/Bus/Bushaltestellen/Schrott.ogg") 
setSoundVolume(schrott, 1.0) -- Valid: 0-1 
end 
addEvent("Schrott", true) 
addEventHandler("Schrott", getRootElement(), SchrottP) 
  
function AngelP() 
nHalt() 
local angel = playSound("sounds/Bus/Bushaltestellen/Angel.ogg") 
setSoundVolume(angel, 1.0) -- Valid: 0-1 
end 
addEvent("Angel", true) 
addEventHandler("Angel", getRootElement(), AngelP) 
  

Link to comment

client

function nHalt() 
    local sound = playSound("sounds/Bus/nHalt.ogg") 
end 
addEvent("N", true) 
addEventHandler("N", getRootElement(), nHalt) 
  
function lt() 
    nHalt() 
    local ltr = playSound("sounds/Bus/Bushaltestellen/LTR.ogg") 
end 
addEvent("LTR", true) 
addEventHandler("LTR", getRootElement(), lt) 
  
function SchrottP() 
    nHalt() 
    local schrott = playSound("sounds/Bus/Bushaltestellen/Schrott.ogg") 
end 
addEvent("Schrott", true) 
addEventHandler("Schrott", getRootElement(), SchrottP) 
  
function AngelP() 
    nHalt() 
    local angel = playSound("sounds/Bus/Bushaltestellen/Angel.ogg") 
end 
addEvent("Angel", true) 
addEventHandler("Angel", getRootElement(), AngelP) 

server

local HalteNr1 
function startJob(thePlayer) 
    HalteNr1 = createMarker ( -2435, -595, 132, "checkpoint", 10, 125, 0, 0, 255, thePlayer ) 
    HalteNr1B = createBlip ( -2435, -595, 132, 0, 2, 255, 0, 0, 255, 0, 99999.0, thePlayer ) 
    triggerClientEvent ( thePlayer, "LTR", getRootElement() ) 
    triggerClientEvent ( thePlayer, "infobox_start", getRootElement(), "\nDienst gestartet!", 5000, 125, 0, 0 ) 
    addEventHandler("onMarkerHit", HalteNr1, cMarker) 
end 
  
local HalteNr2 
function cMarker(thePlayer) 
    local money = vioGetElementData(thePlayer, "money") 
    vioSetElementData ( thePlayer, "money", tonumber(money)+50 ) 
    givePlayerMoney(thePlayer, 50) 
    destroyElement(HalteNr1B) 
    destroyElement(HalteNr1) 
    triggerClientEvent ( thePlayer, "Schrott", getRootElement() ) 
    triggerClientEvent ( thePlayer, "N", getRootElement() ) 
    HalteNr2 = createMarker ( -1923, -1785, 32, "checkpoint", 10, 125, 0, 0, 255, thePlayer ) 
    HalteNr2B = createBlip ( -1923, -1785, 32, 0, 2, 255, 0, 0, 255, 0, 99999.0, thePlayer ) 
    addEventHandler("onMarkerHit", HalteNr2, dMarker) 
end 

xthepr0mise you forgot end in function cMarker

Link to comment
bindKey ( thePlayer, "sub_mission", "down", startJob ) 

Full code please

Try for test :

  
addEventHandler("onResourceStart",resourceRoot, 
    function() 
        for i,v in ipairs(getElementsByType("player")) do 
            bindKey ( v, "F3", "down", startJob ) 
        end 
    end 
)    
  

Key:F3

Edited by Guest
Link to comment
  
function enterVehicle ( thePlayer, seat, jacked ) 
    local passenger = getVehicleOccupant( source, 1 ) 
    local preis = 100 
    if busVehicles[getElementModel ( source )]  then 
        if seat == 0 then 
            if vioGetElementData ( thePlayer, "job" ) == "busfahrer" then 
                bindKey ( thePlayer, "sub_mission", "down", startJob ) 
                triggerClientEvent ( thePlayer, "infobox_start", getRootElement(), "\nDruecke die spezial-\nmissionen-Taste,\num in den Dienst\nzu gehen!", 5000, 125, 0, 0 ) 
            else 
                triggerClientEvent ( thePlayer, "infobox_start", getRootElement(), "\nDu bist kein Busfahrer!", 5000, 125, 0, 0 ) 
            end 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 
  

Link to comment

First off, which of those both

17. triggerClientEvent ( thePlayer, "Schrott", getRootElement() )

18. triggerClientEvent ( thePlayer, "N", getRootElement() )

is played?

Second:

Does the file not played:

1) Exist client side

2) Can it be played by the windows media player?

Third:

Did you ever use a debugscript to ensure that the client side event really gets called?

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