Jump to content

sound in server side


HoLsTeN

Recommended Posts

hi all :mrgreen:

i want to make code for

if i buy anything from the shop

play sound for Warning

and all player in server Hear that

can Any one help me here :D

this is my code in server side i dont think we need cilent side

addEvent("Repair", true) 
addEventHandler("Repair", getRootElement(), 
  function() 
    if isPedInVehicle(source) then 
      if ( getPlayerMoney (source) >= 500 ) then 
        takePlayerMoney(source, 500) 
        fixVehicle(getPedOccupiedVehicle(source)) 
    local sound = playSound("DontHaveTime.mp3") 
        setSoundVolume(sound, 2.5) 
        outputChatBox("Vehicle Successfully Fixed", source, 255, 255, 0, true) 
      else 
        outputChatBox("Not enough money.", source, 255, 0, 0, true) 
      end      
    else 
      outputChatBox("You are not in a vehicle", source, 255, 0, 0, true) 
    end 
  end 
) 

Link to comment

playSound only Client side, you must trigger an event:

--server side

addEvent("Repair", true) 
addEventHandler("Repair", getRootElement(), 
  function() 
    if isPedInVehicle(source) then 
      if ( getPlayerMoney (source) >= 500 ) then 
        takePlayerMoney(source, 500) 
        fixVehicle(getPedOccupiedVehicle(source)) 
       triggerClientEvent("play_shop_sound",getRootElement()) 
        outputChatBox("Vehicle Successfully Fixed", source, 255, 255, 0, true) 
      else 
        outputChatBox("Not enough money.", source, 255, 0, 0, true) 
      end     
    else 
      outputChatBox("You are not in a vehicle", source, 255, 0, 0, true) 
    end 
  end 
) 

--client side

addEvent("play_shop_sound",true) 
addEventHandler("play_shop_sound",getRootElement(), 
function () 
local sound = playSound("DontHaveTime.mp3") 
setSoundVolume(sound, 2.5) 
end) 

Link to comment

Thank you solid

i make it like that

addEvent("Repair", true) 
addEventHandler("Repair", getRootElement(), 
  function() 
    if isPedInVehicle(source) then 
      if ( getPlayerMoney (source) >= 500 ) then 
        takePlayerMoney(source, 500) 
        fixVehicle(getPedOccupiedVehicle(source)) 
       triggerClientEvent("play_shop_sound",getRootElement()) 
        outputChatBox("Vehicle Successfully Fixed", source, 255, 255, 0, true) 
      else 
        outputChatBox("Not enough money.", source, 255, 0, 0, true) 
      end     
    else 
      outputChatBox("You are not in a vehicle", source, 255, 0, 0, true) 
    end 
  end 
) 

and it is work but i dont know if all player in server can here it

but thank you agine

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