Jump to content

[Question]Horn


Recommended Posts

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
Link to comment
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
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
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
Link to comment

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

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