From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This event is triggered when a sound beats.

[[{{{image}}}|link=|]] Note: This event does not work correctly pre 1.3.1-9-04627
[[{{{image}}}|link=|]] Note: This event is triggered ahead of a sound beat the number passed is the play time at which the beat occurs


double theTime
  • theTime: the position in the song of the beat


The source of this event is the sound's element.


Click to collapse [-]

This code will change the vehicle color to a random value if the sound beats and the localPlayer is inside a vehicle

 function playMySound()
    playSound("sound.mp3") -- play the sound used for onClientSoundBeat
    addEventHandler("onClientSoundBeat", getRootElement(), changeVehicleColorOnSoundBeat)
addEventHandler("onClientResourceStart", getRootElement(), playMySound)

function changeVehicleColorOnSoundBeat()
    if getPedOccupiedVehicle(localPlayer) then -- if the player is inside a vehicle
    setVehicleColor( getPedOccupiedVehicle(localPlayer), math.random(0,255), math.random(0,255), math.random(0,255) ) -- apply the color to the vehicle
    outputChatBox("The color of your vehicle was changed.") 
    outputChatBox("Could not change the vehicle color, the localPlayer is not inside a vehicle.") 
    return end;


Minimum server version n/a
Minimum client version 1.3.0-9.04162

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.3.0-9.04162" />

See Also

Client sound events

Client event functions