HoLsTeN Posted January 29, 2011 Share Posted January 29, 2011 hi all 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 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
Castillo Posted January 29, 2011 Share Posted January 29, 2011 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
HoLsTeN Posted January 29, 2011 Author Share Posted January 29, 2011 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
Castillo Posted January 29, 2011 Share Posted January 29, 2011 That code is the one i gave you.. everyone will hear it since i put getRootElement() Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now