Dzsozi (h03) Posted March 27, 2014 Share Posted March 27, 2014 Hello everyone! Today I tried the triggering stuff, but it's not working. I don't know why. Can somebody help me please? This script is about when the engine is broken and you try to start it, it should start play a sound. Here's this part of the code: Server if (vehKey) or (owner < 0) and (faction == -1) or (playerFaction == faction) and (faction ~= -1) or (exports.global:isPlayerAdmin(source)) then local fuel = getElementData(veh, "fuel") local broke = getElementData(veh, "enginebroke") if broke == 1 then exports.global:sendLocalMeAction(source, "megpróbálja beindítani a jármûvet, de nem sikerül.") exports["notifications"]:showBox(source, "error", "A jármű motorja sérült.") triggerClientEvent ("onMotorSerult",getRootElement()) end end Client addEvent ("onMotorSerult",true) addEventHandler ("onMotorSerult",getRootElement(), function () local jatekosjarmu = getPedOccupiedVehicle(localPlayer) local x, y, z = getElementPosition(jatekosjarmu) motor = playSound3D("startup.mp3", x, y, z, false) setSoundMaxDistance(motor, 30) end ) Link to comment
Anubhav Posted March 27, 2014 Share Posted March 27, 2014 Any errors ? And what are you trying to do? Link to comment
Moderators IIYAMA Posted March 27, 2014 Moderators Share Posted March 27, 2014 @Dzsozi Did you know that with your code every player has to be in a vehicle to hear a sound? and if they are not they get 3 warnings at clientside? Because you don't check if the vehicle does exist. try: -- server triggerClientEvent ("onMotorSerult",veh) -- client addEvent ("onMotorSerult",true) addEventHandler ("onMotorSerult",root, function () if isElement(source) then local x, y, z = getElementPosition(source) local motor = playSound3D("startup.mp3", x, y, z, false) setSoundMaxDistance(motor, 30) end end ) 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