Mefisto_PL Posted April 22, 2012 Posted April 22, 2012 I want to create new horn and my code doesn't working Where is mistake? function createHorn ( ) local x, y, z = getElementPosition ( player ) local vehicle = getPedOccupiedVehicle ( player ) local sound = playSound3( "newhorn.mp3" ) setSoundVolume ( sound, 0.5 ) attachElements ( sound, vehicle ) end addCommandHandler("horn", createHorn) function onPlayerJoin() bindKey( source, "h", "both", createHorn ) end addEventHandler( "onPlayerJoin", root, onPlayerJoin ) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function () for i,v in pairs(getElementsByType("player")) do bindKey(v,"h","both",createHorn) end end)
denny199 Posted April 22, 2012 Posted April 22, 2012 This is client with server side, it never will work. Sometimes I dream about cheese
Kenix Posted April 22, 2012 Posted April 22, 2012 function createHorn ( ) local x, y, z = getElementPosition ( player ) -- variable player not defined local vehicle = getPedOccupiedVehicle ( player ) -- variable player not defined local sound = playSound3( "newhorn.mp3" ) -- function playSound3 not exists, should be playSound3D but this function only client side setSoundVolume ( sound, 0.5 ) -- client side function, but you use in server side attachElements ( sound, vehicle ) end addCommandHandler("horn", createHorn) function onPlayerJoin() bindKey( source, "h", "both", createHorn ) end addEventHandler( "onPlayerJoin", root, onPlayerJoin ) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function () for i,v in pairs(getElementsByType("player")) do bindKey(v,"h","both",createHorn) end end) Read comments Also tabulate your code in next time. https://wiki.multitheftauto.com/wiki/Scr ... troduction http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
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