Jump to content

[Question]Horn


Recommended Posts

Posted

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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

Yes it is :P.

How ? . You need a horn.mp3 , then bind the horn key , and playSound.

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

But playSound is client side so it would be only hearable by the client player (localPlayer)

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted (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 by Guest
CiTLh.png
Posted (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 by Guest

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
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.

Posted (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 by Guest

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

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.

CiTLh.png
Posted

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 
) 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...