ViRuZGamiing Posted January 3, 2014 Share Posted January 3, 2014 Hello, Is it (i know it will be) possible to change the horn sounds with a script? don't reply with just yes but tell me how, Thanks Link to comment
bandi94 Posted January 3, 2014 Share Posted January 3, 2014 Yes it is . How ? . You need a horn.mp3 , then bind the horn key , and playSound. Link to comment
TAPL Posted January 3, 2014 Share Posted January 3, 2014 And disable the default horn with: https://wiki.multitheftauto.com/wiki/SetWorldSoundEnabled Link to comment
ViRuZGamiing Posted January 3, 2014 Author Share Posted January 3, 2014 But playSound is client side so it would be only hearable by the client player (localPlayer) Link to comment
pa3ck Posted January 3, 2014 Share Posted January 3, 2014 Use triggerServerEvent with 'getRootElement()' then trigger a client event back using triggerClientEvent with 'getRootElement()' and use playSound3D insted of playSound Link to comment
50p Posted January 3, 2014 Share Posted January 3, 2014 Use triggerServerEvent with 'getRootElement()' then trigger a client event back using triggerClientEvent with 'getRootElement()' and use playSound3D insted of playSound Explain the need for triggerServerEvent? You can bindKey server-side. Link to comment
TAPL Posted January 3, 2014 Share Posted January 3, 2014 (edited) Make everything client side . With bindKey when the key pressed down set the element data to the vehicle and when the key up remove the element data. Use the event onClientElementDataChange to play the sound and to destroy the sound and don't forget to use table to store the sound element. Edited January 3, 2014 by Guest Link to comment
ViRuZGamiing Posted January 3, 2014 Author Share Posted January 3, 2014 (edited) How about this? function horn () x, y, z = getPlayerPosition ( localPlayer() ) triggerServerEvent("root", root) local sound = playSound("horn.mp3", x, y, z) end bindKey(localPlayer(), "horn", "down") -------- addEvent("root", true) addEventHandler("root", getRootElement(), function () -- what here? end ) Edited January 3, 2014 by Guest Link to comment
ViRuZGamiing Posted January 3, 2014 Author Share Posted January 3, 2014 so TAPL I can just play sound client side? Link to comment
TAPL Posted January 3, 2014 Share Posted January 3, 2014 Yes, the whole script can be done client side. Link to comment
50p Posted January 3, 2014 Share Posted January 3, 2014 so TAPL I can just play sound client side? You can't play sounds server-side. Your code is wrong. - localPlayer is a variable not a function. - There is no getPlayerPosition function. Use getElementPosition instead. - What's the need for new event? Link to comment
ViRuZGamiing Posted January 3, 2014 Author Share Posted January 3, 2014 The upper part is ment too be client and below server Link to comment
50p Posted January 3, 2014 Share Posted January 3, 2014 The upper part is ment too be client and below server Follow this: Make everything client side .With bindKey when the key pressed down set the element data to the vehicle and when the key up remove the element data. Use the event onClientElementDataChange to play the sound and to destroy the sound and don't forget to use table to store the sound element. Link to comment
ViRuZGamiing Posted January 3, 2014 Author Share Posted January 3, 2014 (edited) Yes, the whole script can be done client side. function horn () x, y, z = getElementPosition( localPlayer() ) local sound = playSound("horn.mp3", x, y, z) onClientElementDataChange () --how does this work? end bindKey(root, "horn", "down") Edited January 3, 2014 by Guest Link to comment
TAPL Posted January 3, 2014 Share Posted January 3, 2014 This make no sense. https://wiki.multitheftauto.com/wiki/Scripting_Introduction Link to comment
ViRuZGamiing Posted January 3, 2014 Author Share Posted January 3, 2014 This make no sense.https://wiki.multitheftauto.com/wiki/Scripting_Introduction Your reply also makes no sense, i don't got further now... Link to comment
Chaos Posted January 3, 2014 Share Posted January 3, 2014 (edited) bindKey ( "horn", "down", horn ) Edited January 3, 2014 by Guest Link to comment
Drakath Posted January 3, 2014 Share Posted January 3, 2014 onClientElementDataChange is an event. Check bindKey syntax. String key must be "h" not horn. Link to comment
TAPL Posted January 3, 2014 Share Posted January 3, 2014 This make no sense.https://wiki.multitheftauto.com/wiki/Scripting_Introduction Your reply also makes no sense, i don't got further now... I can't tell more than what 50p said already in his previous post along side with the link i post. If you don't read the wiki this a problem, you should realize that bindKey does not require player element in client side. This is mentioned on the wiki (Client - Syntax). https://wiki.multitheftauto.com/wiki/BindKey bindKey ( string key, string keyState, function handlerFunction, [ var arguments, ... ] ) Everything about events was in the link: https://wiki.multitheftauto.com/wiki/Scripting_Introduction Edit: @Drakath, horn is correct, it's the control name: https://wiki.multitheftauto.com/wiki/Control_names. Link to comment
ViRuZGamiing Posted January 3, 2014 Author Share Posted January 3, 2014 Indeed TAPL that's what I saw too horn is a control name bindKey ( horn, "down", function( ) x, y, z = getElementPosition ( getLocalPlayer() ) local uSound = playSound3D( x, y, z ) setSoundMaxDistance( uSound, 100 ) 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