Dzsozi (h03) Posted March 27, 2014 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 ) Your signature image is too large. Removed
Anubhav Posted March 27, 2014 Posted March 27, 2014 Any errors ? And what are you trying to do? See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Moderators IIYAMA Posted March 27, 2014 Moderators 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 ) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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