OnClientSoundBeat: Difference between revisions
Jump to navigation
Jump to search
m (→Example) |
|||
Line 30: | Line 30: | ||
function changeVehicleColorOnSoundBeat() | function changeVehicleColorOnSoundBeat() | ||
if getPedOccupiedVehicle(localPlayer) then -- if the player is inside a vehicle | 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 | 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("The color of your vehicle was changed.") | ||
else | else |
Revision as of 14:13, 28 August 2023
This event is triggered when a sound beats.
Parameters
double theTime
- theTime: the position in the song of the beat
Source
The source of this event is the sound's element.
Example
Click to collapse [-]
ClientThis 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) end 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.") else outputChatBox("Could not change the vehicle color, the localPlayer is not inside a vehicle.") return end; end
Requirements
This template will be deleted.
See Also
Client sound events
- onClientSoundBeat
- onClientSoundChangedMeta
- onClientSoundFinishedDownload
- onClientSoundStarted
- onClientSoundStopped
- onClientSoundStream
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled